From fc9644d4c9c9d29958e9bcf1676d48d4b3026bb4 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Thu, 14 Jun 2018 10:22:33 -0400 Subject: [PATCH] llvm 6: Fix libcxxabi impurity and darwin sanitizers --- .../compilers/llvm/6/compiler-rt.nix | 10 ++++-- pkgs/development/compilers/llvm/6/default.nix | 35 +++++++++---------- pkgs/test/cc-wrapper/default.nix | 2 +- 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/pkgs/development/compilers/llvm/6/compiler-rt.nix b/pkgs/development/compilers/llvm/6/compiler-rt.nix index 333818f7dbde..88bccca36476 100644 --- a/pkgs/development/compilers/llvm/6/compiler-rt.nix +++ b/pkgs/development/compilers/llvm/6/compiler-rt.nix @@ -1,4 +1,4 @@ -{ stdenv, version, fetch, cmake, python, llvm }: +{ stdenv, version, fetch, cmake, python, llvm, libcxxabi }: with stdenv.lib; stdenv.mkDerivation rec { name = "compiler-rt-${version}"; @@ -6,12 +6,13 @@ stdenv.mkDerivation rec { src = fetch "compiler-rt" "16m7rvh3w6vq10iwkjrr1nn293djld3xm62l5zasisaprx117k6h"; nativeBuildInputs = [ cmake python llvm ]; + buildInputs = stdenv.lib.optional stdenv.hostPlatform.isDarwin libcxxabi; configureFlags = [ "-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON" ]; - outputs = [ "dev" "out" ]; + outputs = [ "out" "dev" ]; patches = [ ./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory @@ -27,5 +28,10 @@ stdenv.mkDerivation rec { --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; } diff --git a/pkgs/development/compilers/llvm/6/default.nix b/pkgs/development/compilers/llvm/6/default.nix index 8fe68bad213d..40d602e222ed 100644 --- a/pkgs/development/compilers/llvm/6/default.nix +++ b/pkgs/development/compilers/llvm/6/default.nix @@ -23,9 +23,19 @@ let tools = stdenv.lib.makeExtensible (tools: let 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 { llvm = overrideManOutput (callPackage ./llvm.nix { }); + clang-unwrapped = overrideManOutput (callPackage ./clang { inherit clang-tools-extra_src; }); @@ -38,16 +48,11 @@ let libstdcxxClang = wrapCCWith rec { cc = tools.clang-unwrapped; - extraPackages = [ libstdcxxHook 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 - ''; + extraPackages = [ + libstdcxxHook + targetLlvmLibraries.compiler-rt + ]; + extraBuildCommands = mkExtraBuildCommands cc; }; libcxxClang = wrapCCWith rec { @@ -57,15 +62,7 @@ let 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 - ''; + extraBuildCommands = mkExtraBuildCommands cc; }; lld = callPackage ./lld.nix {}; diff --git a/pkgs/test/cc-wrapper/default.nix b/pkgs/test/cc-wrapper/default.nix index 7061adb8e88a..dd41cd157cae 100644 --- a/pkgs/test/cc-wrapper/default.nix +++ b/pkgs/test/cc-wrapper/default.nix @@ -3,7 +3,7 @@ with stdenv.lib; let # Sanitizers are not supported on Darwin. # Sanitizer headers aren't available in older libc++ stdenvs due to a bug - sanitizersBroken = stdenv.isDarwin || stdenv.cc.isClang && builtins.compareVersions (getVersion stdenv.cc.name) "6.0.0" < 0; + sanitizersBroken = stdenv.cc.isClang && versionOlder (getVersion stdenv.cc.name) "6.0.0"; in stdenv.mkDerivation { name = "cc-wrapper-test";