llvm 5: split out compiler-rt and remove libcxxabi dep

We already did them on non-mass-rebuild llvm 6. Also, this allows
simplifying the stdenv booting.

We were missing the libcxxabi dep in compile-rt in llvm 6, so fixed that
too.
This commit is contained in:
John Ericson 2018-06-14 10:22:33 -04:00
parent fc9644d4c9
commit 6e7e22da70
6 changed files with 83 additions and 57 deletions

View File

@ -30,10 +30,7 @@ let
"-DSPHINX_OUTPUT_MAN=ON" "-DSPHINX_OUTPUT_MAN=ON"
"-DSPHINX_OUTPUT_HTML=OFF" "-DSPHINX_OUTPUT_HTML=OFF"
"-DSPHINX_WARNINGS_AS_ERRORS=OFF" "-DSPHINX_WARNINGS_AS_ERRORS=OFF"
] ];
# Maybe with compiler-rt this won't be needed?
++ stdenv.lib.optional stdenv.isLinux "-DGCC_INSTALL_PREFIX=${gcc}"
++ stdenv.lib.optional (stdenv.cc.libc != null) "-DC_INCLUDE_DIRS=${stdenv.cc.libc}/include";
patches = [ ./purity.patch ]; patches = [ ./purity.patch ];
@ -50,13 +47,12 @@ let
outputs = [ "out" "lib" "python" ]; outputs = [ "out" "lib" "python" ];
# Clang expects to find LLVMgold in its own prefix
postInstall = '' postInstall = ''
# Clang expects to find LLVMgold in its own prefix
if [ -e ${llvm}/lib/LLVMgold.so ]; then if [ -e ${llvm}/lib/LLVMgold.so ]; then
ln -sv ${llvm}/lib/LLVMgold.so $out/lib ln -sv ${llvm}/lib/LLVMgold.so $out/lib
fi fi
# Clang expects to find sanitizer libraries in its own prefix
ln -sv ${llvm}/lib/clang/${release_version}/lib $out/lib/clang/${release_version}/
ln -sv $out/bin/clang $out/bin/cpp ln -sv $out/bin/clang $out/bin/cpp
# Move libclang to 'lib' output # Move libclang to 'lib' output

View File

