treewide: Try to make a few bootstrapping things more consistent

- Introduce `preLibcCrossHeaders` to bootstrap libgcc and compiler-rt
the same way.

- Organize LLVM bintools as `bintools{-unwrapped,,NoLibc}` for
consistency with GNU Binutils and Apple's cctools.

- Do Android changes for all `llvmPackages` for consistency.

- Improve the way the default GCC and LLVM versions are selected.

+301 -169
pkgs/development/compilers/llvm/10/bintools.nix pkgs/development/compilers/llvm/10/bintools/default.nix
+7 -7
pkgs/development/compilers/llvm/10/compiler-rt/default.nix
··· 4 4 5 5 useLLVM = stdenv.hostPlatform.useLLVM or false; 6 6 bareMetal = stdenv.hostPlatform.parsed.kernel.name == "none"; 7 + haveLibc = stdenv.cc.libc != null; 7 8 inherit (stdenv.hostPlatform) isMusl; 8 9 9 10 in 10 11 11 - stdenv.mkDerivation rec { 12 - pname = "compiler-rt"; 12 + stdenv.mkDerivation { 13 + pname = "compiler-rt" + lib.optionalString (haveLibc) "-libc"; 13 14 inherit version; 14 - src = fetch pname "1yjqjri753w0fzmxcyz687nvd97sbc9rsqrxzpq720na47hwh3fr"; 15 + src = fetch "compiler-rt" "1yjqjri753w0fzmxcyz687nvd97sbc9rsqrxzpq720na47hwh3fr"; 15 16 16 17 nativeBuildInputs = [ cmake python3 llvm.dev ]; 17 18 buildInputs = lib.optional stdenv.hostPlatform.isDarwin libcxxabi; ··· 29 30 "-DCOMPILER_RT_BUILD_XRAY=OFF" 30 31 "-DCOMPILER_RT_BUILD_LIBFUZZER=OFF" 31 32 "-DCOMPILER_RT_BUILD_PROFILE=OFF" 32 - ] ++ lib.optionals (useLLVM || bareMetal) [ 33 + ] ++ lib.optionals ((useLLVM || bareMetal) && !haveLibc) [ 33 34 "-DCMAKE_C_COMPILER_WORKS=ON" 34 35 "-DCMAKE_CXX_COMPILER_WORKS=ON" 35 36 "-DCOMPILER_RT_BAREMETAL_BUILD=ON" 36 37 "-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}" 38 + ] ++ lib.optionals (useLLVM && !haveLibc) [ 39 + "-DCMAKE_C_FLAGS=-nodefaultlibs" 37 40 ] ++ lib.optionals (useLLVM) [ 38 41 "-DCOMPILER_RT_BUILD_BUILTINS=ON" 39 - "-DCMAKE_C_FLAGS=-nodefaultlibs" 40 42 #https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program 41 43 "-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY" 42 44 ] ++ lib.optionals (bareMetal) [ ··· 57 59 ./gnu-install-dirs.patch 58 60 ]# ++ lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch 59 61 ++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch; 60 - 61 62 62 63 # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks 63 64 # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra ··· 88 89 ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o 89 90 ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/crtendS.o 90 91 ''; 91 - 92 92 }
+41 -17
pkgs/development/compilers/llvm/10/default.nix
··· 1 - { lowPrio, newScope, pkgs, lib, stdenv, cmake, gccForLibs 1 + { lowPrio, newScope, pkgs, lib, stdenv, cmake 2 + , gccForLibs, preLibcCrossHeaders 2 3 , libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith 3 4 , buildLlvmTools # tools, but from the previous stage, for cross 4 5 , targetLlvmLibraries # libraries, but from the next stage, for cross ··· 93 94 # doesn’t support like LLVM. Probably we should move to some other 94 95 # file. 95 96 96 - bintools = callPackage ./bintools.nix {}; 97 + bintools-unwrapped = callPackage ./bintools {}; 98 + 99 + bintoolsNoLibc = wrapBintoolsWith { 100 + bintools = tools.bintools-unwrapped; 101 + libc = preLibcCrossHeaders; 102 + }; 103 + 104 + bintools = wrapBintoolsWith { 105 + bintools = tools.bintools-unwrapped; 106 + }; 97 107 98 108 lldClang = wrapCCWith rec { 99 109 cc = tools.clang-unwrapped; ··· 112 122 echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags 113 123 '' + lib.optionalString (!stdenv.targetPlatform.isWasm) '' 114 124 echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags 125 + '' + lib.optionalString (stdenv.targetPlatform.isAndroid && stdenv.targetPlatform.useLLVM) '' 126 + echo "-lunwind" >> $out/nix-support/cc-ldflags 115 127 '' + lib.optionalString stdenv.targetPlatform.isWasm '' 116 128 echo "-fno-exceptions" >> $out/nix-support/cc-cflags 117 129 '' + mkExtraBuildCommands cc; ··· 120 132 lldClangNoLibcxx = wrapCCWith rec { 121 133 cc = tools.clang-unwrapped; 122 134 libcxx = null; 123 - bintools = wrapBintoolsWith { 124 - inherit (tools) bintools; 125 - }; 135 + inherit (tools) bintools; 126 136 extraPackages = [ 127 137 targetLlvmLibraries.compiler-rt 128 138 ]; ··· 136 146 lldClangNoLibc = wrapCCWith rec { 137 147 cc = tools.clang-unwrapped; 138 148 libcxx = null; 139 - bintools = wrapBintoolsWith { 140 - inherit (tools) bintools; 141 - libc = null; 142 - }; 149 + bintools = tools.bintoolsNoLibc; 143 150 extraPackages = [ 144 151 targetLlvmLibraries.compiler-rt 145 152 ]; ··· 152 159 lldClangNoCompilerRt = wrapCCWith rec { 153 160 cc = tools.clang-unwrapped; 154 161 libcxx = null; 155 - bintools = wrapBintoolsWith { 156 - inherit (tools) bintools; 157 - libc = null; 158 - }; 162 + bintools = tools.bintoolsNoLibc; 159 163 extraPackages = [ ]; 160 164 extraBuildCommands = '' 161 165 echo "-nostartfiles" >> $out/nix-support/cc-cflags 162 166 '' + mkExtraBuildCommands0 cc; 163 167 }; 164 168 169 + lldClangNoCompilerRtWithLibc = wrapCCWith rec { 170 + cc = tools.clang-unwrapped; 171 + libcxx = null; 172 + inherit (tools) bintools; 173 + extraPackages = [ ]; 174 + extraBuildCommands = mkExtraBuildCommands0 cc; 175 + }; 176 + 165 177 }); 166 178 167 179 libraries = lib.makeExtensible (libraries: let 168 180 callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; }); 169 181 in { 170 182 171 - compiler-rt = callPackage ./compiler-rt ({} // 172 - (lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) { 173 - stdenv = overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt; 174 - })); 183 + compiler-rt-libc = callPackage ./compiler-rt { 184 + stdenv = if stdenv.hostPlatform.useLLVM or false 185 + then overrideCC stdenv buildLlvmTools.lldClangNoCompilerRtWithLibc 186 + else stdenv; 187 + }; 188 + 189 + compiler-rt-no-libc = callPackage ./compiler-rt { 190 + stdenv = if stdenv.hostPlatform.useLLVM or false 191 + then overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt 192 + else stdenv; 193 + }; 194 + 195 + # N.B. condition is safe because without useLLVM both are the same. 196 + compiler-rt = if stdenv.hostPlatform.isAndroid 197 + then libraries.compiler-rt-libc 198 + else libraries.compiler-rt-no-libc; 175 199 176 200 stdenv = overrideCC stdenv buildLlvmTools.clang; 177 201
pkgs/development/compilers/llvm/11/bintools.nix pkgs/development/compilers/llvm/11/bintools/default.nix
+7 -7
pkgs/development/compilers/llvm/11/compiler-rt/default.nix
··· 4 4 5 5 useLLVM = stdenv.hostPlatform.useLLVM or false; 6 6 bareMetal = stdenv.hostPlatform.parsed.kernel.name == "none"; 7 + haveLibc = stdenv.cc.libc != null; 7 8 inherit (stdenv.hostPlatform) isMusl; 8 9 9 10 in 10 11 11 - stdenv.mkDerivation rec { 12 - pname = "compiler-rt"; 12 + stdenv.mkDerivation { 13 + pname = "compiler-rt" + lib.optionalString (haveLibc) "-libc"; 13 14 inherit version; 14 - src = fetch pname "0x1j8ngf1zj63wlnns9vlibafq48qcm72p4jpaxkmkb4qw0grwfy"; 15 + src = fetch "compiler-rt" "0x1j8ngf1zj63wlnns9vlibafq48qcm72p4jpaxkmkb4qw0grwfy"; 15 16 16 17 nativeBuildInputs = [ cmake python3 llvm.dev ]; 17 18 buildInputs = lib.optional stdenv.hostPlatform.isDarwin libcxxabi; ··· 29 30 "-DCOMPILER_RT_BUILD_XRAY=OFF" 30 31 "-DCOMPILER_RT_BUILD_LIBFUZZER=OFF" 31 32 "-DCOMPILER_RT_BUILD_PROFILE=OFF" 32 - ] ++ lib.optionals (useLLVM || bareMetal) [ 33 + ] ++ lib.optionals ((useLLVM || bareMetal) && !haveLibc) [ 33 34 "-DCMAKE_C_COMPILER_WORKS=ON" 34 35 "-DCMAKE_CXX_COMPILER_WORKS=ON" 35 36 "-DCOMPILER_RT_BAREMETAL_BUILD=ON" 36 37 "-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}" 38 + ] ++ lib.optionals (useLLVM && !haveLibc) [ 39 + "-DCMAKE_C_FLAGS=-nodefaultlibs" 37 40 ] ++ lib.optionals (useLLVM) [ 38 41 "-DCOMPILER_RT_BUILD_BUILTINS=ON" 39 - "-DCMAKE_C_FLAGS=-nodefaultlibs" 40 42 #https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program 41 43 "-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY" 42 44 ] ++ lib.optionals (bareMetal) [ ··· 58 60 ./normalize-var.patch 59 61 ]# ++ lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch 60 62 ++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch; 61 - 62 63 63 64 # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks 64 65 # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra ··· 91 92 ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o 92 93 ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/crtendS.o 93 94 ''; 94 - 95 95 }
+41 -17
pkgs/development/compilers/llvm/11/default.nix
··· 1 - { lowPrio, newScope, pkgs, lib, stdenv, cmake, gccForLibs 1 + { lowPrio, newScope, pkgs, lib, stdenv, cmake 2 + , gccForLibs, preLibcCrossHeaders 2 3 , libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith 3 4 , buildLlvmTools # tools, but from the previous stage, for cross 4 5 , targetLlvmLibraries # libraries, but from the next stage, for cross ··· 94 95 # doesn’t support like LLVM. Probably we should move to some other 95 96 # file. 96 97 97 - bintools = callPackage ./bintools.nix {}; 98 + bintools-unwrapped = callPackage ./bintools {}; 99 + 100 + bintoolsNoLibc = wrapBintoolsWith { 101 + bintools = tools.bintools-unwrapped; 102 + libc = preLibcCrossHeaders; 103 + }; 104 + 105 + bintools = wrapBintoolsWith { 106 + bintools = tools.bintools-unwrapped; 107 + }; 98 108 99 109 lldClang = wrapCCWith rec { 100 110 cc = tools.clang-unwrapped; ··· 113 123 echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags 114 124 '' + lib.optionalString (!stdenv.targetPlatform.isWasm) '' 115 125 echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags 126 + '' + lib.optionalString (stdenv.targetPlatform.isAndroid && stdenv.targetPlatform.useLLVM) '' 127 + echo "-lunwind" >> $out/nix-support/cc-ldflags 116 128 '' + lib.optionalString stdenv.targetPlatform.isWasm '' 117 129 echo "-fno-exceptions" >> $out/nix-support/cc-cflags 118 130 '' + mkExtraBuildCommands cc; ··· 121 133 lldClangNoLibcxx = wrapCCWith rec { 122 134 cc = tools.clang-unwrapped; 123 135 libcxx = null; 124 - bintools = wrapBintoolsWith { 125 - inherit (tools) bintools; 126 - }; 136 + inherit (tools) bintools; 127 137 extraPackages = [ 128 138 targetLlvmLibraries.compiler-rt 129 139 ]; ··· 137 147 lldClangNoLibc = wrapCCWith rec { 138 148 cc = tools.clang-unwrapped; 139 149 libcxx = null; 140 - bintools = wrapBintoolsWith { 141 - inherit (tools) bintools; 142 - libc = null; 143 - }; 150 + bintools = tools.bintoolsNoLibc; 144 151 extraPackages = [ 145 152 targetLlvmLibraries.compiler-rt 146 153 ]; ··· 153 160 lldClangNoCompilerRt = wrapCCWith rec { 154 161 cc = tools.clang-unwrapped; 155 162 libcxx = null; 156 - bintools = wrapBintoolsWith { 157 - inherit (tools) bintools; 158 - libc = null; 159 - }; 163 + bintools = tools.bintoolsNoLibc; 160 164 extraPackages = [ ]; 161 165 extraBuildCommands = '' 162 166 echo "-nostartfiles" >> $out/nix-support/cc-cflags 163 167 '' + mkExtraBuildCommands0 cc; 164 168 }; 165 169 170 + lldClangNoCompilerRtWithLibc = wrapCCWith rec { 171 + cc = tools.clang-unwrapped; 172 + libcxx = null; 173 + inherit (tools) bintools; 174 + extraPackages = [ ]; 175 + extraBuildCommands = mkExtraBuildCommands0 cc; 176 + }; 177 + 166 178 }); 167 179 168 180 libraries = lib.makeExtensible (libraries: let 169 181 callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; }); 170 182 in { 171 183 172 - compiler-rt = callPackage ./compiler-rt ({} // 173 - (lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) { 174 - stdenv = overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt; 175 - })); 184 + compiler-rt-libc = callPackage ./compiler-rt { 185 + stdenv = if stdenv.hostPlatform.useLLVM or false 186 + then overrideCC stdenv buildLlvmTools.lldClangNoCompilerRtWithLibc 187 + else stdenv; 188 + }; 189 + 190 + compiler-rt-no-libc = callPackage ./compiler-rt { 191 + stdenv = if stdenv.hostPlatform.useLLVM or false 192 + then overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt 193 + else stdenv; 194 + }; 195 + 196 + # N.B. condition is safe because without useLLVM both are the same. 197 + compiler-rt = if stdenv.hostPlatform.isAndroid 198 + then libraries.compiler-rt-libc 199 + else libraries.compiler-rt-no-libc; 176 200 177 201 stdenv = overrideCC stdenv buildLlvmTools.clang; 178 202
+1 -2
pkgs/development/compilers/llvm/12/compiler-rt/default.nix
··· 9 9 10 10 in 11 11 12 - stdenv.mkDerivation rec { 12 + stdenv.mkDerivation { 13 13 pname = "compiler-rt" + lib.optionalString (haveLibc) "-libc"; 14 14 inherit version; 15 15 src = fetch "compiler-rt" "0d444qihq9jhqnfv003cr704v363va72zl6qaw2algj1c85cva45"; ··· 60 60 ./normalize-var.patch 61 61 ]# ++ lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch 62 62 ++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch; 63 - 64 63 65 64 # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks 66 65 # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra
+28 -24
pkgs/development/compilers/llvm/12/default.nix
··· 1 - { lowPrio, newScope, pkgs, lib, stdenv, cmake, gccForLibs 1 + { lowPrio, newScope, pkgs, lib, stdenv, cmake 2 + , gccForLibs, preLibcCrossHeaders 2 3 , libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith 3 4 , buildLlvmTools # tools, but from the previous stage, for cross 4 5 , targetLlvmLibraries # libraries, but from the next stage, for cross ··· 112 113 # doesn’t support like LLVM. Probably we should move to some other 113 114 # file. 114 115 115 - bintools = callPackage ./bintools {}; 116 + bintools-unwrapped = callPackage ./bintools {}; 117 + 118 + bintoolsNoLibc = wrapBintoolsWith { 119 + bintools = tools.bintools-unwrapped; 120 + libc = preLibcCrossHeaders; 121 + }; 122 + 123 + bintools = wrapBintoolsWith { 124 + bintools = tools.bintools-unwrapped; 125 + }; 116 126 117 127 lldClang = wrapCCWith rec { 118 128 cc = tools.clang-unwrapped; ··· 141 151 lldClangNoLibcxx = wrapCCWith rec { 142 152 cc = tools.clang-unwrapped; 143 153 libcxx = null; 144 - bintools = wrapBintoolsWith { 145 - inherit (tools) bintools; 146 - }; 154 + inherit (tools) bintools; 147 155 extraPackages = [ 148 156 targetLlvmLibraries.compiler-rt 149 157 ]; ··· 157 165 lldClangNoLibc = wrapCCWith rec { 158 166 cc = tools.clang-unwrapped; 159 167 libcxx = null; 160 - bintools = wrapBintoolsWith { 161 - inherit (tools) bintools; 162 - libc = null; 163 - }; 168 + bintools = tools.bintoolsNoLibc; 164 169 extraPackages = [ 165 170 targetLlvmLibraries.compiler-rt 166 171 ]; ··· 173 178 lldClangNoCompilerRt = wrapCCWith rec { 174 179 cc = tools.clang-unwrapped; 175 180 libcxx = null; 176 - bintools = wrapBintoolsWith { 177 - inherit (tools) bintools; 178 - libc = null; 179 - }; 181 + bintools = tools.bintoolsNoLibc; 180 182 extraPackages = [ ]; 181 183 extraBuildCommands = '' 182 184 echo "-nostartfiles" >> $out/nix-support/cc-cflags ··· 186 188 lldClangNoCompilerRtWithLibc = wrapCCWith rec { 187 189 cc = tools.clang-unwrapped; 188 190 libcxx = null; 189 - bintools = wrapBintoolsWith { 190 - inherit (tools) bintools; 191 - }; 191 + inherit (tools) bintools; 192 192 extraPackages = [ ]; 193 193 extraBuildCommands = mkExtraBuildCommands0 cc; 194 194 }; ··· 199 199 callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; }); 200 200 in { 201 201 202 - compiler-rt-libc = callPackage ./compiler-rt ({ inherit llvm_meta; } // 203 - (lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) { 204 - stdenv = overrideCC stdenv buildLlvmTools.lldClangNoCompilerRtWithLibc; 205 - })); 202 + compiler-rt-libc = callPackage ./compiler-rt { 203 + inherit llvm_meta; 204 + stdenv = if stdenv.hostPlatform.useLLVM or false 205 + then overrideCC stdenv buildLlvmTools.lldClangNoCompilerRtWithLibc 206 + else stdenv; 207 + }; 206 208 207 - compiler-rt-no-libc = callPackage ./compiler-rt ({ inherit llvm_meta; } // 208 - (lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) { 209 - stdenv = overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt; 210 - })); 209 + compiler-rt-no-libc = callPackage ./compiler-rt { 210 + inherit llvm_meta; 211 + stdenv = if stdenv.hostPlatform.useLLVM or false 212 + then overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt 213 + else stdenv; 214 + }; 211 215 212 216 # N.B. condition is safe because without useLLVM both are the same. 213 217 compiler-rt = if stdenv.hostPlatform.isAndroid
pkgs/development/compilers/llvm/7/bintools.nix pkgs/development/compilers/llvm/7/bintools/default.nix
+9 -8
pkgs/development/compilers/llvm/7/compiler-rt/default.nix
··· 4 4 5 5 useLLVM = stdenv.hostPlatform.useLLVM or false; 6 6 bareMetal = stdenv.hostPlatform.parsed.kernel.name == "none"; 7 + haveLibc = stdenv.cc.libc != null; 7 8 inherit (stdenv.hostPlatform) isMusl; 8 9 9 10 in 10 11 11 12 stdenv.mkDerivation { 12 - pname = "compiler-rt"; 13 + pname = "compiler-rt" + lib.optionalString (haveLibc) "-libc"; 13 14 inherit version; 14 15 src = fetch "compiler-rt" "1n48p8gjarihkws0i2bay5w9bdwyxyxxbpwyng7ba58jb30dlyq5"; 15 16 ··· 29 30 "-DCOMPILER_RT_BUILD_XRAY=OFF" 30 31 "-DCOMPILER_RT_BUILD_LIBFUZZER=OFF" 31 32 "-DCOMPILER_RT_BUILD_PROFILE=OFF" 32 - ] ++ lib.optionals (useLLVM || bareMetal) [ 33 + ] ++ lib.optionals ((useLLVM || bareMetal) && !haveLibc) [ 33 34 "-DCMAKE_C_COMPILER_WORKS=ON" 34 35 "-DCMAKE_CXX_COMPILER_WORKS=ON" 35 36 "-DCOMPILER_RT_BAREMETAL_BUILD=ON" 36 37 "-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}" 38 + ] ++ lib.optionals (useLLVM && !haveLibc) [ 39 + "-DCMAKE_C_FLAGS=-nodefaultlibs" 37 40 ] ++ lib.optionals (useLLVM) [ 38 41 "-DCOMPILER_RT_BUILD_BUILTINS=ON" 39 - "-DCMAKE_C_FLAGS=-nodefaultlibs" 40 42 #https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program 41 43 "-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY" 42 44 ] ++ lib.optionals (bareMetal) [ ··· 83 85 postInstall = lib.optionalString (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isWasm) '' 84 86 ln -s "$out/lib"/*/* "$out/lib" 85 87 '' + lib.optionalString (useLLVM) '' 86 - ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/linux/crtbegin.o 87 - ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/linux/crtend.o 88 - ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/linux/crtbeginS.o 89 - ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/linux/crtendS.o 88 + ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/crtbegin.o 89 + ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/crtend.o 90 + ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o 91 + ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/crtendS.o 90 92 ''; 91 - 92 93 }
+37 -14
pkgs/development/compilers/llvm/7/default.nix
··· 1 - { lowPrio, newScope, pkgs, lib, stdenv, cmake, gccForLibs 1 + { lowPrio, newScope, pkgs, lib, stdenv, cmake 2 + , gccForLibs, preLibcCrossHeaders 2 3 , libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith 3 4 , buildLlvmTools # tools, but from the previous stage, for cross 4 5 , targetLlvmLibraries # libraries, but from the next stage, for cross ··· 95 96 # doesn’t support like LLVM. Probably we should move to some other 96 97 # file. 97 98 98 - bintools = callPackage ./bintools.nix {}; 99 + bintools-unwrapped = callPackage ./bintools {}; 100 + 101 + bintoolsNoLibc = wrapBintoolsWith { 102 + bintools = tools.bintools-unwrapped; 103 + libc = preLibcCrossHeaders; 104 + }; 105 + 106 + bintools = wrapBintoolsWith { 107 + bintools = tools.bintools-unwrapped; 108 + }; 99 109 100 110 lldClang = wrapCCWith rec { 101 111 cc = tools.clang-unwrapped; ··· 114 124 echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags 115 125 '' + lib.optionalString (!stdenv.targetPlatform.isWasm) '' 116 126 echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags 127 + '' + lib.optionalString (stdenv.targetPlatform.isAndroid && stdenv.targetPlatform.useLLVM) '' 128 + echo "-lunwind" >> $out/nix-support/cc-ldflags 117 129 '' + lib.optionalString stdenv.targetPlatform.isWasm '' 118 130 echo "-fno-exceptions" >> $out/nix-support/cc-cflags 119 131 '' + mkExtraBuildCommands cc; ··· 122 134 lldClangNoLibcxx = wrapCCWith rec { 123 135 cc = tools.clang-unwrapped; 124 136 libcxx = null; 125 - bintools = wrapBintoolsWith { 126 - inherit (tools) bintools; 127 - }; 137 + inherit (tools) bintools; 128 138 extraPackages = [ 129 139 targetLlvmLibraries.compiler-rt 130 140 ]; ··· 138 148 lldClangNoLibc = wrapCCWith rec { 139 149 cc = tools.clang-unwrapped; 140 150 libcxx = null; 141 - bintools = wrapBintoolsWith { 142 - inherit (tools) bintools; 143 - libc = null; 144 - }; 151 + bintools = tools.bintoolsNoLibc; 145 152 extraPackages = [ 146 153 targetLlvmLibraries.compiler-rt 147 154 ]; ··· 154 161 lldClangNoCompilerRt = wrapCCWith rec { 155 162 cc = tools.clang-unwrapped; 156 163 libcxx = null; 157 - bintools = wrapBintoolsWith { 158 - inherit (tools) bintools; 159 - libc = null; 160 - }; 164 + bintools = tools.bintoolsNoLibc; 161 165 extraPackages = [ ]; 162 166 extraBuildCommands = '' 163 167 echo "-nostartfiles" >> $out/nix-support/cc-cflags 164 168 '' + mkExtraBuildCommands0 cc; 165 169 }; 166 170 171 + lldClangNoCompilerRtWithLibc = wrapCCWith rec { 172 + cc = tools.clang-unwrapped; 173 + libcxx = null; 174 + inherit (tools) bintools; 175 + extraPackages = [ ]; 176 + extraBuildCommands = mkExtraBuildCommands0 cc; 177 + }; 178 + 167 179 }); 168 180 169 181 libraries = lib.makeExtensible (libraries: let 170 182 callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; }); 171 183 in { 172 184 173 - compiler-rt = callPackage ./compiler-rt { 185 + compiler-rt-libc = callPackage ./compiler-rt { 186 + stdenv = if stdenv.hostPlatform.useLLVM or false 187 + then overrideCC stdenv buildLlvmTools.lldClangNoCompilerRtWithLibc 188 + else stdenv; 189 + }; 190 + 191 + compiler-rt-no-libc = callPackage ./compiler-rt { 174 192 stdenv = if stdenv.hostPlatform.useLLVM or false 175 193 then overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt 176 194 else stdenv; 177 195 }; 196 + 197 + # N.B. condition is safe because without useLLVM both are the same. 198 + compiler-rt = if stdenv.hostPlatform.isAndroid 199 + then libraries.compiler-rt-libc 200 + else libraries.compiler-rt-no-libc; 178 201 179 202 stdenv = overrideCC stdenv buildLlvmTools.clang; 180 203
pkgs/development/compilers/llvm/8/bintools.nix pkgs/development/compilers/llvm/8/bintools/default.nix
+5 -4
pkgs/development/compilers/llvm/8/compiler-rt/default.nix
··· 4 4 5 5 useLLVM = stdenv.hostPlatform.useLLVM or false; 6 6 bareMetal = stdenv.hostPlatform.parsed.kernel.name == "none"; 7 + haveLibc = stdenv.cc.libc != null; 7 8 inherit (stdenv.hostPlatform) isMusl; 8 9 9 10 in 10 11 11 12 stdenv.mkDerivation { 12 - pname = "compiler-rt"; 13 + pname = "compiler-rt" + lib.optionalString (haveLibc) "-libc"; 13 14 inherit version; 14 15 src = fetch "compiler-rt" "0dqqf8f930l8gag4d9qjgn1n0pj0nbv2anviqqhdi1rkhas8z0hi"; 15 16 ··· 29 30 "-DCOMPILER_RT_BUILD_XRAY=OFF" 30 31 "-DCOMPILER_RT_BUILD_LIBFUZZER=OFF" 31 32 "-DCOMPILER_RT_BUILD_PROFILE=OFF" 32 - ] ++ lib.optionals (useLLVM || bareMetal) [ 33 + ] ++ lib.optionals ((useLLVM || bareMetal) && !haveLibc) [ 33 34 "-DCMAKE_C_COMPILER_WORKS=ON" 34 35 "-DCMAKE_CXX_COMPILER_WORKS=ON" 35 36 "-DCOMPILER_RT_BAREMETAL_BUILD=ON" 36 37 "-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}" 38 + ] ++ lib.optionals (useLLVM && !haveLibc) [ 39 + "-DCMAKE_C_FLAGS=-nodefaultlibs" 37 40 ] ++ lib.optionals (useLLVM) [ 38 41 "-DCOMPILER_RT_BUILD_BUILTINS=ON" 39 - "-DCMAKE_C_FLAGS=-nodefaultlibs" 40 42 #https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program 41 43 "-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY" 42 44 ] ++ lib.optionals (bareMetal) [ ··· 88 90 ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o 89 91 ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/crtendS.o 90 92 ''; 91 - 92 93 }
+41 -17
pkgs/development/compilers/llvm/8/default.nix
··· 1 - { lowPrio, newScope, pkgs, lib, stdenv, cmake, gccForLibs 1 + { lowPrio, newScope, pkgs, lib, stdenv, cmake 2 + , gccForLibs, preLibcCrossHeaders 2 3 , libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith 3 4 , buildLlvmTools # tools, but from the previous stage, for cross 4 5 , targetLlvmLibraries # libraries, but from the next stage, for cross ··· 96 97 # doesn’t support like LLVM. Probably we should move to some other 97 98 # file. 98 99 99 - bintools = callPackage ./bintools.nix {}; 100 + bintools-unwrapped = callPackage ./bintools {}; 101 + 102 + bintoolsNoLibc = wrapBintoolsWith { 103 + bintools = tools.bintools-unwrapped; 104 + libc = preLibcCrossHeaders; 105 + }; 106 + 107 + bintools = wrapBintoolsWith { 108 + bintools = tools.bintools-unwrapped; 109 + }; 100 110 101 111 lldClang = wrapCCWith rec { 102 112 cc = tools.clang-unwrapped; ··· 115 125 echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags 116 126 '' + lib.optionalString (!stdenv.targetPlatform.isWasm) '' 117 127 echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags 128 + '' + lib.optionalString (stdenv.targetPlatform.isAndroid && stdenv.targetPlatform.useLLVM) '' 129 + echo "-lunwind" >> $out/nix-support/cc-ldflags 118 130 '' + lib.optionalString stdenv.targetPlatform.isWasm '' 119 131 echo "-fno-exceptions" >> $out/nix-support/cc-cflags 120 132 '' + mkExtraBuildCommands cc; ··· 123 135 lldClangNoLibcxx = wrapCCWith rec { 124 136 cc = tools.clang-unwrapped; 125 137 libcxx = null; 126 - bintools = wrapBintoolsWith { 127 - inherit (tools) bintools; 128 - }; 138 + inherit (tools) bintools; 129 139 extraPackages = [ 130 140 targetLlvmLibraries.compiler-rt 131 141 ]; ··· 139 149 lldClangNoLibc = wrapCCWith rec { 140 150 cc = tools.clang-unwrapped; 141 151 libcxx = null; 142 - bintools = wrapBintoolsWith { 143 - inherit (tools) bintools; 144 - libc = null; 145 - }; 152 + bintools = tools.bintoolsNoLibc; 146 153 extraPackages = [ 147 154 targetLlvmLibraries.compiler-rt 148 155 ]; ··· 155 162 lldClangNoCompilerRt = wrapCCWith rec { 156 163 cc = tools.clang-unwrapped; 157 164 libcxx = null; 158 - bintools = wrapBintoolsWith { 159 - inherit (tools) bintools; 160 - libc = null; 161 - }; 165 + bintools = tools.bintoolsNoLibc; 162 166 extraPackages = [ ]; 163 167 extraBuildCommands = '' 164 168 echo "-nostartfiles" >> $out/nix-support/cc-cflags 165 169 '' + mkExtraBuildCommands0 cc; 166 170 }; 167 171 172 + lldClangNoCompilerRtWithLibc = wrapCCWith rec { 173 + cc = tools.clang-unwrapped; 174 + libcxx = null; 175 + inherit (tools) bintools; 176 + extraPackages = [ ]; 177 + extraBuildCommands = mkExtraBuildCommands0 cc; 178 + }; 179 + 168 180 }); 169 181 170 182 libraries = lib.makeExtensible (libraries: let 171 183 callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; }); 172 184 in { 173 185 174 - compiler-rt = callPackage ./compiler-rt ({} // 175 - (lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) { 176 - stdenv = overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt; 177 - })); 186 + compiler-rt-libc = callPackage ./compiler-rt { 187 + stdenv = if stdenv.hostPlatform.useLLVM or false 188 + then overrideCC stdenv buildLlvmTools.lldClangNoCompilerRtWithLibc 189 + else stdenv; 190 + }; 191 + 192 + compiler-rt-no-libc = callPackage ./compiler-rt { 193 + stdenv = if stdenv.hostPlatform.useLLVM or false 194 + then overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt 195 + else stdenv; 196 + }; 197 + 198 + # N.B. condition is safe because without useLLVM both are the same. 199 + compiler-rt = if stdenv.hostPlatform.isAndroid 200 + then libraries.compiler-rt-libc 201 + else libraries.compiler-rt-no-libc; 178 202 179 203 stdenv = overrideCC stdenv buildLlvmTools.clang; 180 204
pkgs/development/compilers/llvm/9/bintools.nix pkgs/development/compilers/llvm/9/bintools/default.nix
+7 -5
pkgs/development/compilers/llvm/9/compiler-rt/default.nix
··· 4 4 5 5 useLLVM = stdenv.hostPlatform.useLLVM or false; 6 6 bareMetal = stdenv.hostPlatform.parsed.kernel.name == "none"; 7 + haveLibc = stdenv.cc.libc != null; 7 8 inherit (stdenv.hostPlatform) isMusl; 8 9 9 10 in 10 11 11 - stdenv.mkDerivation rec { 12 - pname = "compiler-rt"; 12 + stdenv.mkDerivation { 13 + pname = "compiler-rt" + lib.optionalString (haveLibc) "-libc"; 13 14 inherit version; 14 - src = fetch pname "0xwh79g3zggdabxgnd0bphry75asm1qz7mv3hcqihqwqr6aspgy2"; 15 + src = fetch "compiler-rt" "0xwh79g3zggdabxgnd0bphry75asm1qz7mv3hcqihqwqr6aspgy2"; 15 16 16 17 nativeBuildInputs = [ cmake python3 llvm.dev ]; 17 18 buildInputs = lib.optional stdenv.hostPlatform.isDarwin libcxxabi; ··· 29 30 "-DCOMPILER_RT_BUILD_XRAY=OFF" 30 31 "-DCOMPILER_RT_BUILD_LIBFUZZER=OFF" 31 32 "-DCOMPILER_RT_BUILD_PROFILE=OFF" 32 - ] ++ lib.optionals (useLLVM || bareMetal) [ 33 + ] ++ lib.optionals ((useLLVM || bareMetal) && !haveLibc) [ 33 34 "-DCMAKE_C_COMPILER_WORKS=ON" 34 35 "-DCMAKE_CXX_COMPILER_WORKS=ON" 35 36 "-DCOMPILER_RT_BAREMETAL_BUILD=ON" 36 37 "-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}" 38 + ] ++ lib.optionals (useLLVM && !haveLibc) [ 39 + "-DCMAKE_C_FLAGS=-nodefaultlibs" 37 40 ] ++ lib.optionals (useLLVM) [ 38 41 "-DCOMPILER_RT_BUILD_BUILTINS=ON" 39 - "-DCMAKE_C_FLAGS=-nodefaultlibs" 40 42 #https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program 41 43 "-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY" 42 44 ] ++ lib.optionals (bareMetal) [
+41 -17
pkgs/development/compilers/llvm/9/default.nix
··· 1 - { lowPrio, newScope, pkgs, lib, stdenv, cmake, gccForLibs 1 + { lowPrio, newScope, pkgs, lib, stdenv, cmake 2 + , gccForLibs, preLibcCrossHeaders 2 3 , libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith 3 4 , buildLlvmTools # tools, but from the previous stage, for cross 4 5 , targetLlvmLibraries # libraries, but from the next stage, for cross ··· 96 97 # doesn’t support like LLVM. Probably we should move to some other 97 98 # file. 98 99 99 - bintools = callPackage ./bintools.nix {}; 100 + bintools-unwrapped = callPackage ./bintools {}; 101 + 102 + bintoolsNoLibc = wrapBintoolsWith { 103 + bintools = tools.bintools-unwrapped; 104 + libc = preLibcCrossHeaders; 105 + }; 106 + 107 + bintools = wrapBintoolsWith { 108 + bintools = tools.bintools-unwrapped; 109 + }; 100 110 101 111 lldClang = wrapCCWith rec { 102 112 cc = tools.clang-unwrapped; ··· 115 125 echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags 116 126 '' + lib.optionalString (!stdenv.targetPlatform.isWasm) '' 117 127 echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags 128 + '' + lib.optionalString (stdenv.targetPlatform.isAndroid && stdenv.targetPlatform.useLLVM) '' 129 + echo "-lunwind" >> $out/nix-support/cc-ldflags 118 130 '' + lib.optionalString stdenv.targetPlatform.isWasm '' 119 131 echo "-fno-exceptions" >> $out/nix-support/cc-cflags 120 132 '' + mkExtraBuildCommands cc; ··· 123 135 lldClangNoLibcxx = wrapCCWith rec { 124 136 cc = tools.clang-unwrapped; 125 137 libcxx = null; 126 - bintools = wrapBintoolsWith { 127 - inherit (tools) bintools; 128 - }; 138 + inherit (tools) bintools; 129 139 extraPackages = [ 130 140 targetLlvmLibraries.compiler-rt 131 141 ]; ··· 139 149 lldClangNoLibc = wrapCCWith rec { 140 150 cc = tools.clang-unwrapped; 141 151 libcxx = null; 142 - bintools = wrapBintoolsWith { 143 - inherit (tools) bintools; 144 - libc = null; 145 - }; 152 + bintools = tools.bintoolsNoLibc; 146 153 extraPackages = [ 147 154 targetLlvmLibraries.compiler-rt 148 155 ]; ··· 155 162 lldClangNoCompilerRt = wrapCCWith rec { 156 163 cc = tools.clang-unwrapped; 157 164 libcxx = null; 158 - bintools = wrapBintoolsWith { 159 - inherit (tools) bintools; 160 - libc = null; 161 - }; 165 + bintools = tools.bintoolsNoLibc; 162 166 extraPackages = [ ]; 163 167 extraBuildCommands = '' 164 168 echo "-nostartfiles" >> $out/nix-support/cc-cflags 165 169 '' + mkExtraBuildCommands0 cc; 166 170 }; 167 171 172 + lldClangNoCompilerRtWithLibc = wrapCCWith rec { 173 + cc = tools.clang-unwrapped; 174 + libcxx = null; 175 + inherit (tools) bintools; 176 + extraPackages = [ ]; 177 + extraBuildCommands = mkExtraBuildCommands0 cc; 178 + }; 179 + 168 180 }); 169 181 170 182 libraries = lib.makeExtensible (libraries: let 171 183 callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; }); 172 184 in { 173 185 174 - compiler-rt = callPackage ./compiler-rt ({} // 175 - (lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) { 176 - stdenv = overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt; 177 - })); 186 + compiler-rt-libc = callPackage ./compiler-rt { 187 + stdenv = if stdenv.hostPlatform.useLLVM or false 188 + then overrideCC stdenv buildLlvmTools.lldClangNoCompilerRtWithLibc 189 + else stdenv; 190 + }; 191 + 192 + compiler-rt-no-libc = callPackage ./compiler-rt { 193 + stdenv = if stdenv.hostPlatform.useLLVM or false 194 + then overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt 195 + else stdenv; 196 + }; 197 + 198 + # N.B. condition is safe because without useLLVM both are the same. 199 + compiler-rt = if stdenv.hostPlatform.isAndroid 200 + then libraries.compiler-rt-libc 201 + else libraries.compiler-rt-no-libc; 178 202 179 203 stdenv = overrideCC stdenv buildLlvmTools.clang; 180 204
+34 -29
pkgs/top-level/all-packages.nix
··· 10345 10345 gerbil-support = callPackage ../development/compilers/gerbil/gerbil-support.nix { }; 10346 10346 gerbilPackages-unstable = gerbil-support.gerbilPackages-unstable; # NB: don't recurseIntoAttrs for (unstable!) libraries 10347 10347 10348 - gccFun = callPackage (if (with stdenv.targetPlatform; isVc4 || libc == "relibc") 10349 - then ../development/compilers/gcc/6 10350 - else ../development/compilers/gcc/10); 10351 - gcc = if (with stdenv.targetPlatform; isVc4 || libc == "relibc") 10352 - then gcc6 else 10353 - # aarch64-darwin doesn't support earlier gcc 10354 - if (stdenv.targetPlatform.isAarch64 && stdenv.isDarwin) then gcc11 10355 - else if stdenv.targetPlatform.isAarch64 then gcc9 else gcc10; 10348 + inherit (let 10349 + num = 10350 + if (with stdenv.targetPlatform; isVc4 || libc == "relibc") then 6 10351 + else if (stdenv.targetPlatform.isAarch64 && stdenv.isDarwin) then 11 10352 + else if stdenv.targetPlatform.isAarch64 then 9 10353 + else 10; 10354 + numS = toString num; 10355 + in { 10356 + gcc = pkgs.${"gcc${numS}"}; 10357 + gccFun = callPackage (../development/compilers/gcc + "/${numS}"); 10358 + }) gcc gccFun; 10356 10359 gcc-unwrapped = gcc.cc; 10357 10360 10358 10361 wrapNonDeterministicGcc = stdenv: ccWrapper: ··· 10430 10433 10431 10434 crossLibcStdenv = 10432 10435 if stdenv.hostPlatform.useLLVM or false 10433 - then overrideCC stdenv buildPackages.llvmPackages_8.lldClangNoLibc 10436 + then overrideCC stdenv buildPackages.llvmPackages.lldClangNoLibc 10434 10437 else gccCrossLibcStdenv; 10435 10438 10436 10439 # The GCC used to build libc for the target platform. Normal gccs will be ··· 11175 11178 llvm_6 = llvmPackages_6.llvm; 11176 11179 llvm_5 = llvmPackages_5.llvm; 11177 11180 11178 - llvmPackages = with targetPlatform; 11179 - if isDarwin then 11180 - llvmPackages_7 11181 - else if isFreeBSD then 11182 - llvmPackages_7 11183 - else if isAndroid then 11184 - llvmPackages_12 11185 - else if isLinux then 11186 - llvmPackages_7 11187 - else if isWasm then 11188 - llvmPackages_8 11189 - else 11190 - llvmPackages_latest; 11181 + llvmPackages = let 11182 + choose = platform: 11183 + /**/ if platform.isDarwin then "7" 11184 + else if platform.isFreeBSD then "7" 11185 + else if platform.isAndroid then "12" 11186 + else if platform.isLinux then "7" 11187 + else if platform.isWasm then "8" 11188 + else "latest"; 11189 + minSupported = lib.min (choose stdenv.hostPlatform) (choose stdenv.targetPlatform); 11190 + in pkgs.${"llvmPackages_${minSupported}"}; 11191 11191 11192 11192 llvmPackages_5 = recurseIntoAttrs (callPackage ../development/compilers/llvm/5 { 11193 11193 inherit (stdenvAdapters) overrideCC; ··· 12602 12602 }); 12603 12603 binutilsNoLibc = wrapBintoolsWith { 12604 12604 bintools = binutils-unwrapped; 12605 - libc = 12606 - /**/ if stdenv.targetPlatform.libc == "msvcrt" then targetPackages.windows.mingw_w64_headers 12607 - else if stdenv.targetPlatform.libc == "libSystem" then darwin.xcode 12608 - else if stdenv.targetPlatform.libc == "nblibc" then targetPackages.netbsdCross.headers 12609 - else null; 12605 + libc = preLibcCrossHeaders; 12610 12606 }; 12611 12607 12612 12608 bison = callPackage ../development/tools/parsing/bison { }; ··· 14741 14737 stdenv = crossLibcStdenv; 14742 14738 }; 14743 14739 14740 + # These are used when buiding compiler-rt / libgcc, prior to building libc. 14741 + preLibcCrossHeaders = let 14742 + inherit (stdenv.targetPlatform) libc; 14743 + in if libc == "msvcrt" then targetPackages.windows.mingw_w64_headers 14744 + else if libc == "nblibc" then targetPackages.netbsdCross.headers 14745 + else null; 14746 + 14744 14747 # We can choose: 14745 14748 libcCrossChooser = name: 14746 14749 # libc is hackily often used from the previous stage. This `or` ··· 14755 14758 else if name == "newlib" then targetPackages.newlibCross or newlibCross 14756 14759 else if name == "musl" then targetPackages.muslCross or muslCross 14757 14760 else if name == "msvcrt" then targetPackages.windows.mingw_w64 or windows.mingw_w64 14758 - else if stdenv.targetPlatform.useiOSPrebuilt then targetPackages.darwin.iosSdkPkgs.libraries or darwin.iosSdkPkgs.libraries 14759 - else if name == "libSystem" then targetPackages.darwin.xcode 14761 + else if name == "libSystem" then 14762 + if stdenv.targetPlatform.useiOSPrebuilt 14763 + then targetPackages.darwin.iosSdkPkgs.libraries or darwin.iosSdkPkgs.libraries 14764 + else throw "don't yet have a `targetPackages.darwin.LibsystemCross`" 14760 14765 else if name == "nblibc" then targetPackages.netbsdCross.libc or netbsdCross.libc 14761 14766 else if name == "wasilibc" then targetPackages.wasilibc or wasilibc 14762 14767 else if name == "relibc" then targetPackages.relibc or relibc
+2 -1
pkgs/top-level/darwin-packages.nix
··· 2 2 , buildPackages, pkgs, targetPackages 3 3 , pkgsBuildBuild, pkgsBuildHost, pkgsBuildTarget, pkgsHostHost, pkgsTargetTarget 4 4 , stdenv, splicePackages, newScope 5 + , preLibcCrossHeaders 5 6 }: 6 7 7 8 let ··· 52 53 }; 53 54 54 55 binutilsNoLibc = pkgs.wrapBintoolsWith { 55 - libc = null; 56 + libc = preLibcCrossHeaders; 56 57 bintools = self.binutils-unwrapped; 57 58 }; 58 59