diff options
author | Brad King <brad.king@kitware.com> | 2015-01-26 14:51:53 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2015-01-26 14:51:53 (GMT) |
commit | dfdcc42c60c723200a0ec9dc0c49e9765384733a (patch) | |
tree | 7ee10b5061875c7271b3ba705d5a99da0cf638dc /Source/cmNinjaNormalTargetGenerator.cxx | |
parent | 1337576b24feef973fca7cc45c695b495b3f8a5e (diff) | |
parent | 097e26f4908b3099f112c3fdc5e043234f9adc53 (diff) | |
download | CMake-dfdcc42c60c723200a0ec9dc0c49e9765384733a.zip CMake-dfdcc42c60c723200a0ec9dc0c49e9765384733a.tar.gz CMake-dfdcc42c60c723200a0ec9dc0c49e9765384733a.tar.bz2 |
Merge topic 'ninja-rsp_file-calculation'
097e26f4 ninja: use the minimum of all command line length limits (#14892)
Diffstat (limited to 'Source/cmNinjaNormalTargetGenerator.cxx')
-rw-r--r-- | Source/cmNinjaNormalTargetGenerator.cxx | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 32a5ccf..c352c1a 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -22,6 +22,7 @@ #include <assert.h> #include <algorithm> +#include <limits> #ifndef _WIN32 #include <unistd.h> @@ -366,15 +367,29 @@ cmNinjaNormalTargetGenerator static int calculateCommandLineLengthLimit(int linkRuleLength) { + static int const limits[] = { #ifdef _WIN32 - return 8000 - linkRuleLength; -#elif defined(__linux) || defined(__APPLE__) || defined(__HAIKU__) - // for instance ARG_MAX is 2096152 on Ubuntu or 262144 on Mac - return ((int)sysconf(_SC_ARG_MAX)) - linkRuleLength - 1000; -#else - (void)linkRuleLength; - return -1; + 8000, #endif +#if defined(__APPLE__) || defined(__HAIKU__) || defined(__linux) + // for instance ARG_MAX is 2096152 on Ubuntu or 262144 on Mac + ((int)sysconf(_SC_ARG_MAX)) - 1000, +#endif +#if defined(__linux) + // #define MAX_ARG_STRLEN (PAGE_SIZE * 32) in Linux's binfmts.h + ((int)sysconf(_SC_PAGESIZE) * 32) - 1000, +#endif + std::numeric_limits<int>::max() + }; + + size_t const arrSz = cmArraySize(limits); + int const sz = *std::min_element(limits, limits + arrSz); + if (sz == std::numeric_limits<int>::max()) + { + return -1; + } + + return sz - linkRuleLength; } |