[cmake-developers] [PATCH] ninja: Generalize check for sysconf(3) call.
Raphael Kubo da Costa
rakuco at FreeBSD.org
Fri Jul 15 06:46:53 EDT 2016
Commit f9644a2d ("cmGlobalNinjaGenerator: Clarify logic for forcing use
of response files") started considering that negative command line
length values meant forcing the use of response files.
cmNinjaNormalTargetGenerator::calculateCommandLineLength() was not
implemented for certain operating systems such as the BSDs despite the
fact that sysconf(_SC_ARG_MAX) also works there. This caused problems
when generating static libraries, as ar(1) on FreeBSD does not recognize
the @file argument syntax.
By generalizing the checks for whether to use sysconf(_SC_ARG_MAX) this
problem can be worked around and we avoid having to change the #ifdef
for each new operating system implementing sysconf(3) according to
POSIX.
---
Source/cmNinjaNormalTargetGenerator.cxx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index c34df3c..5e965ff 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -375,7 +375,7 @@ static int calculateCommandLineLengthLimit(int linkRuleLength)
#ifdef _WIN32
8000,
#endif
-#if defined(__APPLE__) || defined(__HAIKU__) || defined(__linux)
+#if defined(_SC_ARG_MAX)
// for instance ARG_MAX is 2096152 on Ubuntu or 262144 on Mac
((int)sysconf(_SC_ARG_MAX)) - 1000,
#endif
--
2.9.0
More information about the cmake-developers
mailing list