From 2cb440df726bb0995c5c5640353b7a7311bceb6c Mon Sep 17 00:00:00 2001 From: Dan Peebles Date: Sat, 18 Mar 2017 13:07:52 -0400 Subject: [PATCH] llvm-4: small improvements on Darwin and elsewhere Split outputs because there's no point in keeping a reference to Python and it causes trouble during the Darwin stdenv bootstrap. There's also an unnecessary dependency on LLVM in libc++ which causes us to rebuild LLVM several more times than necessary during bootstrap, and an awkward dependency on XPC in the TSAN that we turn off. This is in preparation for using LLVM 4 in the Darwin stdenv and by default across nixpkgs. --- .../compilers/llvm/4/clang/default.nix | 11 +++++++++++ .../compilers/llvm/4/libc++/default.nix | 2 +- pkgs/development/compilers/llvm/4/llvm.nix | 15 ++++++++------- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/pkgs/development/compilers/llvm/4/clang/default.nix b/pkgs/development/compilers/llvm/4/clang/default.nix index 88eafe983d3e..6ce63209935c 100644 --- a/pkgs/development/compilers/llvm/4/clang/default.nix +++ b/pkgs/development/compilers/llvm/4/clang/default.nix @@ -29,12 +29,23 @@ let sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/ToolChains.cpp ''; + outputs = [ "out" "python" ]; + # Clang expects to find LLVMgold in its own prefix # Clang expects to find sanitizer libraries in its own prefix postInstall = '' 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 + + mkdir -p $python/bin $python/share/clang/ + mv $out/bin/{git-clang-format,scan-view} $python/bin + if [ -e $out/bin/set-xcode-analyzer ]; then + mv $out/bin/set-xcode-analyzer $python/bin + fi + mv $out/share/clang/*.py $python/share/clang + + rm $out/bin/c-index-test ''; enableParallelBuilding = true; diff --git a/pkgs/development/compilers/llvm/4/libc++/default.nix b/pkgs/development/compilers/llvm/4/libc++/default.nix index 8e2c8eaa1768..ba8302919e1e 100644 --- a/pkgs/development/compilers/llvm/4/libc++/default.nix +++ b/pkgs/development/compilers/llvm/4/libc++/default.nix @@ -19,7 +19,7 @@ stdenv.mkDerivation rec { substituteInPlace lib/CMakeLists.txt --replace "/usr/lib/libc++" "\''${LIBCXX_LIBCXXABI_LIB_PATH}/libc++" ''; - buildInputs = [ cmake llvm libcxxabi ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames; + buildInputs = [ cmake libcxxabi ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames; cmakeFlags = [ "-DLIBCXX_LIBCXXABI_LIB_PATH=${libcxxabi}/lib" diff --git a/pkgs/development/compilers/llvm/4/llvm.nix b/pkgs/development/compilers/llvm/4/llvm.nix index ac3fc6790d58..83a14b7fc4dd 100644 --- a/pkgs/development/compilers/llvm/4/llvm.nix +++ b/pkgs/development/compilers/llvm/4/llvm.nix @@ -41,16 +41,18 @@ in stdenv.mkDerivation rec { outputs = [ "out" ] ++ stdenv.lib.optional enableSharedLibraries "lib"; buildInputs = [ perl groff cmake libxml2 python libffi ] - ++ stdenv.lib.optionals stdenv.isDarwin - [ libcxxabi darwin.cctools darwin.apple_sdk.libs.xpc ]; + ++ stdenv.lib.optionals stdenv.isDarwin [ libcxxabi ]; propagatedBuildInputs = [ ncurses zlib ]; - # hacky fix: New LLVM releases require a newer OS X SDK than - # 10.9. This is a temporary measure until nixpkgs darwin support is - # updated. + # 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 '' - sed -i 's/os_trace(\(.*\)");$/printf(\1\\n");/g' ./projects/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc + substituteInPlace ./projects/compiler-rt/cmake/config-ix.cmake \ + --replace 'set(COMPILER_RT_HAS_TSAN TRUE)' 'set(COMPILER_RT_HAS_TSAN FALSE)' '' # Patch llvm-config to return correct library path based on --link-{shared,static}. + stdenv.lib.optionalString (enableSharedLibraries) '' @@ -85,7 +87,6 @@ in stdenv.mkDerivation rec { ++ stdenv.lib.optionals (isDarwin) [ "-DLLVM_ENABLE_LIBCXX=ON" "-DCAN_TARGET_i386=false" - "-DCMAKE_LIBTOOL=${darwin.cctools}/bin/libtool" ]; postBuild = ''