llvm and clang 6: factor out compiler-rt, fix libstdcxxStdenv sanitizer headers
Build compiler-rt separate from llvm and clang, and just add as an extra
library in the wrapper.
(cherry picked from commit 16da44b5c1
)
This commit is contained in:
parent
ce0180dfd5
commit
158e550762
@ -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 ];
|
||||||
|
|
||||||
@ -51,10 +48,9 @@ let
|
|||||||
outputs = [ "out" "lib" "python" ];
|
outputs = [ "out" "lib" "python" ];
|
||||||
|
|
||||||
# Clang expects to find LLVMgold in its own prefix
|
# Clang expects to find LLVMgold in its own prefix
|
||||||
# Clang expects to find sanitizer libraries in its own prefix
|
|
||||||
postInstall = ''
|
postInstall = ''
|
||||||
ln -sv ${llvm}/lib/LLVMgold.so $out/lib
|
ln -sv ${llvm}/lib/LLVMgold.so $out/lib
|
||||||
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
|
||||||
@ -76,7 +72,7 @@ let
|
|||||||
passthru = {
|
passthru = {
|
||||||
isClang = true;
|
isClang = true;
|
||||||
inherit llvm;
|
inherit llvm;
|
||||||
} // stdenv.lib.optionalAttrs stdenv.isLinux {
|
} // stdenv.lib.optionalAttrs stdenv.targetPlatform.isLinux {
|
||||||
inherit gcc;
|
inherit gcc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
31
pkgs/development/compilers/llvm/6/compiler-rt.nix
Normal file
31
pkgs/development/compilers/llvm/6/compiler-rt.nix
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
{ stdenv, version, fetch, cmake, python, llvm }:
|
||||||
|
with stdenv.lib;
|
||||||
|
stdenv.mkDerivation rec {
|
||||||
|
name = "compiler-rt-${version}";
|
||||||
|
inherit version;
|
||||||
|
src = fetch "compiler-rt" "16m7rvh3w6vq10iwkjrr1nn293djld3xm62l5zasisaprx117k6h";
|
||||||
|
|
||||||
|
nativeBuildInputs = [ cmake python llvm ];
|
||||||
|
|
||||||
|
configureFlags = [
|
||||||
|
"-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON"
|
||||||
|
];
|
||||||
|
|
||||||
|
outputs = [ "dev" "out" ];
|
||||||
|
|
||||||
|
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)'
|
||||||
|
'';
|
||||||
|
|
||||||
|
enableParallelBuilding = true;
|
||||||
|
}
|
@ -14,7 +14,6 @@ let
|
|||||||
inherit sha256;
|
inherit sha256;
|
||||||
};
|
};
|
||||||
|
|
||||||
compiler-rt_src = fetch "compiler-rt" "16m7rvh3w6vq10iwkjrr1nn293djld3xm62l5zasisaprx117k6h";
|
|
||||||
clang-tools-extra_src = fetch "clang-tools-extra" "1ll9v6r29xfdiywbn9iss49ad39ah3fk91wiv0sr6k6k9i544fq5";
|
clang-tools-extra_src = fetch "clang-tools-extra" "1ll9v6r29xfdiywbn9iss49ad39ah3fk91wiv0sr6k6k9i544fq5";
|
||||||
|
|
||||||
# Add man output without introducing extra dependencies.
|
# Add man output without introducing extra dependencies.
|
||||||
@ -27,7 +26,6 @@ let
|
|||||||
in {
|
in {
|
||||||
|
|
||||||
llvm = overrideManOutput (callPackage ./llvm.nix {
|
llvm = overrideManOutput (callPackage ./llvm.nix {
|
||||||
inherit compiler-rt_src;
|
|
||||||
inherit (targetLlvmLibraries) libcxxabi;
|
inherit (targetLlvmLibraries) libcxxabi;
|
||||||
});
|
});
|
||||||
clang-unwrapped = overrideManOutput (callPackage ./clang {
|
clang-unwrapped = overrideManOutput (callPackage ./clang {
|
||||||
@ -43,11 +41,27 @@ let
|
|||||||
libstdcxxClang = wrapCCWith {
|
libstdcxxClang = wrapCCWith {
|
||||||
cc = tools.clang-unwrapped;
|
cc = tools.clang-unwrapped;
|
||||||
extraPackages = [ libstdcxxHook ];
|
extraPackages = [ libstdcxxHook ];
|
||||||
|
extraBuildCommands = stdenv.lib.optionalString stdenv.targetPlatform.isLinux ''
|
||||||
|
echo "--gcc-toolchain=${tools.clang-unwrapped.gcc}" >> $out/nix-support/cc-cflags
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
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 = ''
|
||||||
|
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
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
lld = callPackage ./lld.nix {};
|
lld = callPackage ./lld.nix {};
|
||||||
@ -59,6 +73,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;
|
||||||
|
@ -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
|
||||||
@ -33,8 +32,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,15 +59,11 @@ 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.hostPlatform.isMusl ''
|
'' + stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
|
||||||
patch -p1 -i ${../TLI-musl.patch}
|
patch -p1 -i ${../TLI-musl.patch}
|
||||||
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
|
||||||
@ -93,7 +78,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"
|
||||||
|
Loading…
Reference in New Issue
Block a user