nixpkgs/pkgs/build-support/cc-wrapper
Randy Eckenrode 6f2b3ba027 cc-wrapper: use a temporary file for reponse file
The Darwin stdenv rework conditionally sets `NIX_CC_USE_RESPONSE_FILE`
depending on the `ARG_MAX` of the build system. If it is at least 1 MiB,
the stdenv passes the arguments on the command-line (like Linux).
Otherwise, it falls back to the response file. This was done to prevent
intermitent failures with clang 16 being unable to read the response
file. Unfortunately, this breaks `gccStdenv` on older Darwin platforms.

Note: While the stdenv logic will also be reverted, this change is
needed for compatibility with clang 16.

GCC is capable of using a response file, but it does not work correctly
when the response file is a file descriptor. This can be reproduced
using the following sequence of commands:

    $ nix shell nixpkgs#gcc; NIX_CC_USE_RESPONSE_FILE=1 gcc
    # Linux
    /nix/store/9n9gjvzci75gp2sh1c4rh626dhizqynl-binutils-2.39/bin/ld: unrecognized option '-B/nix/store/vnwdak3n1w2jjil119j65k8mw1z23p84-glibc-2.35-224/lib/'
    /nix/store/9n9gjvzci75gp2sh1c4rh626dhizqynl-binutils-2.39/bin/ld: use the --help option for usage information
    collect2: error: ld returned 1 exit status
    # Darwin
    ld: unknown option: -mmacosx-version-min=11.0
    collect2: error: ld returned 1 exit status

Instead of using process substitution, create a temporary file and
remove it in a trap. This should also prevent the intermitent build
failures with clang 16 on older Darwin systems.

Fixes #245167
2023-08-01 10:32:56 +02:00
..
add-clang-cc-cflags-before.sh cc-wrapper: Add clang specific options to clang specific file 2022-06-15 11:34:53 -04:00
add-flags.sh cc-wrapper: change cflags order from cc/crt1/libc to crt1/libc/cc 2022-02-20 10:45:45 +00:00
add-gnat-extra-flags.sh cc-wrapper: Fix gnatmake wrapper 2023-01-07 18:32:12 +11:00
add-hardening.sh build-support: Use response-expanded params in pie test 2023-06-23 11:09:49 +01:00
cc-wrapper.sh cc-wrapper: use a temporary file for reponse file 2023-08-01 10:32:56 +02:00
default.nix Merge pull request #239624 from Stunkymonkey/use-optionalString-then 2023-07-22 13:02:47 +02:00
fortran-hook.sh cc-wrapper: fortran: enable stackprotector on M1 2022-08-19 16:41:36 -07:00
gnat-wrapper.sh cc-wrapper: Wrap/link all other GNAT commands 2023-01-07 18:32:12 +11:00
go-wrapper.sh gccgo: wrap go binary (#207670) 2023-01-20 14:31:54 +01:00
setup-hook.sh hardening flags: enable fortify3 by default 2023-06-25 11:50:46 +01:00