You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Clang supports response files, which are special "file" arguments prefixed by @ that actually contain the command line arguments that clang should be invoked with. This facility is generally used to support long command lines that exceed system capabilities (especially on Windows). In unusual cases, the file containing the arguments could actually be a pipe. In that case, build-bom generate-bitcode runs the original compilation command, which "drains" the pipe. When it re-runs the command to generate bitcode, the pipe is empty and clang receives no arguments, which means that no bitcode is generated.
This has been observed by @kquick on Nix, which has a wrapper script around clang that uses this pattern.
We can fix this by noticing cases where clang is being invoked with a response file that points to a pipe. If we see that, drain the pipe in build-bom before invoking the original command and save the contents of the response file. Then persist the contents to a temporary file and tweak the execve arguments to the original command to point to the temporary file. When we run the bitcode generation command, just reuse that same temporary file. Note that there is a bit of a technical challenge here, as the filename must exist in the process. We will likely need to both allocate storage for the filename and poke the path byte-by-byte (or via /dev/mem) into the process. This isn't conceptually difficult, but will take effort to implement.
The text was updated successfully, but these errors were encountered:
Clang supports response files, which are special "file" arguments prefixed by
@
that actually contain the command line arguments that clang should be invoked with. This facility is generally used to support long command lines that exceed system capabilities (especially on Windows). In unusual cases, the file containing the arguments could actually be a pipe. In that case,build-bom generate-bitcode
runs the original compilation command, which "drains" the pipe. When it re-runs the command to generate bitcode, the pipe is empty and clang receives no arguments, which means that no bitcode is generated.This has been observed by @kquick on Nix, which has a wrapper script around clang that uses this pattern.
We can fix this by noticing cases where clang is being invoked with a response file that points to a pipe. If we see that, drain the pipe in
build-bom
before invoking the original command and save the contents of the response file. Then persist the contents to a temporary file and tweak theexecve
arguments to the original command to point to the temporary file. When we run the bitcode generation command, just reuse that same temporary file. Note that there is a bit of a technical challenge here, as the filename must exist in the process. We will likely need to both allocate storage for the filename and poke the path byte-by-byte (or via /dev/mem) into the process. This isn't conceptually difficult, but will take effort to implement.The text was updated successfully, but these errors were encountered: