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

wrapper-common/utils.bash, gcc: @file params are not put back into an @file after expansion #255359

Open
jsoo1 opened this issue Sep 15, 2023 · 0 comments
Labels
0.kind: bug Something is broken

Comments

@jsoo1
Copy link
Contributor

jsoo1 commented Sep 15, 2023

Describe the bug

When a tool uses an @file to execute gcc (or any of the gnu linkers) via the wrappers, expandResponseParams undoes the @file that the tool uses. For example hsc2hs always uses @files to run linkers (see https://github.com/haskell/hsc2hs/blob/5bf5c61e7c6e813d03bc069e17289c574185d41c/src/Common.hs#L37).

But in the wrappers (via utils.bash) expandResponseParams silently expand @files and re-execs the compiler/linker without the @file in the cc/ld wrappers. See

expandResponseParams() {
For example - the linker only checks NIX_LD_USE_RESPONSE_FILE here
if (( "${NIX_LD_USE_RESPONSE_FILE:-@use_response_file_by_default@}" >= 1 )); then
even if an @file was explicitly requested by the invoking tool.

This results in E2BIG for even small hsc2hs invocations.

This would seem easy enough to fix - by setting an env var like NIX_REPONSE_FILE_EXPANDED=1 and also checking that, but it seems to break some packages (like bison and ghc itself though maybe this is fixed on staging).

Related to #41340

Steps To Reproduce

(on x86_64-linux) nix build github:awakesecurity/nixpkgs?ref=reproduce-expand-response-params#haskellPackages.termonad
See reproducing patch here: awakesecurity@97fde27

Expected behavior

@files should be restored after expanding if the original execution requested it.

Notify maintainers

@vcunat @Ericson2314 @Synthetica9

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 5.10.177, NixOS, 22.05 (Quokka)`
 - multi-user?: `yes`
 - sandbox: `relaxed`
 - version: `nix-env (Nix) 2.15.1`
@jsoo1 jsoo1 added the 0.kind: bug Something is broken label Sep 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken
Projects
None yet
Development

No branches or pull requests

1 participant