Set a default machine type when using lld targeting Windows.

Fixes autotools checks parsing --help
main
Shea Levy 2 years ago
parent 15aa32e082
commit d68a532d1b
No known key found for this signature in database
GPG Key ID: 5C0BD6957D86FE27
  1. 6
      pkgs/build-support/bintools-wrapper/add-lld-ldflags-before.sh
  2. 18
      pkgs/build-support/bintools-wrapper/default.nix

@ -0,0 +1,6 @@
# ld.lld has two incompatible command-line drivers: One for the gnu-compatible COFF linker and one for
# the ELF linker. If no emulation is set (with -m), it will default to the ELF linker;
# unfortunately, some configure scripts use `ld --help` to check for certain Windows-specific flags,
# which don't show up in the help for the ELF linker. So we set a default -m here.
extraBefore+=("-m" "@mtype@")

@ -384,6 +384,24 @@ stdenv.mkDerivation {
''
)
##
## Set the default machine type so that $prefix-ld.lld uses the COFF driver for --help
##
## Needed because autotools parses --help for linker features...
##
+ optionalString (isLld && stdenv.targetPlatform.isWindows) (let
mtype =
/**/ if targetPlatform.isx86_32 then "i386pe"
else if targetPlatform.isx86_64 then "i386pep"
else if targetPlatform.isAarch32 then "thumb2pe"
else if targetPlatform.isAarch64 then "arm64pe"
else throw "unsupported target arch for lld";
in ''
export mtype=${mtype}
substituteAll ${./add-lld-ldflags-before.sh} add-local-ldflags-before.sh
cat add-local-ldflags-before.sh >> $out/nix-support/add-local-ldflags-before.sh
'')
##
## Code signing on Apple Silicon
##

Loading…
Cancel
Save