[PATCH] D47795: commandLineFitsWithinSystemLimits Overestimates System Limits
Austin Belknap via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 6 09:31:34 PDT 2018
dabelknap updated this revision to Diff 150152.
dabelknap added a comment.
Re-uploaded patch with full context.
https://reviews.llvm.org/D47795
Files:
lib/Support/Unix/Program.inc
Index: lib/Support/Unix/Program.inc
===================================================================
--- lib/Support/Unix/Program.inc
+++ lib/Support/Unix/Program.inc
@@ -434,13 +434,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.150152.patch
Type: text/x-patch
Size: 1089 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180606/13145cea/attachment.bin>
More information about the llvm-commits
mailing list