@ -0,0 +1,37 @@
{ stdenv, version, fetch, cmake, python, llvm, libcxxabi }:
with stdenv.lib;
stdenv.mkDerivation rec {
name = "compiler-rt-${version}";
inherit version;
src = fetch "compiler-rt" "0ipd4jdxpczgr2w6lzrabymz6dhzj69ywmyybjjc1q397zgrvziy";
nativeBuildInputs = [ cmake python llvm ];
buildInputs = stdenv.lib.optional stdenv.hostPlatform.isDarwin libcxxabi;
configureFlags = [
"-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON"
];
outputs = [ "out" "dev" ];
patches = [
./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory
] ++ optional stdenv.hostPlatform.isMusl ./sanitizers-nongnu.patch;
# 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
# can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd
# get no binary cache for the entire platform. If you really find yourself wanting the TSAN, make this controllable by
# a flag and turn the flag off during the stdenv build.
postPatch = stdenv.lib.optionalString stdenv.isDarwin ''
substituteInPlace cmake/config-ix.cmake \
--replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)'
'';
# Hack around weird upsream RPATH bug
postInstall = stdenv.lib.optionalString stdenv.isDarwin ''
ln -s "$out/lib"/*/* "$out/lib"
'';
enableParallelBuilding = true;
}

View File

@ -14,7 +14,6 @@ let
inherit sha256; inherit sha256;
}; };
compiler-rt_src = fetch "compiler-rt" "0ipd4jdxpczgr2w6lzrabymz6dhzj69ywmyybjjc1q397zgrvziy";
clang-tools-extra_src = fetch "clang-tools-extra" "018b3fiwah8f8br5i26qmzh6sjvzchpn358sn8v079m49f2jldm3"; clang-tools-extra_src = fetch "clang-tools-extra" "018b3fiwah8f8br5i26qmzh6sjvzchpn358sn8v079m49f2jldm3";
# Add man output without introducing extra dependencies. # Add man output without introducing extra dependencies.
@ -24,12 +23,19 @@ let
tools = stdenv.lib.makeExtensible (tools: let tools = stdenv.lib.makeExtensible (tools: let
callPackage = newScope (tools // { inherit stdenv cmake libxml2 python2 isl release_version version fetch; }); callPackage = newScope (tools // { inherit stdenv cmake libxml2 python2 isl release_version version fetch; });
mkExtraBuildCommands = cc: ''
rsrc="$out/resource-root"
mkdir "$rsrc"
ln -s "${cc}/lib/clang/${release_version}/include" "$rsrc"
ln -s "${targetLlvmLibraries.compiler-rt.out}/lib" "$rsrc/lib"
echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
'' + stdenv.lib.optionalString stdenv.targetPlatform.isLinux ''
echo "--gcc-toolchain=${tools.clang-unwrapped.gcc}" >> $out/nix-support/cc-cflags
'';
in { in {
llvm = overrideManOutput (callPackage ./llvm.nix { llvm = overrideManOutput (callPackage ./llvm.nix { });
inherit compiler-rt_src;
inherit (targetLlvmLibraries) libcxxabi;
});
clang-unwrapped = overrideManOutput (callPackage ./clang { clang-unwrapped = overrideManOutput (callPackage ./clang {
inherit clang-tools-extra_src; inherit clang-tools-extra_src;
}); });
@ -40,14 +46,23 @@ let
clang = if stdenv.cc.isGNU then tools.libstdcxxClang else tools.libcxxClang; clang = if stdenv.cc.isGNU then tools.libstdcxxClang else tools.libcxxClang;
libstdcxxClang = wrapCCWith { libstdcxxClang = wrapCCWith rec {
cc = tools.clang-unwrapped; cc = tools.clang-unwrapped;
extraPackages = [ libstdcxxHook ]; extraPackages = [
libstdcxxHook
targetLlvmLibraries.compiler-rt
];
extraBuildCommands = mkExtraBuildCommands cc;
}; };
libcxxClang = wrapCCWith { libcxxClang = wrapCCWith rec {
cc = tools.clang-unwrapped; cc = tools.clang-unwrapped;
extraPackages = [ targetLlvmLibraries.libcxx targetLlvmLibraries.libcxxabi ]; extraPackages = [
targetLlvmLibraries.libcxx
targetLlvmLibraries.libcxxabi
targetLlvmLibraries.compiler-rt
];
extraBuildCommands = mkExtraBuildCommands cc;
}; };
lld = callPackage ./lld.nix {}; lld = callPackage ./lld.nix {};
@ -59,6 +74,8 @@ let
callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python2 isl release_version version fetch; }); callPackage = newScope (libraries // buildLlvmTools // { inherit stdenv cmake libxml2 python2 isl release_version version fetch; });
in { in {
compiler-rt = callPackage ./compiler-rt.nix {};
stdenv = overrideCC stdenv buildLlvmTools.clang; stdenv = overrideCC stdenv buildLlvmTools.clang;
libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang; libcxxStdenv = overrideCC stdenv buildLlvmTools.libcxxClang;

View File

@ -11,7 +11,6 @@
, version , version
, release_version , release_version
, zlib , zlib
, compiler-rt_src
, libcxxabi , libcxxabi
, debugVersion ? false , debugVersion ? false
, enableManpages ? false , enableManpages ? false
@ -32,8 +31,6 @@ in stdenv.mkDerivation (rec {
unpackFile ${src} unpackFile ${src}
mv llvm-${version}* llvm mv llvm-${version}* llvm
sourceRoot=$PWD/llvm sourceRoot=$PWD/llvm
unpackFile ${compiler-rt_src}
mv compiler-rt-* $sourceRoot/projects/compiler-rt
''; '';
outputs = [ "out" "python" ] outputs = [ "out" "python" ]
@ -48,15 +45,7 @@ in stdenv.mkDerivation (rec {
propagatedBuildInputs = [ ncurses zlib ]; propagatedBuildInputs = [ ncurses zlib ];
# 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
# can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd
# get no binary cache for the entire platform. If you really find yourself wanting the TSAN, make this controllable by
# a flag and turn the flag off during the stdenv build.
postPatch = stdenv.lib.optionalString stdenv.isDarwin '' postPatch = stdenv.lib.optionalString stdenv.isDarwin ''
substituteInPlace ./projects/compiler-rt/cmake/config-ix.cmake \
--replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)'
substituteInPlace cmake/modules/AddLLVM.cmake \ substituteInPlace cmake/modules/AddLLVM.cmake \
--replace 'set(_install_name_dir INSTALL_NAME_DIR "@rpath")' "set(_install_name_dir INSTALL_NAME_DIR "$lib/lib")" \ --replace 'set(_install_name_dir INSTALL_NAME_DIR "@rpath")' "set(_install_name_dir INSTALL_NAME_DIR "$lib/lib")" \
--replace 'set(_install_rpath "@loader_path/../lib" ''${extra_libdir})' "" --replace 'set(_install_rpath "@loader_path/../lib" ''${extra_libdir})' ""
@ -70,9 +59,6 @@ in stdenv.mkDerivation (rec {
substituteInPlace unittests/Support/CMakeLists.txt \ substituteInPlace unittests/Support/CMakeLists.txt \
--replace "Path.cpp" "" --replace "Path.cpp" ""
rm unittests/Support/Path.cpp rm unittests/Support/Path.cpp
# Revert compiler-rt commit that makes codesign mandatory
patch -p1 -i ${./compiler-rt-codesign.patch} -d projects/compiler-rt
'' + stdenv.lib.optionalString stdenv.isAarch64 '' '' + stdenv.lib.optionalString stdenv.isAarch64 ''
patch -p0 < ${../aarch64.patch} patch -p0 < ${../aarch64.patch}
'' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl '' '' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
@ -80,7 +66,6 @@ in stdenv.mkDerivation (rec {
substituteInPlace unittests/Support/CMakeLists.txt \ substituteInPlace unittests/Support/CMakeLists.txt \
--replace "add_subdirectory(DynamicLibrary)" "" --replace "add_subdirectory(DynamicLibrary)" ""
rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp rm unittests/Support/DynamicLibrary/DynamicLibraryTest.cpp
patch -p1 -i ${./sanitizers-nongnu.patch} -d projects/compiler-rt
''; '';
# hacky fix: created binaries need to be run before installation # hacky fix: created binaries need to be run before installation
@ -95,7 +80,6 @@ in stdenv.mkDerivation (rec {
"-DLLVM_BUILD_TESTS=ON" "-DLLVM_BUILD_TESTS=ON"
"-DLLVM_ENABLE_FFI=ON" "-DLLVM_ENABLE_FFI=ON"
"-DLLVM_ENABLE_RTTI=ON" "-DLLVM_ENABLE_RTTI=ON"
"-DCOMPILER_RT_INCLUDE_TESTS=OFF" # FIXME: requires clang source code
] ]
++ stdenv.lib.optional enableSharedLibraries ++ stdenv.lib.optional enableSharedLibraries
"-DLLVM_LINK_LLVM_DYLIB=ON" "-DLLVM_LINK_LLVM_DYLIB=ON"

View File

@ -239,9 +239,11 @@ in rec {
openssh sqlite sed serf openldap db cyrus-sasl expat apr-util openssh sqlite sed serf openldap db cyrus-sasl expat apr-util
findfreetype libssh curl cmake autoconf automake libtool cpio; findfreetype libssh curl cmake autoconf automake libtool cpio;
llvmPackages_5 = super.llvmPackages_5 // { llvmPackages_5 = super.llvmPackages_5 // (let
inherit (llvmPackages_5) libcxx libcxxabi; libraries = super.llvmPackages_5.libraries.extend (_: _: {
}; inherit (llvmPackages_5) libcxx libcxxabi;
});
in { inherit libraries; } // libraries);
darwin = super.darwin // { darwin = super.darwin // {
inherit (darwin) inherit (darwin)
@ -280,12 +282,14 @@ in rec {
coreutils findutils diffutils patchutils; coreutils findutils diffutils patchutils;
llvmPackages_5 = super.llvmPackages_5 // (let llvmPackages_5 = super.llvmPackages_5 // (let
tools = super.llvmPackages_5.tools.extend (_: _: { tools = super.llvmPackages_5.tools.extend (llvmSelf: _: {
llvm = llvmPackages_5.llvm.override { inherit libcxxabi; }; inherit (llvmPackages_5) llvm;
clang-unwrapped = llvmPackages_5.clang-unwrapped.override { llvm = self.llvmPackages_5.llvm; }; # The .override that was here before had the side affect of removing
# the hacked-in "man" output.
clang-unwrapped = builtins.removeAttrs llvmPackages_5.clang-unwrapped [ "man" ];
}); });
libraries = super.llvmPackages_5.libraries.extend (_: _: { libraries = super.llvmPackages_5.libraries.extend (llvmSelf: _: {
inherit (llvmPackages_5) libcxx libcxxabi; inherit (llvmPackages_5) libcxx libcxxabi compiler-rt;
}); });
in { inherit tools libraries; } // tools // libraries); in { inherit tools libraries; } // tools // libraries);
@ -327,7 +331,7 @@ in rec {
inherit (llvmPackages_5) llvm clang-unwrapped; inherit (llvmPackages_5) llvm clang-unwrapped;
}); });
libraries = super.llvmPackages_5.libraries.extend (_: _: { libraries = super.llvmPackages_5.libraries.extend (_: _: {
inherit (llvmPackages_5) libcxx libcxxabi; inherit (llvmPackages_5) compiler-rt libcxx libcxxabi;
}); });
in { inherit tools libraries; } // tools // libraries); in { inherit tools libraries; } // tools // libraries);
@ -361,20 +365,7 @@ in rec {
initialPath = import ../common-path.nix { inherit pkgs; }; initialPath = import ../common-path.nix { inherit pkgs; };
shell = "${pkgs.bash}/bin/bash"; shell = "${pkgs.bash}/bin/bash";
cc = lib.callPackageWith {} ../../build-support/cc-wrapper { cc = pkgs.llvmPackages.libcxxClang;
inherit (pkgs) stdenvNoCC;
inherit shell;
nativeTools = false;
nativeLibc = false;
buildPackages = {
inherit (prevStage) stdenv;
};
inherit (pkgs) coreutils gnugrep;
cc = pkgs.llvmPackages.clang-unwrapped;
bintools = pkgs.darwin.binutils;
libc = pkgs.darwin.Libsystem;
extraPackages = [ pkgs.libcxx ];
};
extraNativeBuildInputs = []; extraNativeBuildInputs = [];
extraBuildInputs = [ pkgs.darwin.CF ]; extraBuildInputs = [ pkgs.darwin.CF ];
@ -390,7 +381,8 @@ in rec {
allowedRequisites = (with pkgs; [ allowedRequisites = (with pkgs; [
xz.out xz.bin libcxx libcxxabi gmp.out gnumake findutils bzip2.out xz.out xz.bin libcxx libcxxabi gmp.out gnumake findutils bzip2.out
bzip2.bin llvmPackages.llvm llvmPackages.llvm.lib zlib.out zlib.dev libffi.out coreutils ed diffutils gnutar bzip2.bin llvmPackages.llvm llvmPackages.llvm.lib llvmPackages.compiler-rt llvmPackages.compiler-rt.dev
zlib.out zlib.dev libffi.out coreutils ed diffutils gnutar
gzip ncurses.out ncurses.dev ncurses.man gnused bash gawk gzip ncurses.out ncurses.dev ncurses.man gnused bash gawk
gnugrep llvmPackages.clang-unwrapped llvmPackages.clang-unwrapped.lib patch pcre.out gettext gnugrep llvmPackages.clang-unwrapped llvmPackages.clang-unwrapped.lib patch pcre.out gettext
binutils.bintools darwin.binutils darwin.binutils.bintools binutils.bintools darwin.binutils darwin.binutils.bintools

View File

@ -3,7 +3,7 @@ with stdenv.lib;
let let
# Sanitizers are not supported on Darwin. # Sanitizers are not supported on Darwin.
# Sanitizer headers aren't available in older libc++ stdenvs due to a bug # Sanitizer headers aren't available in older libc++ stdenvs due to a bug
sanitizersBroken = stdenv.cc.isClang && versionOlder (getVersion stdenv.cc.name) "6.0.0"; sanitizersBroken = stdenv.cc.isClang && versionOlder (getVersion stdenv.cc.name) "5.0.0";
in stdenv.mkDerivation { in stdenv.mkDerivation {
name = "cc-wrapper-test"; name = "cc-wrapper-test";