nixpkgs-suyu/pkgs/build-support/cc-wrapper
Peter Waller e08ce498f0 cc-wrapper: Account for NIX_LDFLAGS and NIX_CFLAGS_LINK in linkType
Without this, pkgsStatic.pkgsLLVM.hello fails with segfaulting binaries
because of the issue described at [0].

In summary, llvm's linker has a different behaviour to GCC's when
supplied with both -static and -Wl,-dynamic-linker=...; GCC copes with
it, but LLVM produces a binary which segfaults on startup. It appears to
be necessary to omit the dynamic linker in this case.

nixpkgs' static adaptor passes -static via NIX_CFLAGS_LINK which was not
accounted for prior to this commit in the checkLinkType logic. For good
measure I put the other NIX_ flags affecting link in the same logic.

Additionally, $NIX_CFLAGS_LINK_@suffixSalt@ is not available until later
than it was originally set, so set $linkType close to its point of use.
I checked for earlier uses by studying the shell trace output and
couldn't find any.

[0] https://github.com/NixOS/nixpkgs/issues/111010#issuecomment-1536424163

Signed-off-by: Peter Waller <p@pwaller.net>
2023-09-03 13:49:50 +01:00
..
add-clang-cc-cflags-before.sh
add-flags.sh
add-gnat-extra-flags.sh
add-hardening.sh cc-wrapper: add fortify flags after invocation args, not before 2023-08-19 14:59:06 +01:00
cc-wrapper.sh cc-wrapper: Account for NIX_LDFLAGS and NIX_CFLAGS_LINK in linkType 2023-09-03 13:49:50 +01:00
default.nix win-dll-links: also copy dll from dependencies 2023-08-31 21:47:48 +03:00
fortran-hook.sh
gnat-wrapper.sh
go-wrapper.sh
setup-hook.sh hardening flags: enable fortify3 by default 2023-06-25 11:50:46 +01:00