From 812f7714e26a2fdd1446b21e43642c4c023045df Mon Sep 17 00:00:00 2001 From: Daiderd Jordan Date: Sun, 31 Dec 2017 11:07:57 +0100 Subject: [PATCH 1/2] clang: move libclang to separate lib output Currently clang-unwrapped can't be used as a buildInput without also shadowing clang/clang++ of a clang based stdenv. --- pkgs/development/compilers/llvm/3.8/clang/default.nix | 6 ++++-- pkgs/development/compilers/llvm/3.8/default.nix | 2 ++ pkgs/development/compilers/llvm/3.9/clang/default.nix | 6 ++++-- pkgs/development/compilers/llvm/3.9/default.nix | 2 ++ pkgs/development/compilers/llvm/4/clang/default.nix | 7 ++++--- pkgs/development/compilers/llvm/4/default.nix | 1 + pkgs/development/compilers/llvm/5/clang/default.nix | 7 ++++--- pkgs/development/compilers/llvm/5/default.nix | 1 + 8 files changed, 22 insertions(+), 10 deletions(-) diff --git a/pkgs/development/compilers/llvm/3.8/clang/default.nix b/pkgs/development/compilers/llvm/3.8/clang/default.nix index 90b8ea2581e8..388c24e63364 100644 --- a/pkgs/development/compilers/llvm/3.8/clang/default.nix +++ b/pkgs/development/compilers/llvm/3.8/clang/default.nix @@ -29,7 +29,7 @@ let sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/ToolChains.cpp ''; - outputs = [ "out" "python" ]; + outputs = [ "out" "lib" "python" ]; # Clang expects to find LLVMgold in its own prefix # Clang expects to find sanitizer libraries in its own prefix @@ -38,6 +38,9 @@ let ln -sv ${llvm}/lib/clang/${version}/lib $out/lib/clang/${version}/ ln -sv $out/bin/clang $out/bin/cpp + # Move libclang to 'lib' output + moveToOutput "lib/libclang.*" "$lib" + 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 @@ -51,7 +54,6 @@ let enableParallelBuilding = true; passthru = { - lib = self; # compatibility with gcc, so that `stdenv.cc.cc.lib` works on both isClang = true; inherit llvm; } // stdenv.lib.optionalAttrs stdenv.isLinux { diff --git a/pkgs/development/compilers/llvm/3.8/default.nix b/pkgs/development/compilers/llvm/3.8/default.nix index bd79db012a63..2f3d59434bba 100644 --- a/pkgs/development/compilers/llvm/3.8/default.nix +++ b/pkgs/development/compilers/llvm/3.8/default.nix @@ -22,6 +22,8 @@ let inherit clang-tools-extra_src stdenv; }; + libclang = self.clang-unwrapped.lib; + clang = if stdenv.cc.isGNU then self.libstdcxxClang else self.libcxxClang; libstdcxxClang = ccWrapperFun { diff --git a/pkgs/development/compilers/llvm/3.9/clang/default.nix b/pkgs/development/compilers/llvm/3.9/clang/default.nix index ec2ec27df363..f215aadc4d98 100644 --- a/pkgs/development/compilers/llvm/3.9/clang/default.nix +++ b/pkgs/development/compilers/llvm/3.9/clang/default.nix @@ -31,7 +31,7 @@ let sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/ToolChains.cpp ''; - outputs = [ "out" "python" ]; + outputs = [ "out" "lib" "python" ]; # Clang expects to find LLVMgold in its own prefix # Clang expects to find sanitizer libraries in its own prefix @@ -40,6 +40,9 @@ let ln -sv ${llvm}/lib/clang/${version}/lib $out/lib/clang/${version}/ ln -sv $out/bin/clang $out/bin/cpp + # Move libclang to 'lib' output + moveToOutput "lib/libclang.*" "$lib" + 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 @@ -53,7 +56,6 @@ let enableParallelBuilding = true; passthru = { - lib = self; # compatibility with gcc, so that `stdenv.cc.cc.lib` works on both isClang = true; inherit llvm; } // stdenv.lib.optionalAttrs stdenv.isLinux { diff --git a/pkgs/development/compilers/llvm/3.9/default.nix b/pkgs/development/compilers/llvm/3.9/default.nix index 5ce51bc9c122..b17d86b57517 100644 --- a/pkgs/development/compilers/llvm/3.9/default.nix +++ b/pkgs/development/compilers/llvm/3.9/default.nix @@ -22,6 +22,8 @@ let inherit clang-tools-extra_src stdenv; }; + libclang = self.clang-unwrapped.lib; + clang = if stdenv.cc.isGNU then self.libstdcxxClang else self.libcxxClang; libstdcxxClang = ccWrapperFun { diff --git a/pkgs/development/compilers/llvm/4/clang/default.nix b/pkgs/development/compilers/llvm/4/clang/default.nix index 8d40ee3c8aa2..404b65c56ab7 100644 --- a/pkgs/development/compilers/llvm/4/clang/default.nix +++ b/pkgs/development/compilers/llvm/4/clang/default.nix @@ -49,7 +49,7 @@ let sed -i '1s,^,find_package(Sphinx REQUIRED)\n,' docs/CMakeLists.txt ''; - outputs = [ "out" "python" ] + outputs = [ "out" "lib" "python" ] ++ stdenv.lib.optional enableManpages "man"; # Clang expects to find LLVMgold in its own prefix @@ -59,13 +59,15 @@ let ln -sv ${llvm}/lib/clang/${release_version}/lib $out/lib/clang/${release_version}/ ln -sv $out/bin/clang $out/bin/cpp + # Move libclang to 'lib' output + moveToOutput "lib/libclang.*" "$lib" + 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 '' + stdenv.lib.optionalString enableManpages '' @@ -79,7 +81,6 @@ let enableParallelBuilding = true; passthru = { - lib = self; # compatibility with gcc, so that `stdenv.cc.cc.lib` works on both isClang = true; inherit llvm; } // stdenv.lib.optionalAttrs stdenv.isLinux { diff --git a/pkgs/development/compilers/llvm/4/default.nix b/pkgs/development/compilers/llvm/4/default.nix index fa61a6c22e71..5a54468f6553 100644 --- a/pkgs/development/compilers/llvm/4/default.nix +++ b/pkgs/development/compilers/llvm/4/default.nix @@ -34,6 +34,7 @@ let llvm = overrideManOutput llvm; clang-unwrapped = overrideManOutput clang-unwrapped; + libclang = self.clang-unwrapped.lib; llvm-manpages = lowPrio self.llvm.man; clang-manpages = lowPrio self.clang-unwrapped.man; diff --git a/pkgs/development/compilers/llvm/5/clang/default.nix b/pkgs/development/compilers/llvm/5/clang/default.nix index fa8502ebd67a..a63b8b9cdf2a 100644 --- a/pkgs/development/compilers/llvm/5/clang/default.nix +++ b/pkgs/development/compilers/llvm/5/clang/default.nix @@ -50,7 +50,7 @@ let sed -i '1s,^,find_package(Sphinx REQUIRED)\n,' docs/CMakeLists.txt ''; - outputs = [ "out" "python" ] + outputs = [ "out" "lib" "python" ] ++ stdenv.lib.optional enableManpages "man"; # Clang expects to find LLVMgold in its own prefix @@ -60,13 +60,15 @@ let ln -sv ${llvm}/lib/clang/${release_version}/lib $out/lib/clang/${release_version}/ ln -sv $out/bin/clang $out/bin/cpp + # Move libclang to 'lib' output + moveToOutput "lib/libclang.*" "$lib" + 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 '' + stdenv.lib.optionalString enableManpages '' @@ -80,7 +82,6 @@ let enableParallelBuilding = true; passthru = { - lib = self; # compatibility with gcc, so that `stdenv.cc.cc.lib` works on both isClang = true; inherit llvm; } // stdenv.lib.optionalAttrs stdenv.isLinux { diff --git a/pkgs/development/compilers/llvm/5/default.nix b/pkgs/development/compilers/llvm/5/default.nix index 9891f3090ac1..2c26fb4ac358 100644 --- a/pkgs/development/compilers/llvm/5/default.nix +++ b/pkgs/development/compilers/llvm/5/default.nix @@ -34,6 +34,7 @@ let llvm = overrideManOutput llvm; clang-unwrapped = overrideManOutput clang-unwrapped; + libclang = self.clang-unwrapped.lib; llvm-manpages = lowPrio self.llvm.man; clang-manpages = lowPrio self.clang-unwrapped.man; From b0c043d26c7ecebe737c7a03d87a732f1285d993 Mon Sep 17 00:00:00 2001 From: Daiderd Jordan Date: Tue, 2 Jan 2018 00:52:22 +0100 Subject: [PATCH 2/2] stdenv: allow lib output of clang on darwin --- pkgs/stdenv/darwin/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix index d202186c29b2..cba988b8cc76 100644 --- a/pkgs/stdenv/darwin/default.nix +++ b/pkgs/stdenv/darwin/default.nix @@ -365,7 +365,7 @@ in rec { 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 gzip ncurses.out ncurses.dev ncurses.man gnused bash gawk - gnugrep llvmPackages.clang-unwrapped patch pcre.out gettext + gnugrep llvmPackages.clang-unwrapped llvmPackages.clang-unwrapped.lib patch pcre.out gettext binutils-raw.bintools binutils binutils.bintools cc.expand-response-params ]) ++ (with pkgs.darwin; [