Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Response files provided by pipes break build-bom #3

Open
travitch opened this issue Jul 1, 2021 · 0 comments
Open

Response files provided by pipes break build-bom #3

travitch opened this issue Jul 1, 2021 · 0 comments

Comments

@travitch
Copy link
Owner

travitch commented Jul 1, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant