···11-# ld.lld has two incompatible command-line drivers: One for the gnu-compatible COFF linker and one for
22-# the ELF linker. If no emulation is set (with -m), it will default to the ELF linker;
33-# unfortunately, some configure scripts use `ld --help` to check for certain Windows-specific flags,
44-# which don't show up in the help for the ELF linker. So we set a default -m here.
55-66-extraBefore+=("-m" "@mtype@")
-32
pkgs/build-support/bintools-wrapper/default.nix
···31313232# Darwin code signing support utilities
3333, postLinkSignHook ? null, signingUtils ? null
3434-3535-# Linker type
3636-, isLld ? bintools.isLld or false
3737-, isCctools ? bintools.isCctools or false
3838-, isGNU ? bintools.isGNU or false
3939-, isGold ? bintools.isGold or false
4040-, isBfd ? bintools.isBfd or false
4134}:
42354336with lib;
···119112120113 passthru = {
121114 inherit bintools libc nativeTools nativeLibc nativePrefix;
122122-123123- inherit isLld isCctools isGNU isGold isBfd;
124115125116 emacsBufferSetup = pkgs: ''
126117 ; We should handle propagation here too
···302293 echo "-arch ${targetPlatform.darwinArch}" >> $out/nix-support/libc-ldflags
303294 ''
304295305305- # lld's MinGW driver (e.g. `ld.lld -m i386pep`) does not support the `-z` flag.
306306- + optionalString (targetPlatform.isWindows && isLld) ''
307307- hardening_unsupported_flags+=" relro bindnow"
308308- ''
309309-310296 ##
311297 ## GNU specific extra strip flags
312298 ##
···350336 substituteAll ${./add-darwin-ldflags-before.sh} $out/nix-support/add-local-ldflags-before.sh
351337 ''
352338 )
353353-354354- ##
355355- ## Set the default machine type so that $prefix-ld.lld uses the COFF driver for --help
356356- ##
357357- ## Needed because autotools parses --help for linker features...
358358- ##
359359- + optionalString (isLld && stdenv.targetPlatform.isWindows) (let
360360- mtype =
361361- /**/ if targetPlatform.isx86_32 then "i386pe"
362362- else if targetPlatform.isx86_64 then "i386pep"
363363- else if targetPlatform.isAarch32 then "thumb2pe"
364364- else if targetPlatform.isAarch64 then "arm64pe"
365365- else throw "unsupported target arch for lld";
366366- in ''
367367- export mtype=${mtype}
368368- substituteAll ${./add-lld-ldflags-before.sh} add-local-ldflags-before.sh
369369- cat add-local-ldflags-before.sh >> $out/nix-support/add-local-ldflags-before.sh
370370- '')
371339372340 ##
373341 ## Code signing on Apple Silicon
···4646 ];
47474848 # Only the C compiler, and explicitly not C++ compiler needs this flag on solaris:
4949- CFLAGS =
5050- # Only the C compiler, and explicitly not C++ compiler needs this flag on solaris:
5151- /**/ if stdenv.isSunOS then "-D_XOPEN_SOURCE_EXTENDED"
5252- # ucrt doesn't support X_OK to access() without this flag
5353- else if stdenv.hostPlatform.libc == "ucrt" then "-D__USE_MINGW_ACCESS"
5454- else "";
5555-4949+ CFLAGS = lib.optionalString stdenv.isSunOS "-D_XOPEN_SOURCE_EXTENDED";
56505751 depsBuildBuild = [
5852 buildPackages.stdenv.cc
+4-4
pkgs/development/libraries/zlib/default.nix
···8888 ''
8989 # Non-typical naming confuses libtool which then refuses to use zlib's DLL
9090 # in some cases, e.g. when compiling libpng.
9191- + lib.optionalString (stdenv.hostPlatform.isMinGW && shared) ''
9191+ + lib.optionalString (stdenv.hostPlatform.libc == "msvcrt" && shared) ''
9292 ln -s zlib1.dll $out/bin/libz.dll
9393 '';
9494···101101 dontStrip = stdenv.hostPlatform != stdenv.buildPlatform && static;
102102 configurePlatforms = [];
103103104104- installFlags = lib.optionals (stdenv.hostPlatform.isMinGW) [
104104+ installFlags = lib.optionals (stdenv.hostPlatform.libc == "msvcrt") [
105105 "BINARY_PATH=$(out)/bin"
106106 "INCLUDE_PATH=$(dev)/include"
107107 "LIBRARY_PATH=$(out)/lib"
···112112113113 makeFlags = [
114114 "PREFIX=${stdenv.cc.targetPrefix}"
115115- ] ++ lib.optionals (stdenv.hostPlatform.isMinGW) [
115115+ ] ++ lib.optionals (stdenv.hostPlatform.libc == "msvcrt") [
116116 "-f" "win32/Makefile.gcc"
117117 ] ++ lib.optionals shared [
118118 # Note that as of writing (zlib 1.2.11), this flag only has an effect
···134134 preConfigure = ''
135135 export CHOST=${stdenv.hostPlatform.config}
136136 '';
137137-} // lib.optionalAttrs (stdenv.hostPlatform.isMinGW) {
137137+} // lib.optionalAttrs (stdenv.hostPlatform.libc == "msvcrt") {
138138 dontConfigure = true;
139139})
-5
pkgs/development/tools/misc/binutils/default.nix
···203203 inherit targetPrefix;
204204 hasGold = enableGold;
205205 isGNU = true;
206206- # TODO Currently platform.linker == "gold" has no effect outside
207207- # of building GHC. If/when that's fixed, these flags should
208208- # probably move to the invocations of bintools-wrapper
209209- isGold = false;
210210- isBfd = true;
211206 };
212207213208 meta = with lib; {
···11-From a18473ed4e5574dab899db640b8efeff78939b54 Mon Sep 17 00:00:00 2001
22-From: Manoj Gupta <manojgupta@chromium.org>
33-Date: Wed, 10 Oct 2018 10:50:23 +0300
44-Subject: [PATCH 1/2] Pick up clang_rt static archives compiler internal
55- libraries
66-77-Libtool checks only for libraries linked as -l* when trying to
88-find internal compiler libraries. Clang, however uses the absolute
99-path to link its internal libraries e.g. compiler_rt. This patch
1010-handles clang's statically linked libraries when finding internal
1111-compiler libraries.
1212-https://crbug.com/749263
1313-https://debbugs.gnu.org/cgi/bugreport.cgi?bug=27866
1414----
1515- m4/libtool.m4 | 2 +-
1616- 1 file changed, 1 insertion(+), 1 deletion(-)
1717-1818-diff --git a/m4/libtool.m4 b/m4/libtool.m4
1919-index b55a6e5..d9322d0 100644
2020---- a/m4/libtool.m4
2121-+++ b/m4/libtool.m4
2222-@@ -7556,7 +7556,7 @@ if AC_TRY_EVAL(ac_compile); then
2323- for p in `eval "$output_verbose_link_cmd"`; do
2424- case $prev$p in
2525-2626-- -L* | -R* | -l*)
2727-+ -L* | -R* | -l* | */libclang_rt.*.a)
2828- # Some compilers place space between "-{L,R}" and the path.
2929- # Remove the space.
3030- if test x-L = "$p" ||
3131---
3232-2.7.4
3333-
···1740217402 # These are used when buiding compiler-rt / libgcc, prior to building libc.
1740317403 preLibcCrossHeaders = let
1740417404 inherit (stdenv.targetPlatform) libc;
1740517405- in if libc == "msvcrt" || libc == "ucrt" then targetPackages.windows.mingw_w64_headers or windows.mingw_w64_headers
1740517405+ in if libc == "msvcrt" then targetPackages.windows.mingw_w64_headers or windows.mingw_w64_headers
1740617406 else if libc == "nblibc" then targetPackages.netbsdCross.headers or netbsdCross.headers
1740717407 else if libc == "libSystem" && stdenv.targetPlatform.isAarch64 then targetPackages.darwin.LibsystemCross or darwin.LibsystemCross
1740817408 else null;
···1742117421 else if name == "newlib" then targetPackages.newlibCross or newlibCross
1742217422 else if name == "newlib-nano" then targetPackages.newlib-nanoCross or newlib-nanoCross
1742317423 else if name == "musl" then targetPackages.muslCross or muslCross
1742417424- else if name == "msvcrt" || name == "ucrt" then targetPackages.windows.mingw_w64 or windows.mingw_w64
1742417424+ else if name == "msvcrt" then targetPackages.windows.mingw_w64 or windows.mingw_w64
1742517425 else if name == "libSystem" then
1742617426 if stdenv.targetPlatform.useiOSPrebuilt
1742717427 then targetPackages.darwin.iosSdkPkgs.libraries or darwin.iosSdkPkgs.libraries