[PATCH] D47795: commandLineFitsWithinSystemLimits Overestimates System Limits
Alexander Kornienko via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 8 08:23:31 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL334295: commandLineFitsWithinSystemLimits Overestimates System Limits (authored by alexfh, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D47795?vs=150152&id=150522#toc
Repository:
rL LLVM
https://reviews.llvm.org/D47795
Files:
llvm/trunk/lib/Support/Unix/Program.inc
Index: llvm/trunk/lib/Support/Unix/Program.inc
===================================================================
--- llvm/trunk/lib/Support/Unix/Program.inc
+++ llvm/trunk/lib/Support/Unix/Program.inc
@@ -436,13 +436,24 @@
bool llvm::sys::commandLineFitsWithinSystemLimits(StringRef Program,
ArrayRef<const char *> Args) {
static long ArgMax = sysconf(_SC_ARG_MAX);
+ // POSIX requires that _POSIX_ARG_MAX is 4096, which is the lowest possible
+ // value for ARG_MAX on a POSIX compliant system.
+ static long ArgMin = _POSIX_ARG_MAX;
+
+ // This the same baseline used by xargs.
+ long EffectiveArgMax = 128 * 1024;
+
+ if (EffectiveArgMax > ArgMax)
+ EffectiveArgMax = ArgMax;
+ else if (EffectiveArgMax < ArgMin)
+ EffectiveArgMax = ArgMin;
// System says no practical limit.
if (ArgMax == -1)
return true;
// Conservatively account for space required by environment variables.
- long HalfArgMax = ArgMax / 2;
+ long HalfArgMax = EffectiveArgMax / 2;
size_t ArgLength = Program.size() + 1;
for (const char* Arg : Args) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47795.150522.patch
Type: text/x-patch
Size: 1122 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180608/0b5ba9c6/attachment.bin>
More information about the llvm-commits
mailing list