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.
This commit is contained in:
parent
e0d3c9d031
commit
37194a325d
|
@ -4,14 +4,15 @@ let
|
||||||
|
|
||||||
useLLVM = stdenv.hostPlatform.useLLVM or false;
|
useLLVM = stdenv.hostPlatform.useLLVM or false;
|
||||||
bareMetal = stdenv.hostPlatform.parsed.kernel.name == "none";
|
bareMetal = stdenv.hostPlatform.parsed.kernel.name == "none";
|
||||||
|
haveLibc = stdenv.cc.libc != null;
|
||||||
inherit (stdenv.hostPlatform) isMusl;
|
inherit (stdenv.hostPlatform) isMusl;
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation {
|
||||||
pname = "compiler-rt";
|
pname = "compiler-rt" + lib.optionalString (haveLibc) "-libc";
|
||||||
inherit version;
|
inherit version;
|
||||||
src = fetch pname "1yjqjri753w0fzmxcyz687nvd97sbc9rsqrxzpq720na47hwh3fr";
|
src = fetch "compiler-rt" "1yjqjri753w0fzmxcyz687nvd97sbc9rsqrxzpq720na47hwh3fr";
|
||||||
|
|
||||||
nativeBuildInputs = [ cmake python3 llvm.dev ];
|
nativeBuildInputs = [ cmake python3 llvm.dev ];
|
||||||
buildInputs = lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
|
buildInputs = lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
|
||||||
|
@ -29,14 +30,15 @@ stdenv.mkDerivation rec {
|
||||||
"-DCOMPILER_RT_BUILD_XRAY=OFF"
|
"-DCOMPILER_RT_BUILD_XRAY=OFF"
|
||||||
"-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
|
"-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
|
||||||
"-DCOMPILER_RT_BUILD_PROFILE=OFF"
|
"-DCOMPILER_RT_BUILD_PROFILE=OFF"
|
||||||
] ++ lib.optionals (useLLVM || bareMetal) [
|
] ++ lib.optionals ((useLLVM || bareMetal) && !haveLibc) [
|
||||||
"-DCMAKE_C_COMPILER_WORKS=ON"
|
"-DCMAKE_C_COMPILER_WORKS=ON"
|
||||||
"-DCMAKE_CXX_COMPILER_WORKS=ON"
|
"-DCMAKE_CXX_COMPILER_WORKS=ON"
|
||||||
"-DCOMPILER_RT_BAREMETAL_BUILD=ON"
|
"-DCOMPILER_RT_BAREMETAL_BUILD=ON"
|
||||||
"-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}"
|
"-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}"
|
||||||
|
] ++ lib.optionals (useLLVM && !haveLibc) [
|
||||||
|
"-DCMAKE_C_FLAGS=-nodefaultlibs"
|
||||||
] ++ lib.optionals (useLLVM) [
|
] ++ lib.optionals (useLLVM) [
|
||||||
"-DCOMPILER_RT_BUILD_BUILTINS=ON"
|
"-DCOMPILER_RT_BUILD_BUILTINS=ON"
|
||||||
"-DCMAKE_C_FLAGS=-nodefaultlibs"
|
|
||||||
#https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program
|
#https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program
|
||||||
"-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
|
"-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
|
||||||
] ++ lib.optionals (bareMetal) [
|
] ++ lib.optionals (bareMetal) [
|
||||||
|
@ -58,7 +60,6 @@ stdenv.mkDerivation rec {
|
||||||
]# ++ lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch
|
]# ++ lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch
|
||||||
++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch;
|
++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch;
|
||||||
|
|
||||||
|
|
||||||
# TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
|
# TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
|
||||||
# to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra
|
# to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra
|
||||||
# can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd
|
# can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd
|
||||||
|
@ -88,5 +89,4 @@ stdenv.mkDerivation rec {
|
||||||
ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o
|
ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o
|
||||||
ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/crtendS.o
|
ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/crtendS.o
|
||||||
'';
|
'';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{ lowPrio, newScope, pkgs, lib, stdenv, cmake, gccForLibs
|
{ lowPrio, newScope, pkgs, lib, stdenv, cmake
|
||||||
|
, gccForLibs, preLibcCrossHeaders
|
||||||
, libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
|
, libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
|
||||||
, buildLlvmTools # tools, but from the previous stage, for cross
|
, buildLlvmTools # tools, but from the previous stage, for cross
|
||||||
, targetLlvmLibraries # libraries, but from the next stage, for cross
|
, targetLlvmLibraries # libraries, but from the next stage, for cross
|
||||||
|
@ -93,7 +94,16 @@ let
|
||||||
# doesn’t support like LLVM. Probably we should move to some other
|
# doesn’t support like LLVM. Probably we should move to some other
|
||||||
# file.
|
# file.
|
||||||
|
|
||||||
bintools = callPackage ./bintools.nix {};
|
bintools-unwrapped = callPackage ./bintools {};
|
||||||
|
|
||||||
|
bintoolsNoLibc = wrapBintoolsWith {
|
||||||
|
bintools = tools.bintools-unwrapped;
|
||||||
|
libc = preLibcCrossHeaders;
|
||||||
|
};
|
||||||
|
|
||||||
|
bintools = wrapBintoolsWith {
|
||||||
|
bintools = tools.bintools-unwrapped;
|
||||||
|
};
|
||||||
|
|
||||||
lldClang = wrapCCWith rec {
|
lldClang = wrapCCWith rec {
|
||||||
cc = tools.clang-unwrapped;
|
cc = tools.clang-unwrapped;
|
||||||
|
@ -112,6 +122,8 @@ let
|
||||||
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
|
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
|
||||||
'' + lib.optionalString (!stdenv.targetPlatform.isWasm) ''
|
'' + lib.optionalString (!stdenv.targetPlatform.isWasm) ''
|
||||||
echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags
|
echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags
|
||||||
|
'' + lib.optionalString (stdenv.targetPlatform.isAndroid && stdenv.targetPlatform.useLLVM) ''
|
||||||
|
echo "-lunwind" >> $out/nix-support/cc-ldflags
|
||||||
'' + lib.optionalString stdenv.targetPlatform.isWasm ''
|
'' + lib.optionalString stdenv.targetPlatform.isWasm ''
|
||||||
echo "-fno-exceptions" >> $out/nix-support/cc-cflags
|
echo "-fno-exceptions" >> $out/nix-support/cc-cflags
|
||||||
'' + mkExtraBuildCommands cc;
|
'' + mkExtraBuildCommands cc;
|
||||||
|
@ -120,9 +132,7 @@ let
|
||||||
lldClangNoLibcxx = wrapCCWith rec {
|
lldClangNoLibcxx = wrapCCWith rec {
|
||||||
cc = tools.clang-unwrapped;
|
cc = tools.clang-unwrapped;
|
||||||
libcxx = null;
|
libcxx = null;
|
||||||
bintools = wrapBintoolsWith {
|
inherit (tools) bintools;
|
||||||
inherit (tools) bintools;
|
|
||||||
};
|
|
||||||
extraPackages = [
|
extraPackages = [
|
||||||
targetLlvmLibraries.compiler-rt
|
targetLlvmLibraries.compiler-rt
|
||||||
];
|
];
|
||||||
|
@ -136,10 +146,7 @@ let
|
||||||
lldClangNoLibc = wrapCCWith rec {
|
lldClangNoLibc = wrapCCWith rec {
|
||||||
cc = tools.clang-unwrapped;
|
cc = tools.clang-unwrapped;
|
||||||
libcxx = null;
|
libcxx = null;
|
||||||
bintools = wrapBintoolsWith {
|
bintools = tools.bintoolsNoLibc;
|
||||||
inherit (tools) bintools;
|
|
||||||
libc = null;
|
|
||||||
};
|
|
||||||
extraPackages = [
|
extraPackages = [
|
||||||
targetLlvmLibraries.compiler-rt
|
targetLlvmLibraries.compiler-rt
|
||||||
];
|
];
|
||||||
|
@ -152,26 +159,43 @@ let
|
||||||
lldClangNoCompilerRt = wrapCCWith rec {
|
lldClangNoCompilerRt = wrapCCWith rec {
|
||||||
cc = tools.clang-unwrapped;
|
cc = tools.clang-unwrapped;
|
||||||
libcxx = null;
|
libcxx = null;
|
||||||
bintools = wrapBintoolsWith {
|
bintools = tools.bintoolsNoLibc;
|
||||||
inherit (tools) bintools;
|
|
||||||
libc = null;
|
|
||||||
};
|
|
||||||
extraPackages = [ ];
|
extraPackages = [ ];
|
||||||
extraBuildCommands = ''
|
extraBuildCommands = ''
|
||||||
echo "-nostartfiles" >> $out/nix-support/cc-cflags
|
echo "-nostartfiles" >> $out/nix-support/cc-cflags
|
||||||
'' + mkExtraBuildCommands0 cc;
|
'' + mkExtraBuildCommands0 cc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
lldClangNoCompilerRtWithLibc = wrapCCWith rec {
|
||||||
|
cc = tools.clang-unwrapped;
|
||||||
|
libcxx = null;
|
||||||
|
inherit (tools) bintools;
|
||||||
|
extraPackages = [ ];
|
||||||
|
extraBuildCommands = mkExtraBuildCommands0 cc;
|
||||||
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
libraries = lib.makeExtensible (libraries: let
|
libraries = lib.makeExtensible (libraries: let
|
||||||
callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
|
callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
|
||||||
in {
|
in {
|
||||||
|
|
||||||
compiler-rt = callPackage ./compiler-rt ({} //
|
compiler-rt-libc = callPackage ./compiler-rt {
|
||||||
(lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
|
stdenv = if stdenv.hostPlatform.useLLVM or false
|
||||||
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt;
|
then overrideCC stdenv buildLlvmTools.lldClangNoCompilerRtWithLibc
|
||||||
}));
|
else stdenv;
|
||||||
|
};
|
||||||
|
|
||||||
|
compiler-rt-no-libc = callPackage ./compiler-rt {
|
||||||
|
stdenv = if stdenv.hostPlatform.useLLVM or false
|
||||||
|
then overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt
|
||||||
|
else stdenv;
|
||||||
|
};
|
||||||
|
|
||||||
|
# N.B. condition is safe because without useLLVM both are the same.
|
||||||
|
compiler-rt = if stdenv.hostPlatform.isAndroid
|
||||||
|
then libraries.compiler-rt-libc
|
||||||
|
else libraries.compiler-rt-no-libc;
|
||||||
|
|
||||||
stdenv = overrideCC stdenv buildLlvmTools.clang;
|
stdenv = overrideCC stdenv buildLlvmTools.clang;
|
||||||
|
|
||||||
|
|
|
@ -4,14 +4,15 @@ let
|
||||||
|
|
||||||
useLLVM = stdenv.hostPlatform.useLLVM or false;
|
useLLVM = stdenv.hostPlatform.useLLVM or false;
|
||||||
bareMetal = stdenv.hostPlatform.parsed.kernel.name == "none";
|
bareMetal = stdenv.hostPlatform.parsed.kernel.name == "none";
|
||||||
|
haveLibc = stdenv.cc.libc != null;
|
||||||
inherit (stdenv.hostPlatform) isMusl;
|
inherit (stdenv.hostPlatform) isMusl;
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation {
|
||||||
pname = "compiler-rt";
|
pname = "compiler-rt" + lib.optionalString (haveLibc) "-libc";
|
||||||
inherit version;
|
inherit version;
|
||||||
src = fetch pname "0x1j8ngf1zj63wlnns9vlibafq48qcm72p4jpaxkmkb4qw0grwfy";
|
src = fetch "compiler-rt" "0x1j8ngf1zj63wlnns9vlibafq48qcm72p4jpaxkmkb4qw0grwfy";
|
||||||
|
|
||||||
nativeBuildInputs = [ cmake python3 llvm.dev ];
|
nativeBuildInputs = [ cmake python3 llvm.dev ];
|
||||||
buildInputs = lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
|
buildInputs = lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
|
||||||
|
@ -29,14 +30,15 @@ stdenv.mkDerivation rec {
|
||||||
"-DCOMPILER_RT_BUILD_XRAY=OFF"
|
"-DCOMPILER_RT_BUILD_XRAY=OFF"
|
||||||
"-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
|
"-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
|
||||||
"-DCOMPILER_RT_BUILD_PROFILE=OFF"
|
"-DCOMPILER_RT_BUILD_PROFILE=OFF"
|
||||||
] ++ lib.optionals (useLLVM || bareMetal) [
|
] ++ lib.optionals ((useLLVM || bareMetal) && !haveLibc) [
|
||||||
"-DCMAKE_C_COMPILER_WORKS=ON"
|
"-DCMAKE_C_COMPILER_WORKS=ON"
|
||||||
"-DCMAKE_CXX_COMPILER_WORKS=ON"
|
"-DCMAKE_CXX_COMPILER_WORKS=ON"
|
||||||
"-DCOMPILER_RT_BAREMETAL_BUILD=ON"
|
"-DCOMPILER_RT_BAREMETAL_BUILD=ON"
|
||||||
"-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}"
|
"-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}"
|
||||||
|
] ++ lib.optionals (useLLVM && !haveLibc) [
|
||||||
|
"-DCMAKE_C_FLAGS=-nodefaultlibs"
|
||||||
] ++ lib.optionals (useLLVM) [
|
] ++ lib.optionals (useLLVM) [
|
||||||
"-DCOMPILER_RT_BUILD_BUILTINS=ON"
|
"-DCOMPILER_RT_BUILD_BUILTINS=ON"
|
||||||
"-DCMAKE_C_FLAGS=-nodefaultlibs"
|
|
||||||
#https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program
|
#https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program
|
||||||
"-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
|
"-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
|
||||||
] ++ lib.optionals (bareMetal) [
|
] ++ lib.optionals (bareMetal) [
|
||||||
|
@ -59,7 +61,6 @@ stdenv.mkDerivation rec {
|
||||||
]# ++ lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch
|
]# ++ lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch
|
||||||
++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch;
|
++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch;
|
||||||
|
|
||||||
|
|
||||||
# TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
|
# TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
|
||||||
# to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra
|
# to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra
|
||||||
# can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd
|
# can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd
|
||||||
|
@ -91,5 +92,4 @@ stdenv.mkDerivation rec {
|
||||||
ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o
|
ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o
|
||||||
ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/crtendS.o
|
ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/crtendS.o
|
||||||
'';
|
'';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{ lowPrio, newScope, pkgs, lib, stdenv, cmake, gccForLibs
|
{ lowPrio, newScope, pkgs, lib, stdenv, cmake
|
||||||
|
, gccForLibs, preLibcCrossHeaders
|
||||||
, libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
|
, libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
|
||||||
, buildLlvmTools # tools, but from the previous stage, for cross
|
, buildLlvmTools # tools, but from the previous stage, for cross
|
||||||
, targetLlvmLibraries # libraries, but from the next stage, for cross
|
, targetLlvmLibraries # libraries, but from the next stage, for cross
|
||||||
|
@ -94,7 +95,16 @@ let
|
||||||
# doesn’t support like LLVM. Probably we should move to some other
|
# doesn’t support like LLVM. Probably we should move to some other
|
||||||
# file.
|
# file.
|
||||||
|
|
||||||
bintools = callPackage ./bintools.nix {};
|
bintools-unwrapped = callPackage ./bintools {};
|
||||||
|
|
||||||
|
bintoolsNoLibc = wrapBintoolsWith {
|
||||||
|
bintools = tools.bintools-unwrapped;
|
||||||
|
libc = preLibcCrossHeaders;
|
||||||
|
};
|
||||||
|
|
||||||
|
bintools = wrapBintoolsWith {
|
||||||
|
bintools = tools.bintools-unwrapped;
|
||||||
|
};
|
||||||
|
|
||||||
lldClang = wrapCCWith rec {
|
lldClang = wrapCCWith rec {
|
||||||
cc = tools.clang-unwrapped;
|
cc = tools.clang-unwrapped;
|
||||||
|
@ -113,6 +123,8 @@ let
|
||||||
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
|
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
|
||||||
'' + lib.optionalString (!stdenv.targetPlatform.isWasm) ''
|
'' + lib.optionalString (!stdenv.targetPlatform.isWasm) ''
|
||||||
echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags
|
echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags
|
||||||
|
'' + lib.optionalString (stdenv.targetPlatform.isAndroid && stdenv.targetPlatform.useLLVM) ''
|
||||||
|
echo "-lunwind" >> $out/nix-support/cc-ldflags
|
||||||
'' + lib.optionalString stdenv.targetPlatform.isWasm ''
|
'' + lib.optionalString stdenv.targetPlatform.isWasm ''
|
||||||
echo "-fno-exceptions" >> $out/nix-support/cc-cflags
|
echo "-fno-exceptions" >> $out/nix-support/cc-cflags
|
||||||
'' + mkExtraBuildCommands cc;
|
'' + mkExtraBuildCommands cc;
|
||||||
|
@ -121,9 +133,7 @@ let
|
||||||
lldClangNoLibcxx = wrapCCWith rec {
|
lldClangNoLibcxx = wrapCCWith rec {
|
||||||
cc = tools.clang-unwrapped;
|
cc = tools.clang-unwrapped;
|
||||||
libcxx = null;
|
libcxx = null;
|
||||||
bintools = wrapBintoolsWith {
|
inherit (tools) bintools;
|
||||||
inherit (tools) bintools;
|
|
||||||
};
|
|
||||||
extraPackages = [
|
extraPackages = [
|
||||||
targetLlvmLibraries.compiler-rt
|
targetLlvmLibraries.compiler-rt
|
||||||
];
|
];
|
||||||
|
@ -137,10 +147,7 @@ let
|
||||||
lldClangNoLibc = wrapCCWith rec {
|
lldClangNoLibc = wrapCCWith rec {
|
||||||
cc = tools.clang-unwrapped;
|
cc = tools.clang-unwrapped;
|
||||||
libcxx = null;
|
libcxx = null;
|
||||||
bintools = wrapBintoolsWith {
|
bintools = tools.bintoolsNoLibc;
|
||||||
inherit (tools) bintools;
|
|
||||||
libc = null;
|
|
||||||
};
|
|
||||||
extraPackages = [
|
extraPackages = [
|
||||||
targetLlvmLibraries.compiler-rt
|
targetLlvmLibraries.compiler-rt
|
||||||
];
|
];
|
||||||
|
@ -153,26 +160,43 @@ let
|
||||||
lldClangNoCompilerRt = wrapCCWith rec {
|
lldClangNoCompilerRt = wrapCCWith rec {
|
||||||
cc = tools.clang-unwrapped;
|
cc = tools.clang-unwrapped;
|
||||||
libcxx = null;
|
libcxx = null;
|
||||||
bintools = wrapBintoolsWith {
|
bintools = tools.bintoolsNoLibc;
|
||||||
inherit (tools) bintools;
|
|
||||||
libc = null;
|
|
||||||
};
|
|
||||||
extraPackages = [ ];
|
extraPackages = [ ];
|
||||||
extraBuildCommands = ''
|
extraBuildCommands = ''
|
||||||
echo "-nostartfiles" >> $out/nix-support/cc-cflags
|
echo "-nostartfiles" >> $out/nix-support/cc-cflags
|
||||||
'' + mkExtraBuildCommands0 cc;
|
'' + mkExtraBuildCommands0 cc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
lldClangNoCompilerRtWithLibc = wrapCCWith rec {
|
||||||
|
cc = tools.clang-unwrapped;
|
||||||
|
libcxx = null;
|
||||||
|
inherit (tools) bintools;
|
||||||
|
extraPackages = [ ];
|
||||||
|
extraBuildCommands = mkExtraBuildCommands0 cc;
|
||||||
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
libraries = lib.makeExtensible (libraries: let
|
libraries = lib.makeExtensible (libraries: let
|
||||||
callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
|
callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
|
||||||
in {
|
in {
|
||||||
|
|
||||||
compiler-rt = callPackage ./compiler-rt ({} //
|
compiler-rt-libc = callPackage ./compiler-rt {
|
||||||
(lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
|
stdenv = if stdenv.hostPlatform.useLLVM or false
|
||||||
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt;
|
then overrideCC stdenv buildLlvmTools.lldClangNoCompilerRtWithLibc
|
||||||
}));
|
else stdenv;
|
||||||
|
};
|
||||||
|
|
||||||
|
compiler-rt-no-libc = callPackage ./compiler-rt {
|
||||||
|
stdenv = if stdenv.hostPlatform.useLLVM or false
|
||||||
|
then overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt
|
||||||
|
else stdenv;
|
||||||
|
};
|
||||||
|
|
||||||
|
# N.B. condition is safe because without useLLVM both are the same.
|
||||||
|
compiler-rt = if stdenv.hostPlatform.isAndroid
|
||||||
|
then libraries.compiler-rt-libc
|
||||||
|
else libraries.compiler-rt-no-libc;
|
||||||
|
|
||||||
stdenv = overrideCC stdenv buildLlvmTools.clang;
|
stdenv = overrideCC stdenv buildLlvmTools.clang;
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ let
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation {
|
||||||
pname = "compiler-rt" + lib.optionalString (haveLibc) "-libc";
|
pname = "compiler-rt" + lib.optionalString (haveLibc) "-libc";
|
||||||
inherit version;
|
inherit version;
|
||||||
src = fetch "compiler-rt" "0d444qihq9jhqnfv003cr704v363va72zl6qaw2algj1c85cva45";
|
src = fetch "compiler-rt" "0d444qihq9jhqnfv003cr704v363va72zl6qaw2algj1c85cva45";
|
||||||
|
@ -61,7 +61,6 @@ stdenv.mkDerivation rec {
|
||||||
]# ++ lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch
|
]# ++ lib.optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch
|
||||||
++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch;
|
++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch;
|
||||||
|
|
||||||
|
|
||||||
# TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
|
# TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
|
||||||
# to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra
|
# to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra
|
||||||
# can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd
|
# can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{ lowPrio, newScope, pkgs, lib, stdenv, cmake, gccForLibs
|
{ lowPrio, newScope, pkgs, lib, stdenv, cmake
|
||||||
|
, gccForLibs, preLibcCrossHeaders
|
||||||
, libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
|
, libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
|
||||||
, buildLlvmTools # tools, but from the previous stage, for cross
|
, buildLlvmTools # tools, but from the previous stage, for cross
|
||||||
, targetLlvmLibraries # libraries, but from the next stage, for cross
|
, targetLlvmLibraries # libraries, but from the next stage, for cross
|
||||||
|
@ -112,7 +113,16 @@ let
|
||||||
# doesn’t support like LLVM. Probably we should move to some other
|
# doesn’t support like LLVM. Probably we should move to some other
|
||||||
# file.
|
# file.
|
||||||
|
|
||||||
bintools = callPackage ./bintools {};
|
bintools-unwrapped = callPackage ./bintools {};
|
||||||
|
|
||||||
|
bintoolsNoLibc = wrapBintoolsWith {
|
||||||
|
bintools = tools.bintools-unwrapped;
|
||||||
|
libc = preLibcCrossHeaders;
|
||||||
|
};
|
||||||
|
|
||||||
|
bintools = wrapBintoolsWith {
|
||||||
|
bintools = tools.bintools-unwrapped;
|
||||||
|
};
|
||||||
|
|
||||||
lldClang = wrapCCWith rec {
|
lldClang = wrapCCWith rec {
|
||||||
cc = tools.clang-unwrapped;
|
cc = tools.clang-unwrapped;
|
||||||
|
@ -141,9 +151,7 @@ let
|
||||||
lldClangNoLibcxx = wrapCCWith rec {
|
lldClangNoLibcxx = wrapCCWith rec {
|
||||||
cc = tools.clang-unwrapped;
|
cc = tools.clang-unwrapped;
|
||||||
libcxx = null;
|
libcxx = null;
|
||||||
bintools = wrapBintoolsWith {
|
inherit (tools) bintools;
|
||||||
inherit (tools) bintools;
|
|
||||||
};
|
|
||||||
extraPackages = [
|
extraPackages = [
|
||||||
targetLlvmLibraries.compiler-rt
|
targetLlvmLibraries.compiler-rt
|
||||||
];
|
];
|
||||||
|
@ -157,10 +165,7 @@ let
|
||||||
lldClangNoLibc = wrapCCWith rec {
|
lldClangNoLibc = wrapCCWith rec {
|
||||||
cc = tools.clang-unwrapped;
|
cc = tools.clang-unwrapped;
|
||||||
libcxx = null;
|
libcxx = null;
|
||||||
bintools = wrapBintoolsWith {
|
bintools = tools.bintoolsNoLibc;
|
||||||
inherit (tools) bintools;
|
|
||||||
libc = null;
|
|
||||||
};
|
|
||||||
extraPackages = [
|
extraPackages = [
|
||||||
targetLlvmLibraries.compiler-rt
|
targetLlvmLibraries.compiler-rt
|
||||||
];
|
];
|
||||||
|
@ -173,10 +178,7 @@ let
|
||||||
lldClangNoCompilerRt = wrapCCWith rec {
|
lldClangNoCompilerRt = wrapCCWith rec {
|
||||||
cc = tools.clang-unwrapped;
|
cc = tools.clang-unwrapped;
|
||||||
libcxx = null;
|
libcxx = null;
|
||||||
bintools = wrapBintoolsWith {
|
bintools = tools.bintoolsNoLibc;
|
||||||
inherit (tools) bintools;
|
|
||||||
libc = null;
|
|
||||||
};
|
|
||||||
extraPackages = [ ];
|
extraPackages = [ ];
|
||||||
extraBuildCommands = ''
|
extraBuildCommands = ''
|
||||||
echo "-nostartfiles" >> $out/nix-support/cc-cflags
|
echo "-nostartfiles" >> $out/nix-support/cc-cflags
|
||||||
|
@ -186,9 +188,7 @@ let
|
||||||
lldClangNoCompilerRtWithLibc = wrapCCWith rec {
|
lldClangNoCompilerRtWithLibc = wrapCCWith rec {
|
||||||
cc = tools.clang-unwrapped;
|
cc = tools.clang-unwrapped;
|
||||||
libcxx = null;
|
libcxx = null;
|
||||||
bintools = wrapBintoolsWith {
|
inherit (tools) bintools;
|
||||||
inherit (tools) bintools;
|
|
||||||
};
|
|
||||||
extraPackages = [ ];
|
extraPackages = [ ];
|
||||||
extraBuildCommands = mkExtraBuildCommands0 cc;
|
extraBuildCommands = mkExtraBuildCommands0 cc;
|
||||||
};
|
};
|
||||||
|
@ -199,15 +199,19 @@ let
|
||||||
callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
|
callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
|
||||||
in {
|
in {
|
||||||
|
|
||||||
compiler-rt-libc = callPackage ./compiler-rt ({ inherit llvm_meta; } //
|
compiler-rt-libc = callPackage ./compiler-rt {
|
||||||
(lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
|
inherit llvm_meta;
|
||||||
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoCompilerRtWithLibc;
|
stdenv = if stdenv.hostPlatform.useLLVM or false
|
||||||
}));
|
then overrideCC stdenv buildLlvmTools.lldClangNoCompilerRtWithLibc
|
||||||
|
else stdenv;
|
||||||
|
};
|
||||||
|
|
||||||
compiler-rt-no-libc = callPackage ./compiler-rt ({ inherit llvm_meta; } //
|
compiler-rt-no-libc = callPackage ./compiler-rt {
|
||||||
(lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
|
inherit llvm_meta;
|
||||||
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt;
|
stdenv = if stdenv.hostPlatform.useLLVM or false
|
||||||
}));
|
then overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt
|
||||||
|
else stdenv;
|
||||||
|
};
|
||||||
|
|
||||||
# N.B. condition is safe because without useLLVM both are the same.
|
# N.B. condition is safe because without useLLVM both are the same.
|
||||||
compiler-rt = if stdenv.hostPlatform.isAndroid
|
compiler-rt = if stdenv.hostPlatform.isAndroid
|
||||||
|
|
|
@ -4,12 +4,13 @@ let
|
||||||
|
|
||||||
useLLVM = stdenv.hostPlatform.useLLVM or false;
|
useLLVM = stdenv.hostPlatform.useLLVM or false;
|
||||||
bareMetal = stdenv.hostPlatform.parsed.kernel.name == "none";
|
bareMetal = stdenv.hostPlatform.parsed.kernel.name == "none";
|
||||||
|
haveLibc = stdenv.cc.libc != null;
|
||||||
inherit (stdenv.hostPlatform) isMusl;
|
inherit (stdenv.hostPlatform) isMusl;
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
pname = "compiler-rt";
|
pname = "compiler-rt" + lib.optionalString (haveLibc) "-libc";
|
||||||
inherit version;
|
inherit version;
|
||||||
src = fetch "compiler-rt" "1n48p8gjarihkws0i2bay5w9bdwyxyxxbpwyng7ba58jb30dlyq5";
|
src = fetch "compiler-rt" "1n48p8gjarihkws0i2bay5w9bdwyxyxxbpwyng7ba58jb30dlyq5";
|
||||||
|
|
||||||
|
@ -29,14 +30,15 @@ stdenv.mkDerivation {
|
||||||
"-DCOMPILER_RT_BUILD_XRAY=OFF"
|
"-DCOMPILER_RT_BUILD_XRAY=OFF"
|
||||||
"-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
|
"-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
|
||||||
"-DCOMPILER_RT_BUILD_PROFILE=OFF"
|
"-DCOMPILER_RT_BUILD_PROFILE=OFF"
|
||||||
] ++ lib.optionals (useLLVM || bareMetal) [
|
] ++ lib.optionals ((useLLVM || bareMetal) && !haveLibc) [
|
||||||
"-DCMAKE_C_COMPILER_WORKS=ON"
|
"-DCMAKE_C_COMPILER_WORKS=ON"
|
||||||
"-DCMAKE_CXX_COMPILER_WORKS=ON"
|
"-DCMAKE_CXX_COMPILER_WORKS=ON"
|
||||||
"-DCOMPILER_RT_BAREMETAL_BUILD=ON"
|
"-DCOMPILER_RT_BAREMETAL_BUILD=ON"
|
||||||
"-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}"
|
"-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}"
|
||||||
|
] ++ lib.optionals (useLLVM && !haveLibc) [
|
||||||
|
"-DCMAKE_C_FLAGS=-nodefaultlibs"
|
||||||
] ++ lib.optionals (useLLVM) [
|
] ++ lib.optionals (useLLVM) [
|
||||||
"-DCOMPILER_RT_BUILD_BUILTINS=ON"
|
"-DCOMPILER_RT_BUILD_BUILTINS=ON"
|
||||||
"-DCMAKE_C_FLAGS=-nodefaultlibs"
|
|
||||||
#https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program
|
#https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program
|
||||||
"-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
|
"-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
|
||||||
] ++ lib.optionals (bareMetal) [
|
] ++ lib.optionals (bareMetal) [
|
||||||
|
@ -83,10 +85,9 @@ stdenv.mkDerivation {
|
||||||
postInstall = lib.optionalString (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isWasm) ''
|
postInstall = lib.optionalString (stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isWasm) ''
|
||||||
ln -s "$out/lib"/*/* "$out/lib"
|
ln -s "$out/lib"/*/* "$out/lib"
|
||||||
'' + lib.optionalString (useLLVM) ''
|
'' + lib.optionalString (useLLVM) ''
|
||||||
ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/linux/crtbegin.o
|
ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/crtbegin.o
|
||||||
ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/linux/crtend.o
|
ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/crtend.o
|
||||||
ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/linux/crtbeginS.o
|
ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o
|
||||||
ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/linux/crtendS.o
|
ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/crtendS.o
|
||||||
'';
|
'';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{ lowPrio, newScope, pkgs, lib, stdenv, cmake, gccForLibs
|
{ lowPrio, newScope, pkgs, lib, stdenv, cmake
|
||||||
|
, gccForLibs, preLibcCrossHeaders
|
||||||
, libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
|
, libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
|
||||||
, buildLlvmTools # tools, but from the previous stage, for cross
|
, buildLlvmTools # tools, but from the previous stage, for cross
|
||||||
, targetLlvmLibraries # libraries, but from the next stage, for cross
|
, targetLlvmLibraries # libraries, but from the next stage, for cross
|
||||||
|
@ -95,7 +96,16 @@ let
|
||||||
# doesn’t support like LLVM. Probably we should move to some other
|
# doesn’t support like LLVM. Probably we should move to some other
|
||||||
# file.
|
# file.
|
||||||
|
|
||||||
bintools = callPackage ./bintools.nix {};
|
bintools-unwrapped = callPackage ./bintools {};
|
||||||
|
|
||||||
|
bintoolsNoLibc = wrapBintoolsWith {
|
||||||
|
bintools = tools.bintools-unwrapped;
|
||||||
|
libc = preLibcCrossHeaders;
|
||||||
|
};
|
||||||
|
|
||||||
|
bintools = wrapBintoolsWith {
|
||||||
|
bintools = tools.bintools-unwrapped;
|
||||||
|
};
|
||||||
|
|
||||||
lldClang = wrapCCWith rec {
|
lldClang = wrapCCWith rec {
|
||||||
cc = tools.clang-unwrapped;
|
cc = tools.clang-unwrapped;
|
||||||
|
@ -114,6 +124,8 @@ let
|
||||||
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
|
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
|
||||||
'' + lib.optionalString (!stdenv.targetPlatform.isWasm) ''
|
'' + lib.optionalString (!stdenv.targetPlatform.isWasm) ''
|
||||||
echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags
|
echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags
|
||||||
|
'' + lib.optionalString (stdenv.targetPlatform.isAndroid && stdenv.targetPlatform.useLLVM) ''
|
||||||
|
echo "-lunwind" >> $out/nix-support/cc-ldflags
|
||||||
'' + lib.optionalString stdenv.targetPlatform.isWasm ''
|
'' + lib.optionalString stdenv.targetPlatform.isWasm ''
|
||||||
echo "-fno-exceptions" >> $out/nix-support/cc-cflags
|
echo "-fno-exceptions" >> $out/nix-support/cc-cflags
|
||||||
'' + mkExtraBuildCommands cc;
|
'' + mkExtraBuildCommands cc;
|
||||||
|
@ -122,9 +134,7 @@ let
|
||||||
lldClangNoLibcxx = wrapCCWith rec {
|
lldClangNoLibcxx = wrapCCWith rec {
|
||||||
cc = tools.clang-unwrapped;
|
cc = tools.clang-unwrapped;
|
||||||
libcxx = null;
|
libcxx = null;
|
||||||
bintools = wrapBintoolsWith {
|
inherit (tools) bintools;
|
||||||
inherit (tools) bintools;
|
|
||||||
};
|
|
||||||
extraPackages = [
|
extraPackages = [
|
||||||
targetLlvmLibraries.compiler-rt
|
targetLlvmLibraries.compiler-rt
|
||||||
];
|
];
|
||||||
|
@ -138,10 +148,7 @@ let
|
||||||
lldClangNoLibc = wrapCCWith rec {
|
lldClangNoLibc = wrapCCWith rec {
|
||||||
cc = tools.clang-unwrapped;
|
cc = tools.clang-unwrapped;
|
||||||
libcxx = null;
|
libcxx = null;
|
||||||
bintools = wrapBintoolsWith {
|
bintools = tools.bintoolsNoLibc;
|
||||||
inherit (tools) bintools;
|
|
||||||
libc = null;
|
|
||||||
};
|
|
||||||
extraPackages = [
|
extraPackages = [
|
||||||
targetLlvmLibraries.compiler-rt
|
targetLlvmLibraries.compiler-rt
|
||||||
];
|
];
|
||||||
|
@ -154,28 +161,44 @@ let
|
||||||
lldClangNoCompilerRt = wrapCCWith rec {
|
lldClangNoCompilerRt = wrapCCWith rec {
|
||||||
cc = tools.clang-unwrapped;
|
cc = tools.clang-unwrapped;
|
||||||
libcxx = null;
|
libcxx = null;
|
||||||
bintools = wrapBintoolsWith {
|
bintools = tools.bintoolsNoLibc;
|
||||||
inherit (tools) bintools;
|
|
||||||
libc = null;
|
|
||||||
};
|
|
||||||
extraPackages = [ ];
|
extraPackages = [ ];
|
||||||
extraBuildCommands = ''
|
extraBuildCommands = ''
|
||||||
echo "-nostartfiles" >> $out/nix-support/cc-cflags
|
echo "-nostartfiles" >> $out/nix-support/cc-cflags
|
||||||
'' + mkExtraBuildCommands0 cc;
|
'' + mkExtraBuildCommands0 cc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
lldClangNoCompilerRtWithLibc = wrapCCWith rec {
|
||||||
|
cc = tools.clang-unwrapped;
|
||||||
|
libcxx = null;
|
||||||
|
inherit (tools) bintools;
|
||||||
|
extraPackages = [ ];
|
||||||
|
extraBuildCommands = mkExtraBuildCommands0 cc;
|
||||||
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
libraries = lib.makeExtensible (libraries: let
|
libraries = lib.makeExtensible (libraries: let
|
||||||
callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
|
callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
|
||||||
in {
|
in {
|
||||||
|
|
||||||
compiler-rt = callPackage ./compiler-rt {
|
compiler-rt-libc = callPackage ./compiler-rt {
|
||||||
|
stdenv = if stdenv.hostPlatform.useLLVM or false
|
||||||
|
then overrideCC stdenv buildLlvmTools.lldClangNoCompilerRtWithLibc
|
||||||
|
else stdenv;
|
||||||
|
};
|
||||||
|
|
||||||
|
compiler-rt-no-libc = callPackage ./compiler-rt {
|
||||||
stdenv = if stdenv.hostPlatform.useLLVM or false
|
stdenv = if stdenv.hostPlatform.useLLVM or false
|
||||||
then overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt
|
then overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt
|
||||||
else stdenv;
|
else stdenv;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# N.B. condition is safe because without useLLVM both are the same.
|
||||||
|
compiler-rt = if stdenv.hostPlatform.isAndroid
|
||||||
|
then libraries.compiler-rt-libc
|
||||||
|
else libraries.compiler-rt-no-libc;
|
||||||
|
|
||||||
stdenv = overrideCC stdenv buildLlvmTools.clang;
|
stdenv = overrideCC stdenv buildLlvmTools.clang;
|
||||||
|
|
||||||
libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
|
libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;
|
||||||
|
|
|
@ -4,12 +4,13 @@ let
|
||||||
|
|
||||||
useLLVM = stdenv.hostPlatform.useLLVM or false;
|
useLLVM = stdenv.hostPlatform.useLLVM or false;
|
||||||
bareMetal = stdenv.hostPlatform.parsed.kernel.name == "none";
|
bareMetal = stdenv.hostPlatform.parsed.kernel.name == "none";
|
||||||
|
haveLibc = stdenv.cc.libc != null;
|
||||||
inherit (stdenv.hostPlatform) isMusl;
|
inherit (stdenv.hostPlatform) isMusl;
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
pname = "compiler-rt";
|
pname = "compiler-rt" + lib.optionalString (haveLibc) "-libc";
|
||||||
inherit version;
|
inherit version;
|
||||||
src = fetch "compiler-rt" "0dqqf8f930l8gag4d9qjgn1n0pj0nbv2anviqqhdi1rkhas8z0hi";
|
src = fetch "compiler-rt" "0dqqf8f930l8gag4d9qjgn1n0pj0nbv2anviqqhdi1rkhas8z0hi";
|
||||||
|
|
||||||
|
@ -29,14 +30,15 @@ stdenv.mkDerivation {
|
||||||
"-DCOMPILER_RT_BUILD_XRAY=OFF"
|
"-DCOMPILER_RT_BUILD_XRAY=OFF"
|
||||||
"-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
|
"-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
|
||||||
"-DCOMPILER_RT_BUILD_PROFILE=OFF"
|
"-DCOMPILER_RT_BUILD_PROFILE=OFF"
|
||||||
] ++ lib.optionals (useLLVM || bareMetal) [
|
] ++ lib.optionals ((useLLVM || bareMetal) && !haveLibc) [
|
||||||
"-DCMAKE_C_COMPILER_WORKS=ON"
|
"-DCMAKE_C_COMPILER_WORKS=ON"
|
||||||
"-DCMAKE_CXX_COMPILER_WORKS=ON"
|
"-DCMAKE_CXX_COMPILER_WORKS=ON"
|
||||||
"-DCOMPILER_RT_BAREMETAL_BUILD=ON"
|
"-DCOMPILER_RT_BAREMETAL_BUILD=ON"
|
||||||
"-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}"
|
"-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}"
|
||||||
|
] ++ lib.optionals (useLLVM && !haveLibc) [
|
||||||
|
"-DCMAKE_C_FLAGS=-nodefaultlibs"
|
||||||
] ++ lib.optionals (useLLVM) [
|
] ++ lib.optionals (useLLVM) [
|
||||||
"-DCOMPILER_RT_BUILD_BUILTINS=ON"
|
"-DCOMPILER_RT_BUILD_BUILTINS=ON"
|
||||||
"-DCMAKE_C_FLAGS=-nodefaultlibs"
|
|
||||||
#https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program
|
#https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program
|
||||||
"-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
|
"-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
|
||||||
] ++ lib.optionals (bareMetal) [
|
] ++ lib.optionals (bareMetal) [
|
||||||
|
@ -88,5 +90,4 @@ stdenv.mkDerivation {
|
||||||
ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o
|
ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o
|
||||||
ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/crtendS.o
|
ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/crtendS.o
|
||||||
'';
|
'';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{ lowPrio, newScope, pkgs, lib, stdenv, cmake, gccForLibs
|
{ lowPrio, newScope, pkgs, lib, stdenv, cmake
|
||||||
|
, gccForLibs, preLibcCrossHeaders
|
||||||
, libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
|
, libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
|
||||||
, buildLlvmTools # tools, but from the previous stage, for cross
|
, buildLlvmTools # tools, but from the previous stage, for cross
|
||||||
, targetLlvmLibraries # libraries, but from the next stage, for cross
|
, targetLlvmLibraries # libraries, but from the next stage, for cross
|
||||||
|
@ -96,7 +97,16 @@ let
|
||||||
# doesn’t support like LLVM. Probably we should move to some other
|
# doesn’t support like LLVM. Probably we should move to some other
|
||||||
# file.
|
# file.
|
||||||
|
|
||||||
bintools = callPackage ./bintools.nix {};
|
bintools-unwrapped = callPackage ./bintools {};
|
||||||
|
|
||||||
|
bintoolsNoLibc = wrapBintoolsWith {
|
||||||
|
bintools = tools.bintools-unwrapped;
|
||||||
|
libc = preLibcCrossHeaders;
|
||||||
|
};
|
||||||
|
|
||||||
|
bintools = wrapBintoolsWith {
|
||||||
|
bintools = tools.bintools-unwrapped;
|
||||||
|
};
|
||||||
|
|
||||||
lldClang = wrapCCWith rec {
|
lldClang = wrapCCWith rec {
|
||||||
cc = tools.clang-unwrapped;
|
cc = tools.clang-unwrapped;
|
||||||
|
@ -115,6 +125,8 @@ let
|
||||||
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
|
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
|
||||||
'' + lib.optionalString (!stdenv.targetPlatform.isWasm) ''
|
'' + lib.optionalString (!stdenv.targetPlatform.isWasm) ''
|
||||||
echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags
|
echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags
|
||||||
|
'' + lib.optionalString (stdenv.targetPlatform.isAndroid && stdenv.targetPlatform.useLLVM) ''
|
||||||
|
echo "-lunwind" >> $out/nix-support/cc-ldflags
|
||||||
'' + lib.optionalString stdenv.targetPlatform.isWasm ''
|
'' + lib.optionalString stdenv.targetPlatform.isWasm ''
|
||||||
echo "-fno-exceptions" >> $out/nix-support/cc-cflags
|
echo "-fno-exceptions" >> $out/nix-support/cc-cflags
|
||||||
'' + mkExtraBuildCommands cc;
|
'' + mkExtraBuildCommands cc;
|
||||||
|
@ -123,9 +135,7 @@ let
|
||||||
lldClangNoLibcxx = wrapCCWith rec {
|
lldClangNoLibcxx = wrapCCWith rec {
|
||||||
cc = tools.clang-unwrapped;
|
cc = tools.clang-unwrapped;
|
||||||
libcxx = null;
|
libcxx = null;
|
||||||
bintools = wrapBintoolsWith {
|
inherit (tools) bintools;
|
||||||
inherit (tools) bintools;
|
|
||||||
};
|
|
||||||
extraPackages = [
|
extraPackages = [
|
||||||
targetLlvmLibraries.compiler-rt
|
targetLlvmLibraries.compiler-rt
|
||||||
];
|
];
|
||||||
|
@ -139,10 +149,7 @@ let
|
||||||
lldClangNoLibc = wrapCCWith rec {
|
lldClangNoLibc = wrapCCWith rec {
|
||||||
cc = tools.clang-unwrapped;
|
cc = tools.clang-unwrapped;
|
||||||
libcxx = null;
|
libcxx = null;
|
||||||
bintools = wrapBintoolsWith {
|
bintools = tools.bintoolsNoLibc;
|
||||||
inherit (tools) bintools;
|
|
||||||
libc = null;
|
|
||||||
};
|
|
||||||
extraPackages = [
|
extraPackages = [
|
||||||
targetLlvmLibraries.compiler-rt
|
targetLlvmLibraries.compiler-rt
|
||||||
];
|
];
|
||||||
|
@ -155,26 +162,43 @@ let
|
||||||
lldClangNoCompilerRt = wrapCCWith rec {
|
lldClangNoCompilerRt = wrapCCWith rec {
|
||||||
cc = tools.clang-unwrapped;
|
cc = tools.clang-unwrapped;
|
||||||
libcxx = null;
|
libcxx = null;
|
||||||
bintools = wrapBintoolsWith {
|
bintools = tools.bintoolsNoLibc;
|
||||||
inherit (tools) bintools;
|
|
||||||
libc = null;
|
|
||||||
};
|
|
||||||
extraPackages = [ ];
|
extraPackages = [ ];
|
||||||
extraBuildCommands = ''
|
extraBuildCommands = ''
|
||||||
echo "-nostartfiles" >> $out/nix-support/cc-cflags
|
echo "-nostartfiles" >> $out/nix-support/cc-cflags
|
||||||
'' + mkExtraBuildCommands0 cc;
|
'' + mkExtraBuildCommands0 cc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
lldClangNoCompilerRtWithLibc = wrapCCWith rec {
|
||||||
|
cc = tools.clang-unwrapped;
|
||||||
|
libcxx = null;
|
||||||
|
inherit (tools) bintools;
|
||||||
|
extraPackages = [ ];
|
||||||
|
extraBuildCommands = mkExtraBuildCommands0 cc;
|
||||||
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
libraries = lib.makeExtensible (libraries: let
|
libraries = lib.makeExtensible (libraries: let
|
||||||
callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
|
callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
|
||||||
in {
|
in {
|
||||||
|
|
||||||
compiler-rt = callPackage ./compiler-rt ({} //
|
compiler-rt-libc = callPackage ./compiler-rt {
|
||||||
(lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
|
stdenv = if stdenv.hostPlatform.useLLVM or false
|
||||||
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt;
|
then overrideCC stdenv buildLlvmTools.lldClangNoCompilerRtWithLibc
|
||||||
}));
|
else stdenv;
|
||||||
|
};
|
||||||
|
|
||||||
|
compiler-rt-no-libc = callPackage ./compiler-rt {
|
||||||
|
stdenv = if stdenv.hostPlatform.useLLVM or false
|
||||||
|
then overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt
|
||||||
|
else stdenv;
|
||||||
|
};
|
||||||
|
|
||||||
|
# N.B. condition is safe because without useLLVM both are the same.
|
||||||
|
compiler-rt = if stdenv.hostPlatform.isAndroid
|
||||||
|
then libraries.compiler-rt-libc
|
||||||
|
else libraries.compiler-rt-no-libc;
|
||||||
|
|
||||||
stdenv = overrideCC stdenv buildLlvmTools.clang;
|
stdenv = overrideCC stdenv buildLlvmTools.clang;
|
||||||
|
|
||||||
|
|
|
@ -4,14 +4,15 @@ let
|
||||||
|
|
||||||
useLLVM = stdenv.hostPlatform.useLLVM or false;
|
useLLVM = stdenv.hostPlatform.useLLVM or false;
|
||||||
bareMetal = stdenv.hostPlatform.parsed.kernel.name == "none";
|
bareMetal = stdenv.hostPlatform.parsed.kernel.name == "none";
|
||||||
|
haveLibc = stdenv.cc.libc != null;
|
||||||
inherit (stdenv.hostPlatform) isMusl;
|
inherit (stdenv.hostPlatform) isMusl;
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation {
|
||||||
pname = "compiler-rt";
|
pname = "compiler-rt" + lib.optionalString (haveLibc) "-libc";
|
||||||
inherit version;
|
inherit version;
|
||||||
src = fetch pname "0xwh79g3zggdabxgnd0bphry75asm1qz7mv3hcqihqwqr6aspgy2";
|
src = fetch "compiler-rt" "0xwh79g3zggdabxgnd0bphry75asm1qz7mv3hcqihqwqr6aspgy2";
|
||||||
|
|
||||||
nativeBuildInputs = [ cmake python3 llvm.dev ];
|
nativeBuildInputs = [ cmake python3 llvm.dev ];
|
||||||
buildInputs = lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
|
buildInputs = lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
|
||||||
|
@ -29,14 +30,15 @@ stdenv.mkDerivation rec {
|
||||||
"-DCOMPILER_RT_BUILD_XRAY=OFF"
|
"-DCOMPILER_RT_BUILD_XRAY=OFF"
|
||||||
"-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
|
"-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
|
||||||
"-DCOMPILER_RT_BUILD_PROFILE=OFF"
|
"-DCOMPILER_RT_BUILD_PROFILE=OFF"
|
||||||
] ++ lib.optionals (useLLVM || bareMetal) [
|
] ++ lib.optionals ((useLLVM || bareMetal) && !haveLibc) [
|
||||||
"-DCMAKE_C_COMPILER_WORKS=ON"
|
"-DCMAKE_C_COMPILER_WORKS=ON"
|
||||||
"-DCMAKE_CXX_COMPILER_WORKS=ON"
|
"-DCMAKE_CXX_COMPILER_WORKS=ON"
|
||||||
"-DCOMPILER_RT_BAREMETAL_BUILD=ON"
|
"-DCOMPILER_RT_BAREMETAL_BUILD=ON"
|
||||||
"-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}"
|
"-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}"
|
||||||
|
] ++ lib.optionals (useLLVM && !haveLibc) [
|
||||||
|
"-DCMAKE_C_FLAGS=-nodefaultlibs"
|
||||||
] ++ lib.optionals (useLLVM) [
|
] ++ lib.optionals (useLLVM) [
|
||||||
"-DCOMPILER_RT_BUILD_BUILTINS=ON"
|
"-DCOMPILER_RT_BUILD_BUILTINS=ON"
|
||||||
"-DCMAKE_C_FLAGS=-nodefaultlibs"
|
|
||||||
#https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program
|
#https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program
|
||||||
"-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
|
"-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
|
||||||
] ++ lib.optionals (bareMetal) [
|
] ++ lib.optionals (bareMetal) [
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{ lowPrio, newScope, pkgs, lib, stdenv, cmake, gccForLibs
|
{ lowPrio, newScope, pkgs, lib, stdenv, cmake
|
||||||
|
, gccForLibs, preLibcCrossHeaders
|
||||||
, libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
|
, libxml2, python3, isl, fetchurl, overrideCC, wrapCCWith, wrapBintoolsWith
|
||||||
, buildLlvmTools # tools, but from the previous stage, for cross
|
, buildLlvmTools # tools, but from the previous stage, for cross
|
||||||
, targetLlvmLibraries # libraries, but from the next stage, for cross
|
, targetLlvmLibraries # libraries, but from the next stage, for cross
|
||||||
|
@ -96,7 +97,16 @@ let
|
||||||
# doesn’t support like LLVM. Probably we should move to some other
|
# doesn’t support like LLVM. Probably we should move to some other
|
||||||
# file.
|
# file.
|
||||||
|
|
||||||
bintools = callPackage ./bintools.nix {};
|
bintools-unwrapped = callPackage ./bintools {};
|
||||||
|
|
||||||
|
bintoolsNoLibc = wrapBintoolsWith {
|
||||||
|
bintools = tools.bintools-unwrapped;
|
||||||
|
libc = preLibcCrossHeaders;
|
||||||
|
};
|
||||||
|
|
||||||
|
bintools = wrapBintoolsWith {
|
||||||
|
bintools = tools.bintools-unwrapped;
|
||||||
|
};
|
||||||
|
|
||||||
lldClang = wrapCCWith rec {
|
lldClang = wrapCCWith rec {
|
||||||
cc = tools.clang-unwrapped;
|
cc = tools.clang-unwrapped;
|
||||||
|
@ -115,6 +125,8 @@ let
|
||||||
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
|
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags
|
||||||
'' + lib.optionalString (!stdenv.targetPlatform.isWasm) ''
|
'' + lib.optionalString (!stdenv.targetPlatform.isWasm) ''
|
||||||
echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags
|
echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags
|
||||||
|
'' + lib.optionalString (stdenv.targetPlatform.isAndroid && stdenv.targetPlatform.useLLVM) ''
|
||||||
|
echo "-lunwind" >> $out/nix-support/cc-ldflags
|
||||||
'' + lib.optionalString stdenv.targetPlatform.isWasm ''
|
'' + lib.optionalString stdenv.targetPlatform.isWasm ''
|
||||||
echo "-fno-exceptions" >> $out/nix-support/cc-cflags
|
echo "-fno-exceptions" >> $out/nix-support/cc-cflags
|
||||||
'' + mkExtraBuildCommands cc;
|
'' + mkExtraBuildCommands cc;
|
||||||
|
@ -123,9 +135,7 @@ let
|
||||||
lldClangNoLibcxx = wrapCCWith rec {
|
lldClangNoLibcxx = wrapCCWith rec {
|
||||||
cc = tools.clang-unwrapped;
|
cc = tools.clang-unwrapped;
|
||||||
libcxx = null;
|
libcxx = null;
|
||||||
bintools = wrapBintoolsWith {
|
inherit (tools) bintools;
|
||||||
inherit (tools) bintools;
|
|
||||||
};
|
|
||||||
extraPackages = [
|
extraPackages = [
|
||||||
targetLlvmLibraries.compiler-rt
|
targetLlvmLibraries.compiler-rt
|
||||||
];
|
];
|
||||||
|
@ -139,10 +149,7 @@ let
|
||||||
lldClangNoLibc = wrapCCWith rec {
|
lldClangNoLibc = wrapCCWith rec {
|
||||||
cc = tools.clang-unwrapped;
|
cc = tools.clang-unwrapped;
|
||||||
libcxx = null;
|
libcxx = null;
|
||||||
bintools = wrapBintoolsWith {
|
bintools = tools.bintoolsNoLibc;
|
||||||
inherit (tools) bintools;
|
|
||||||
libc = null;
|
|
||||||
};
|
|
||||||
extraPackages = [
|
extraPackages = [
|
||||||
targetLlvmLibraries.compiler-rt
|
targetLlvmLibraries.compiler-rt
|
||||||
];
|
];
|
||||||
|
@ -155,26 +162,43 @@ let
|
||||||
lldClangNoCompilerRt = wrapCCWith rec {
|
lldClangNoCompilerRt = wrapCCWith rec {
|
||||||
cc = tools.clang-unwrapped;
|
cc = tools.clang-unwrapped;
|
||||||
libcxx = null;
|
libcxx = null;
|
||||||
bintools = wrapBintoolsWith {
|
bintools = tools.bintoolsNoLibc;
|
||||||
inherit (tools) bintools;
|
|
||||||
libc = null;
|
|
||||||
};
|
|
||||||
extraPackages = [ ];
|
extraPackages = [ ];
|
||||||
extraBuildCommands = ''
|
extraBuildCommands = ''
|
||||||
echo "-nostartfiles" >> $out/nix-support/cc-cflags
|
echo "-nostartfiles" >> $out/nix-support/cc-cflags
|
||||||
'' + mkExtraBuildCommands0 cc;
|
'' + mkExtraBuildCommands0 cc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
lldClangNoCompilerRtWithLibc = wrapCCWith rec {
|
||||||
|
cc = tools.clang-unwrapped;
|
||||||
|
libcxx = null;
|
||||||
|
inherit (tools) bintools;
|
||||||
|
extraPackages = [ ];
|
||||||
|
extraBuildCommands = mkExtraBuildCommands0 cc;
|
||||||
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
libraries = lib.makeExtensible (libraries: let
|
libraries = lib.makeExtensible (libraries: let
|
||||||
callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
|
callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python3 isl release_version version fetch; });
|
||||||
in {
|
in {
|
||||||
|
|
||||||
compiler-rt = callPackage ./compiler-rt ({} //
|
compiler-rt-libc = callPackage ./compiler-rt {
|
||||||
(lib.optionalAttrs (stdenv.hostPlatform.useLLVM or false) {
|
stdenv = if stdenv.hostPlatform.useLLVM or false
|
||||||
stdenv = overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt;
|
then overrideCC stdenv buildLlvmTools.lldClangNoCompilerRtWithLibc
|
||||||
}));
|
else stdenv;
|
||||||
|
};
|
||||||
|
|
||||||
|
compiler-rt-no-libc = callPackage ./compiler-rt {
|
||||||
|
stdenv = if stdenv.hostPlatform.useLLVM or false
|
||||||
|
then overrideCC stdenv buildLlvmTools.lldClangNoCompilerRt
|
||||||
|
else stdenv;
|
||||||
|
};
|
||||||
|
|
||||||
|
# N.B. condition is safe because without useLLVM both are the same.
|
||||||
|
compiler-rt = if stdenv.hostPlatform.isAndroid
|
||||||
|
then libraries.compiler-rt-libc
|
||||||
|
else libraries.compiler-rt-no-libc;
|
||||||
|
|
||||||
stdenv = overrideCC stdenv buildLlvmTools.clang;
|
stdenv = overrideCC stdenv buildLlvmTools.clang;
|
||||||
|
|
||||||
|
|
|
@ -10345,14 +10345,17 @@ in
|
||||||
gerbil-support = callPackage ../development/compilers/gerbil/gerbil-support.nix { };
|
gerbil-support = callPackage ../development/compilers/gerbil/gerbil-support.nix { };
|
||||||
gerbilPackages-unstable = gerbil-support.gerbilPackages-unstable; # NB: don't recurseIntoAttrs for (unstable!) libraries
|
gerbilPackages-unstable = gerbil-support.gerbilPackages-unstable; # NB: don't recurseIntoAttrs for (unstable!) libraries
|
||||||
|
|
||||||
gccFun = callPackage (if (with stdenv.targetPlatform; isVc4 || libc == "relibc")
|
inherit (let
|
||||||
then ../development/compilers/gcc/6
|
num =
|
||||||
else ../development/compilers/gcc/10);
|
if (with stdenv.targetPlatform; isVc4 || libc == "relibc") then 6
|
||||||
gcc = if (with stdenv.targetPlatform; isVc4 || libc == "relibc")
|
else if (stdenv.targetPlatform.isAarch64 && stdenv.isDarwin) then 11
|
||||||
then gcc6 else
|
else if stdenv.targetPlatform.isAarch64 then 9
|
||||||
# aarch64-darwin doesn't support earlier gcc
|
else 10;
|
||||||
if (stdenv.targetPlatform.isAarch64 && stdenv.isDarwin) then gcc11
|
numS = toString num;
|
||||||
else if stdenv.targetPlatform.isAarch64 then gcc9 else gcc10;
|
in {
|
||||||
|
gcc = pkgs.${"gcc${numS}"};
|
||||||
|
gccFun = callPackage (../development/compilers/gcc + "/${numS}");
|
||||||
|
}) gcc gccFun;
|
||||||
gcc-unwrapped = gcc.cc;
|
gcc-unwrapped = gcc.cc;
|
||||||
|
|
||||||
wrapNonDeterministicGcc = stdenv: ccWrapper:
|
wrapNonDeterministicGcc = stdenv: ccWrapper:
|
||||||
|
@ -10430,7 +10433,7 @@ in
|
||||||
|
|
||||||
crossLibcStdenv =
|
crossLibcStdenv =
|
||||||
if stdenv.hostPlatform.useLLVM or false
|
if stdenv.hostPlatform.useLLVM or false
|
||||||
then overrideCC stdenv buildPackages.llvmPackages_8.lldClangNoLibc
|
then overrideCC stdenv buildPackages.llvmPackages.lldClangNoLibc
|
||||||
else gccCrossLibcStdenv;
|
else gccCrossLibcStdenv;
|
||||||
|
|
||||||
# The GCC used to build libc for the target platform. Normal gccs will be
|
# The GCC used to build libc for the target platform. Normal gccs will be
|
||||||
|
@ -11175,19 +11178,16 @@ in
|
||||||
llvm_6 = llvmPackages_6.llvm;
|
llvm_6 = llvmPackages_6.llvm;
|
||||||
llvm_5 = llvmPackages_5.llvm;
|
llvm_5 = llvmPackages_5.llvm;
|
||||||
|
|
||||||
llvmPackages = with targetPlatform;
|
llvmPackages = let
|
||||||
if isDarwin then
|
choose = platform:
|
||||||
llvmPackages_7
|
/**/ if platform.isDarwin then "7"
|
||||||
else if isFreeBSD then
|
else if platform.isFreeBSD then "7"
|
||||||
llvmPackages_7
|
else if platform.isAndroid then "12"
|
||||||
else if isAndroid then
|
else if platform.isLinux then "7"
|
||||||
llvmPackages_12
|
else if platform.isWasm then "8"
|
||||||
else if isLinux then
|
else "latest";
|
||||||
llvmPackages_7
|
minSupported = lib.min (choose stdenv.hostPlatform) (choose stdenv.targetPlatform);
|
||||||
else if isWasm then
|
in pkgs.${"llvmPackages_${minSupported}"};
|
||||||
llvmPackages_8
|
|
||||||
else
|
|
||||||
llvmPackages_latest;
|
|
||||||
|
|
||||||
llvmPackages_5 = recurseIntoAttrs (callPackage ../development/compilers/llvm/5 {
|
llvmPackages_5 = recurseIntoAttrs (callPackage ../development/compilers/llvm/5 {
|
||||||
inherit (stdenvAdapters) overrideCC;
|
inherit (stdenvAdapters) overrideCC;
|
||||||
|
@ -12602,11 +12602,7 @@ in
|
||||||
});
|
});
|
||||||
binutilsNoLibc = wrapBintoolsWith {
|
binutilsNoLibc = wrapBintoolsWith {
|
||||||
bintools = binutils-unwrapped;
|
bintools = binutils-unwrapped;
|
||||||
libc =
|
libc = preLibcCrossHeaders;
|
||||||
/**/ if stdenv.targetPlatform.libc == "msvcrt" then targetPackages.windows.mingw_w64_headers
|
|
||||||
else if stdenv.targetPlatform.libc == "libSystem" then darwin.xcode
|
|
||||||
else if stdenv.targetPlatform.libc == "nblibc" then targetPackages.netbsdCross.headers
|
|
||||||
else null;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bison = callPackage ../development/tools/parsing/bison { };
|
bison = callPackage ../development/tools/parsing/bison { };
|
||||||
|
@ -14741,6 +14737,13 @@ in
|
||||||
stdenv = crossLibcStdenv;
|
stdenv = crossLibcStdenv;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# These are used when buiding compiler-rt / libgcc, prior to building libc.
|
||||||
|
preLibcCrossHeaders = let
|
||||||
|
inherit (stdenv.targetPlatform) libc;
|
||||||
|
in if libc == "msvcrt" then targetPackages.windows.mingw_w64_headers
|
||||||
|
else if libc == "nblibc" then targetPackages.netbsdCross.headers
|
||||||
|
else null;
|
||||||
|
|
||||||
# We can choose:
|
# We can choose:
|
||||||
libcCrossChooser = name:
|
libcCrossChooser = name:
|
||||||
# libc is hackily often used from the previous stage. This `or`
|
# libc is hackily often used from the previous stage. This `or`
|
||||||
|
@ -14755,8 +14758,10 @@ in
|
||||||
else if name == "newlib" then targetPackages.newlibCross or newlibCross
|
else if name == "newlib" then targetPackages.newlibCross or newlibCross
|
||||||
else if name == "musl" then targetPackages.muslCross or muslCross
|
else if name == "musl" then targetPackages.muslCross or muslCross
|
||||||
else if name == "msvcrt" then targetPackages.windows.mingw_w64 or windows.mingw_w64
|
else if name == "msvcrt" then targetPackages.windows.mingw_w64 or windows.mingw_w64
|
||||||
else if stdenv.targetPlatform.useiOSPrebuilt then targetPackages.darwin.iosSdkPkgs.libraries or darwin.iosSdkPkgs.libraries
|
else if name == "libSystem" then
|
||||||
else if name == "libSystem" then targetPackages.darwin.xcode
|
if stdenv.targetPlatform.useiOSPrebuilt
|
||||||
|
then targetPackages.darwin.iosSdkPkgs.libraries or darwin.iosSdkPkgs.libraries
|
||||||
|
else throw "don't yet have a `targetPackages.darwin.LibsystemCross`"
|
||||||
else if name == "nblibc" then targetPackages.netbsdCross.libc or netbsdCross.libc
|
else if name == "nblibc" then targetPackages.netbsdCross.libc or netbsdCross.libc
|
||||||
else if name == "wasilibc" then targetPackages.wasilibc or wasilibc
|
else if name == "wasilibc" then targetPackages.wasilibc or wasilibc
|
||||||
else if name == "relibc" then targetPackages.relibc or relibc
|
else if name == "relibc" then targetPackages.relibc or relibc
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
, buildPackages, pkgs, targetPackages
|
, buildPackages, pkgs, targetPackages
|
||||||
, pkgsBuildBuild, pkgsBuildHost, pkgsBuildTarget, pkgsHostHost, pkgsTargetTarget
|
, pkgsBuildBuild, pkgsBuildHost, pkgsBuildTarget, pkgsHostHost, pkgsTargetTarget
|
||||||
, stdenv, splicePackages, newScope
|
, stdenv, splicePackages, newScope
|
||||||
|
, preLibcCrossHeaders
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
@ -52,7 +53,7 @@ impure-cmds // apple-source-releases // {
|
||||||
};
|
};
|
||||||
|
|
||||||
binutilsNoLibc = pkgs.wrapBintoolsWith {
|
binutilsNoLibc = pkgs.wrapBintoolsWith {
|
||||||
libc = null;
|
libc = preLibcCrossHeaders;
|
||||||
bintools = self.binutils-unwrapped;
|
bintools = self.binutils-unwrapped;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue