clang: Add compat `lib` attribute to have `stdenv.cc.cc.lib` always work

Fixes tarball evaluation:

http://hydra.nixos.org/build/35042997/nixlog/1/raw

+129 -123
+43 -41
pkgs/development/compilers/llvm/3.6/clang/default.nix
··· 2 2 3 3 let 4 4 gcc = if stdenv.cc.isGNU then stdenv.cc.cc else stdenv.cc.cc.gcc; 5 - in stdenv.mkDerivation { 6 - name = "clang-${version}"; 5 + self = stdenv.mkDerivation { 6 + name = "clang-${version}"; 7 7 8 - unpackPhase = '' 9 - unpackFile ${fetch "cfe" "1wwr8s6lzr324hv4s1k6na4j5zv6n9kdhi14s4kb9b13d93814df"} 10 - mv cfe-${version}.src clang 11 - sourceRoot=$PWD/clang 12 - unpackFile ${clang-tools-extra_src} 13 - mv clang-tools-extra-* $sourceRoot/tools/extra 14 - ''; 8 + unpackPhase = '' 9 + unpackFile ${fetch "cfe" "1wwr8s6lzr324hv4s1k6na4j5zv6n9kdhi14s4kb9b13d93814df"} 10 + mv cfe-${version}.src clang 11 + sourceRoot=$PWD/clang 12 + unpackFile ${clang-tools-extra_src} 13 + mv clang-tools-extra-* $sourceRoot/tools/extra 14 + ''; 15 15 16 - buildInputs = [ cmake libedit libxml2 llvm ]; 16 + buildInputs = [ cmake libedit libxml2 llvm ]; 17 17 18 - cmakeFlags = [ 19 - "-DCMAKE_BUILD_TYPE=Release" 20 - "-DCMAKE_CXX_FLAGS=-std=c++11" 21 - ] ++ 22 - # Maybe with compiler-rt this won't be needed? 23 - (stdenv.lib.optional stdenv.isLinux "-DGCC_INSTALL_PREFIX=${gcc}") ++ 24 - (stdenv.lib.optional (stdenv.cc.libc != null) "-DC_INCLUDE_DIRS=${stdenv.cc.libc}/include"); 18 + cmakeFlags = [ 19 + "-DCMAKE_BUILD_TYPE=Release" 20 + "-DCMAKE_CXX_FLAGS=-std=c++11" 21 + ] ++ 22 + # Maybe with compiler-rt this won't be needed? 23 + (stdenv.lib.optional stdenv.isLinux "-DGCC_INSTALL_PREFIX=${gcc}") ++ 24 + (stdenv.lib.optional (stdenv.cc.libc != null) "-DC_INCLUDE_DIRS=${stdenv.cc.libc}/include"); 25 25 26 - patches = [ ./purity.patch ./cmake-exports.patch ]; 26 + patches = [ ./purity.patch ./cmake-exports.patch ]; 27 27 28 - postPatch = '' 29 - sed -i -e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/Tools.cpp 30 - sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/ToolChains.cpp 31 - ''; 28 + postPatch = '' 29 + sed -i -e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/Tools.cpp 30 + sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/ToolChains.cpp 31 + ''; 32 32 33 - # Clang expects to find LLVMgold in its own prefix 34 - # Clang expects to find sanitizer libraries in its own prefix 35 - postInstall = '' 36 - ln -sv ${llvm}/lib/LLVMgold.so $out/lib 37 - ln -sv ${llvm}/lib/clang/${version}/lib $out/lib/clang/${version}/ 38 - ln -sv $out/bin/clang $out/bin/cpp 39 - ''; 33 + # Clang expects to find LLVMgold in its own prefix 34 + # Clang expects to find sanitizer libraries in its own prefix 35 + postInstall = '' 36 + ln -sv ${llvm}/lib/LLVMgold.so $out/lib 37 + ln -sv ${llvm}/lib/clang/${version}/lib $out/lib/clang/${version}/ 38 + ln -sv $out/bin/clang $out/bin/cpp 39 + ''; 40 40 41 - enableParallelBuilding = true; 41 + enableParallelBuilding = true; 42 42 43 - passthru = { 44 - isClang = true; 45 - } // stdenv.lib.optionalAttrs stdenv.isLinux { 46 - inherit gcc; 47 - }; 43 + passthru = { 44 + lib = self; # compatibility with gcc, so that `stdenv.cc.cc.lib` works on both 45 + isClang = true; 46 + } // stdenv.lib.optionalAttrs stdenv.isLinux { 47 + inherit gcc; 48 + }; 48 49 49 - meta = { 50 - description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler"; 51 - homepage = http://llvm.org/; 52 - license = stdenv.lib.licenses.bsd3; 53 - platforms = stdenv.lib.platforms.all; 50 + meta = { 51 + description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler"; 52 + homepage = http://llvm.org/; 53 + license = stdenv.lib.licenses.bsd3; 54 + platforms = stdenv.lib.platforms.all; 55 + }; 54 56 }; 55 - } 57 + in self
+43 -41
pkgs/development/compilers/llvm/3.7/clang/default.nix
··· 2 2 3 3 let 4 4 gcc = if stdenv.cc.isGNU then stdenv.cc.cc else stdenv.cc.cc.gcc; 5 - in stdenv.mkDerivation { 6 - name = "clang-${version}"; 5 + self = stdenv.mkDerivation { 6 + name = "clang-${version}"; 7 7 8 - unpackPhase = '' 9 - unpackFile ${fetch "cfe" "0x065d0w9b51xvdjxwfzjxng0gzpbx45fgiaxpap45ragi61dqjn"} 10 - mv cfe-${version}.src clang 11 - sourceRoot=$PWD/clang 12 - unpackFile ${clang-tools-extra_src} 13 - mv clang-tools-extra-* $sourceRoot/tools/extra 14 - ''; 8 + unpackPhase = '' 9 + unpackFile ${fetch "cfe" "0x065d0w9b51xvdjxwfzjxng0gzpbx45fgiaxpap45ragi61dqjn"} 10 + mv cfe-${version}.src clang 11 + sourceRoot=$PWD/clang 12 + unpackFile ${clang-tools-extra_src} 13 + mv clang-tools-extra-* $sourceRoot/tools/extra 14 + ''; 15 15 16 - buildInputs = [ cmake libedit libxml2 llvm ]; 16 + buildInputs = [ cmake libedit libxml2 llvm ]; 17 17 18 - cmakeFlags = [ 19 - "-DCMAKE_BUILD_TYPE=Release" 20 - "-DCMAKE_CXX_FLAGS=-std=c++11" 21 - ] ++ 22 - # Maybe with compiler-rt this won't be needed? 23 - (stdenv.lib.optional stdenv.isLinux "-DGCC_INSTALL_PREFIX=${gcc}") ++ 24 - (stdenv.lib.optional (stdenv.cc.libc != null) "-DC_INCLUDE_DIRS=${stdenv.cc.libc}/include"); 18 + cmakeFlags = [ 19 + "-DCMAKE_BUILD_TYPE=Release" 20 + "-DCMAKE_CXX_FLAGS=-std=c++11" 21 + ] ++ 22 + # Maybe with compiler-rt this won't be needed? 23 + (stdenv.lib.optional stdenv.isLinux "-DGCC_INSTALL_PREFIX=${gcc}") ++ 24 + (stdenv.lib.optional (stdenv.cc.libc != null) "-DC_INCLUDE_DIRS=${stdenv.cc.libc}/include"); 25 25 26 - patches = [ ./purity.patch ]; 26 + patches = [ ./purity.patch ]; 27 27 28 - postPatch = '' 29 - sed -i -e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/Tools.cpp 30 - sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/ToolChains.cpp 31 - ''; 28 + postPatch = '' 29 + sed -i -e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/Tools.cpp 30 + sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/ToolChains.cpp 31 + ''; 32 32 33 - # Clang expects to find LLVMgold in its own prefix 34 - # Clang expects to find sanitizer libraries in its own prefix 35 - postInstall = '' 36 - ln -sv ${llvm}/lib/LLVMgold.so $out/lib 37 - ln -sv ${llvm}/lib/clang/${version}/lib $out/lib/clang/${version}/ 38 - ln -sv $out/bin/clang $out/bin/cpp 39 - ''; 33 + # Clang expects to find LLVMgold in its own prefix 34 + # Clang expects to find sanitizer libraries in its own prefix 35 + postInstall = '' 36 + ln -sv ${llvm}/lib/LLVMgold.so $out/lib 37 + ln -sv ${llvm}/lib/clang/${version}/lib $out/lib/clang/${version}/ 38 + ln -sv $out/bin/clang $out/bin/cpp 39 + ''; 40 40 41 - enableParallelBuilding = true; 41 + enableParallelBuilding = true; 42 42 43 - passthru = { 44 - isClang = true; 45 - } // stdenv.lib.optionalAttrs stdenv.isLinux { 46 - inherit gcc; 47 - }; 43 + passthru = { 44 + lib = self; # compatibility with gcc, so that `stdenv.cc.cc.lib` works on both 45 + isClang = true; 46 + } // stdenv.lib.optionalAttrs stdenv.isLinux { 47 + inherit gcc; 48 + }; 48 49 49 - meta = { 50 - description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler"; 51 - homepage = http://llvm.org/; 52 - license = stdenv.lib.licenses.bsd3; 53 - platforms = stdenv.lib.platforms.all; 50 + meta = { 51 + description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler"; 52 + homepage = http://llvm.org/; 53 + license = stdenv.lib.licenses.bsd3; 54 + platforms = stdenv.lib.platforms.all; 55 + }; 54 56 }; 55 - } 57 + in self
+43 -41
pkgs/development/compilers/llvm/3.8/clang/default.nix
··· 2 2 3 3 let 4 4 gcc = if stdenv.cc.isGNU then stdenv.cc.cc else stdenv.cc.cc.gcc; 5 - in stdenv.mkDerivation { 6 - name = "clang-${version}"; 5 + self = stdenv.mkDerivation { 6 + name = "clang-${version}"; 7 7 8 - unpackPhase = '' 9 - unpackFile ${fetch "cfe" "1ybcac8hlr9vl3wg8s4v6cp0c0qgqnwprsv85lihbkq3vqv94504"} 10 - mv cfe-${version}.src clang 11 - sourceRoot=$PWD/clang 12 - unpackFile ${clang-tools-extra_src} 13 - mv clang-tools-extra-* $sourceRoot/tools/extra 14 - ''; 8 + unpackPhase = '' 9 + unpackFile ${fetch "cfe" "1ybcac8hlr9vl3wg8s4v6cp0c0qgqnwprsv85lihbkq3vqv94504"} 10 + mv cfe-${version}.src clang 11 + sourceRoot=$PWD/clang 12 + unpackFile ${clang-tools-extra_src} 13 + mv clang-tools-extra-* $sourceRoot/tools/extra 14 + ''; 15 15 16 - buildInputs = [ cmake libedit libxml2 llvm python ]; 16 + buildInputs = [ cmake libedit libxml2 llvm python ]; 17 17 18 - cmakeFlags = [ 19 - "-DCMAKE_BUILD_TYPE=Release" 20 - "-DCMAKE_CXX_FLAGS=-std=c++11" 21 - ] ++ 22 - # Maybe with compiler-rt this won't be needed? 23 - (stdenv.lib.optional stdenv.isLinux "-DGCC_INSTALL_PREFIX=${gcc}") ++ 24 - (stdenv.lib.optional (stdenv.cc.libc != null) "-DC_INCLUDE_DIRS=${stdenv.cc.libc}/include"); 18 + cmakeFlags = [ 19 + "-DCMAKE_BUILD_TYPE=Release" 20 + "-DCMAKE_CXX_FLAGS=-std=c++11" 21 + ] ++ 22 + # Maybe with compiler-rt this won't be needed? 23 + (stdenv.lib.optional stdenv.isLinux "-DGCC_INSTALL_PREFIX=${gcc}") ++ 24 + (stdenv.lib.optional (stdenv.cc.libc != null) "-DC_INCLUDE_DIRS=${stdenv.cc.libc}/include"); 25 25 26 - patches = [ ./purity.patch ]; 26 + patches = [ ./purity.patch ]; 27 27 28 - postPatch = '' 29 - sed -i -e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/Tools.cpp 30 - sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/ToolChains.cpp 31 - ''; 28 + postPatch = '' 29 + sed -i -e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/Tools.cpp 30 + sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/ToolChains.cpp 31 + ''; 32 32 33 - # Clang expects to find LLVMgold in its own prefix 34 - # Clang expects to find sanitizer libraries in its own prefix 35 - postInstall = '' 36 - ln -sv ${llvm}/lib/LLVMgold.so $out/lib 37 - ln -sv ${llvm}/lib/clang/${version}/lib $out/lib/clang/${version}/ 38 - ln -sv $out/bin/clang $out/bin/cpp 39 - ''; 33 + # Clang expects to find LLVMgold in its own prefix 34 + # Clang expects to find sanitizer libraries in its own prefix 35 + postInstall = '' 36 + ln -sv ${llvm}/lib/LLVMgold.so $out/lib 37 + ln -sv ${llvm}/lib/clang/${version}/lib $out/lib/clang/${version}/ 38 + ln -sv $out/bin/clang $out/bin/cpp 39 + ''; 40 40 41 - enableParallelBuilding = true; 41 + enableParallelBuilding = true; 42 42 43 - passthru = { 44 - isClang = true; 45 - } // stdenv.lib.optionalAttrs stdenv.isLinux { 46 - inherit gcc; 47 - }; 43 + passthru = { 44 + lib = self; # compatibility with gcc, so that `stdenv.cc.cc.lib` works on both 45 + isClang = true; 46 + } // stdenv.lib.optionalAttrs stdenv.isLinux { 47 + inherit gcc; 48 + }; 48 49 49 - meta = { 50 - description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler"; 51 - homepage = http://llvm.org/; 52 - license = stdenv.lib.licenses.bsd3; 53 - platforms = stdenv.lib.platforms.all; 50 + meta = { 51 + description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler"; 52 + homepage = http://llvm.org/; 53 + license = stdenv.lib.licenses.bsd3; 54 + platforms = stdenv.lib.platforms.all; 55 + }; 54 56 }; 55 - } 57 + in self