mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 08:23:09 +00:00
e0d2053b87
When a response file is in use, "$*" contains the response file and not the parameters; both the linker and compiler wrappers are updated to use the response-expanded params. The compiler driver likes to pass parameters to the linker via a response file, including -shared. LLD rejects the combination of (-shared -pie), whereas other linkers silently ignore the contradiction: ``` ld.lld: error: -shared and -pie may not be used together ``` This breaks certain configurations using LLD as a linker. Changing `add-hardening.sh` results in a full rebuild. To avoid the rebuild, here is a quick test case which shows the new hardening script allows the link to succeed: ``` { pkgs ? import <nixpkgs> {} }: let # gcc silently accepts -shared -pie together, lld does not. linker = pkgs.wrapBintoolsWith { bintools = pkgs.llvmPackages.lld; }; patchWrapper = prev: prev.overrideAttrs (final: prev: let prevScript = builtins.match (".*(/nix/store/[a-z0-9]+-add-hardening.sh).*") prev.postFixup; in { postFixup = (builtins.replaceStrings prevScript ["${./new-add-hardening.sh}"] prev.postFixup); }); in pkgs.stdenv.mkDerivation { name = "nixpkgs-hardening-bug"; src = pkgs.writeText "src.c" "int main(int argc, char* argv[]) { return 0; }"; NIX_HARDENING_ENABLE = "pie"; unpackPhase = ":"; buildPhase = '' $CC -c -o src.o $src bash -x ${patchWrapper linker}/bin/ld.lld -o $out @${pkgs.writeText "responsefile" "-shared"} src.o ''; } ``` Fixes: #178162 Signed-off-by: Peter Waller <p@pwaller.net> |
||
---|---|---|
.. | ||
add-darwin-ldflags-before.sh | ||
add-flags.sh | ||
add-hardening.sh | ||
darwin-install_name_tool-wrapper.sh | ||
darwin-strip-wrapper.sh | ||
default.nix | ||
gnu-binutils-strip-wrapper.sh | ||
ld-solaris-wrapper.sh | ||
ld-wrapper.sh | ||
macos-sierra-reexport-hack.bash | ||
setup-hook.sh |