Set a default machine type when using lld targeting Windows.

Fixes autotools checks parsing --help
This commit is contained in:
Shea Levy 2022-05-06 07:20:03 -04:00
parent 15aa32e082
commit d68a532d1b
No known key found for this signature in database
GPG key ID: 5C0BD6957D86FE27
2 changed files with 24 additions and 0 deletions

View file

@ -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@")

View file

@ -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
##