diff options
author | Brad King <brad.king@kitware.com> | 2017-03-28 14:14:35 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2017-03-28 14:14:40 (GMT) |
commit | 4d970868489e7a7a45419ad74444afe2ab8239ee (patch) | |
tree | 1cdd94de9a8afc2ba72bac14649116367ab133e9 /Source | |
parent | 21499431e05b0defb134b10b1753488c0516bafd (diff) | |
parent | 92fe00d33cb029a583de20a16e5bc17bd337ed57 (diff) | |
download | CMake-4d970868489e7a7a45419ad74444afe2ab8239ee.zip CMake-4d970868489e7a7a45419ad74444afe2ab8239ee.tar.gz CMake-4d970868489e7a7a45419ad74444afe2ab8239ee.tar.bz2 |
Merge topic 'ninja-fix-sysconf-non-limit'
92fe00d3 Ninja: Fix command line limit when sysconf has no ARG_MAX
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !633
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmNinjaNormalTargetGenerator.cxx | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 5552fa9..560eb4f 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -544,10 +544,6 @@ static int calculateCommandLineLengthLimit(int linkRuleLength) #ifdef _WIN32 8000, #endif -#if defined(_SC_ARG_MAX) - // 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, @@ -556,7 +552,15 @@ static int calculateCommandLineLengthLimit(int linkRuleLength) }; size_t const arrSz = cmArraySize(limits); - int const sz = *std::min_element(limits, limits + arrSz); + int sz = *std::min_element(limits, limits + arrSz); +#if defined(_SC_ARG_MAX) + // for instance ARG_MAX is 2096152 on Ubuntu or 262144 on Mac + int const szArgMax = static_cast<int>(sysconf(_SC_ARG_MAX)); + // a return value of -1 signifies an unrestricted value + if (szArgMax != -1) { + sz = std::min(sz, szArgMax - 1000); + } +#endif if (sz == std::numeric_limits<int>::max()) { return 0; } |