1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00
llvm-mirror/lib/Support/Unix
Alexander Kornienko 73a92659e5 commandLineFitsWithinSystemLimits Overestimates System Limits
Summary:
The function `llvm::sys::commandLineFitsWithinSystemLimits` appears to be overestimating the system limits. This issue was discovered while attempting to enable response files in the Swift compiler. When the compiler submits its frontend jobs, those jobs are subjected to the system limits on command line length. `commandLineFitsWithinSystemLimits` is used to determine if the job's arguments need to be wrapped in a response file. There are some cases where the argument size for the job passes `commandLineFitsWithinSystemLimits`, but actually exceeds the real system limit, and the job fails.

`clang` also uses this function to decide whether or not to wrap it's job arguments in response files. See: https://github.com/llvm-mirror/clang/blob/master/lib/Driver/Driver.cpp#L1341. Clang will also fail for response files who's size falls within a certain range. I wrote a script that should find a failure point for `clang++`. All that is needed to run it is Python 2.7, and a simple "hello world" program for `test.cc`. It should run on Linux and on macOS. The script is available here: https://gist.github.com/dabelknap/71bd083cd06b91c5b3cef6a7f4d3d427. When it hits a failure point, you should see a `clang: error: unable to execute command: posix_spawn failed: Argument list too long`.

The proposed solution is to mirror the behavior of `xargs` in `commandLinefitsWithinSystemLimits`. `xargs` defaults to 128k for the command line length size (See: https://fossies.org/dox/findutils-4.6.0/buildcmd_8c_source.html#l00551). It adjusts this depending on the value of `ARG_MAX`.

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: llvm-commits

Tags: #clang

Patch by Austin Belknap!

Differential Revision: https://reviews.llvm.org/D47795

llvm-svn: 334295
2018-06-08 15:19:16 +00:00
..
COM.inc
DynamicLibrary.inc
Host.inc [Support] Avoid normalization in sys::getDefaultTargetTriple 2018-05-25 20:39:37 +00:00
Memory.inc [Support] Use zx_cache_flush on Fuchsia to flush instruction cache 2018-06-06 06:26:18 +00:00
Mutex.inc
Path.inc Add a file open flag that disables O_CLOEXEC. 2018-06-08 15:15:56 +00:00
Process.inc IWYU for llvm-config.h in llvm, additions. 2018-04-30 14:59:11 +00:00
Program.inc commandLineFitsWithinSystemLimits Overestimates System Limits 2018-06-08 15:19:16 +00:00
README.txt
RWMutex.inc
Signals.inc Signal handling should be signal-safe 2018-05-16 17:25:35 +00:00
Threading.inc
ThreadLocal.inc IWYU for llvm-config.h in llvm, additions. 2018-04-30 14:59:11 +00:00
Unix.h Remove @brief commands from doxygen comments, too. 2018-05-01 16:10:38 +00:00
Watchdog.inc IWYU for llvm-config.h in llvm, additions. 2018-04-30 14:59:11 +00:00

llvm/lib/Support/Unix README
===========================

This directory provides implementations of the lib/System classes that
are common to two or more variants of UNIX. For example, the directory
structure underneath this directory could look like this:

Unix           - only code that is truly generic to all UNIX platforms
  Posix        - code that is specific to Posix variants of UNIX
  SUS          - code that is specific to the Single Unix Specification
  SysV         - code that is specific to System V variants of UNIX

As a rule, only those directories actually needing to be created should be
created. Also, further subdirectories could be created to reflect versions of
the various standards. For example, under SUS there could be v1, v2, and v3
subdirectories to reflect the three major versions of SUS.