From 6f6c06adc1c0338e0125e7d5785b43223493f114 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Thu, 2 Mar 2017 16:51:32 -0600 Subject: llvm4.0: Rename "4.0" (and _40) to "4" (and _4). This reflects upstream versioning change, and allows us to replace 4.0 with 4.1 (which is now a minor revision) without changing the attribute name. Thanks to @vcunat for the idea. --- .../compilers/llvm/4.0/clang/default.nix | 56 ---------- .../compilers/llvm/4.0/clang/purity.patch | 16 --- pkgs/development/compilers/llvm/4.0/default.nix | 51 --------- .../compilers/llvm/4.0/libc++/default.nix | 42 -------- .../compilers/llvm/4.0/libc++/setup-hook.sh | 3 - pkgs/development/compilers/llvm/4.0/libc++abi.nix | 46 -------- pkgs/development/compilers/llvm/4.0/lld.nix | 32 ------ pkgs/development/compilers/llvm/4.0/lldb.nix | 50 --------- .../compilers/llvm/4.0/llvm-outputs.patch | 26 ----- pkgs/development/compilers/llvm/4.0/llvm.nix | 117 --------------------- .../development/compilers/llvm/4/clang/default.nix | 56 ++++++++++ .../compilers/llvm/4/clang/purity.patch | 16 +++ pkgs/development/compilers/llvm/4/default.nix | 51 +++++++++ .../compilers/llvm/4/libc++/default.nix | 42 ++++++++ .../compilers/llvm/4/libc++/setup-hook.sh | 3 + pkgs/development/compilers/llvm/4/libc++abi.nix | 46 ++++++++ pkgs/development/compilers/llvm/4/lld.nix | 32 ++++++ pkgs/development/compilers/llvm/4/lldb.nix | 50 +++++++++ .../compilers/llvm/4/llvm-outputs.patch | 26 +++++ pkgs/development/compilers/llvm/4/llvm.nix | 117 +++++++++++++++++++++ 20 files changed, 439 insertions(+), 439 deletions(-) delete mode 100644 pkgs/development/compilers/llvm/4.0/clang/default.nix delete mode 100644 pkgs/development/compilers/llvm/4.0/clang/purity.patch delete mode 100644 pkgs/development/compilers/llvm/4.0/default.nix delete mode 100644 pkgs/development/compilers/llvm/4.0/libc++/default.nix delete mode 100644 pkgs/development/compilers/llvm/4.0/libc++/setup-hook.sh delete mode 100644 pkgs/development/compilers/llvm/4.0/libc++abi.nix delete mode 100644 pkgs/development/compilers/llvm/4.0/lld.nix delete mode 100644 pkgs/development/compilers/llvm/4.0/lldb.nix delete mode 100644 pkgs/development/compilers/llvm/4.0/llvm-outputs.patch delete mode 100644 pkgs/development/compilers/llvm/4.0/llvm.nix create mode 100644 pkgs/development/compilers/llvm/4/clang/default.nix create mode 100644 pkgs/development/compilers/llvm/4/clang/purity.patch create mode 100644 pkgs/development/compilers/llvm/4/default.nix create mode 100644 pkgs/development/compilers/llvm/4/libc++/default.nix create mode 100644 pkgs/development/compilers/llvm/4/libc++/setup-hook.sh create mode 100644 pkgs/development/compilers/llvm/4/libc++abi.nix create mode 100644 pkgs/development/compilers/llvm/4/lld.nix create mode 100644 pkgs/development/compilers/llvm/4/lldb.nix create mode 100644 pkgs/development/compilers/llvm/4/llvm-outputs.patch create mode 100644 pkgs/development/compilers/llvm/4/llvm.nix (limited to 'pkgs/development') diff --git a/pkgs/development/compilers/llvm/4.0/clang/default.nix b/pkgs/development/compilers/llvm/4.0/clang/default.nix deleted file mode 100644 index 5be8ffd91cf1..000000000000 --- a/pkgs/development/compilers/llvm/4.0/clang/default.nix +++ /dev/null @@ -1,56 +0,0 @@ -{ stdenv, fetch, cmake, libxml2, libedit, llvm, version, release_version, clang-tools-extra_src, python }: - -let - gcc = if stdenv.cc.isGNU then stdenv.cc.cc else stdenv.cc.cc.gcc; - self = stdenv.mkDerivation { - name = "clang-${version}"; - - unpackPhase = '' - unpackFile ${fetch "cfe" "1lsdyrz82vyrsc7k0ah1zmzzan61s5kakxrkxgfbmklp3pclfkwp"} - mv cfe-${version}* clang - sourceRoot=$PWD/clang - unpackFile ${clang-tools-extra_src} - mv clang-tools-extra-* $sourceRoot/tools/extra - ''; - - buildInputs = [ cmake libedit libxml2 llvm python ]; - - cmakeFlags = [ - "-DCMAKE_CXX_FLAGS=-std=c++11" - ] ++ - # 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 ]; - - postPatch = '' - sed -i -e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/Tools.cpp - sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/ToolChains.cpp - ''; - - # 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 - ''; - - enableParallelBuilding = true; - - passthru = { - lib = self; # compatibility with gcc, so that `stdenv.cc.cc.lib` works on both - isClang = true; - } // stdenv.lib.optionalAttrs stdenv.isLinux { - inherit gcc; - }; - - meta = { - description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler"; - homepage = http://llvm.org/; - license = stdenv.lib.licenses.ncsa; - platforms = stdenv.lib.platforms.all; - }; - }; -in self diff --git a/pkgs/development/compilers/llvm/4.0/clang/purity.patch b/pkgs/development/compilers/llvm/4.0/clang/purity.patch deleted file mode 100644 index f5fb4c73af47..000000000000 --- a/pkgs/development/compilers/llvm/4.0/clang/purity.patch +++ /dev/null @@ -1,16 +0,0 @@ ---- a/lib/Driver/Tools.cpp 2016-08-25 15:48:05.187553443 +0200 -+++ b/lib/Driver/Tools.cpp 2016-08-25 15:48:47.534468882 +0200 -@@ -9420,13 +9420,6 @@ - if (!Args.hasArg(options::OPT_static)) { - if (Args.hasArg(options::OPT_rdynamic)) - CmdArgs.push_back("-export-dynamic"); -- -- if (!Args.hasArg(options::OPT_shared)) { -- const std::string Loader = -- D.DyldPrefix + ToolChain.getDynamicLinker(Args); -- CmdArgs.push_back("-dynamic-linker"); -- CmdArgs.push_back(Args.MakeArgString(Loader)); -- } - } - - CmdArgs.push_back("-o"); diff --git a/pkgs/development/compilers/llvm/4.0/default.nix b/pkgs/development/compilers/llvm/4.0/default.nix deleted file mode 100644 index 349545a29599..000000000000 --- a/pkgs/development/compilers/llvm/4.0/default.nix +++ /dev/null @@ -1,51 +0,0 @@ -{ newScope, stdenv, isl, fetchurl, overrideCC, wrapCC, darwin, ccWrapperFun }: -let - callPackage = newScope (self // { inherit stdenv isl release_version version fetch; }); - - release_version = "4.0.0"; - rc = "rc3"; - version = "${release_version}${rc}"; - - fetch = name: sha256: fetchurl { - url = "http://llvm.org/pre-releases/${release_version}/${rc}/${name}-${version}.src.tar.xz"; - # Once 4.0 is released, use this instead: - # url = "http://llvm.org/releases/${release-version}/${name}-${version}.src.tar.xz"; - inherit sha256; - }; - - compiler-rt_src = fetch "compiler-rt" "0jfqhz95cp15c5688c6l9mr12s0qp86milpcrjlc93dc2jy08ba5"; - clang-tools-extra_src = fetch "clang-tools-extra" "1c9c507w3f5vm153rdd0kmzvv2ski6z439izk01zf5snfwkqxkq8"; - - self = { - llvm = callPackage ./llvm.nix { - inherit compiler-rt_src stdenv; - }; - - clang-unwrapped = callPackage ./clang { - inherit clang-tools-extra_src stdenv; - }; - - clang = wrapCC self.clang-unwrapped; - - libcxxClang = ccWrapperFun { - cc = self.clang-unwrapped; - isClang = true; - inherit (self) stdenv; - /* FIXME is this right? */ - inherit (stdenv.cc) libc nativeTools nativeLibc; - extraPackages = [ self.libcxx self.libcxxabi ]; - }; - - stdenv = overrideCC stdenv self.clang; - - libcxxStdenv = overrideCC stdenv self.libcxxClang; - - lld = callPackage ./lld.nix {}; - - lldb = callPackage ./lldb.nix {}; - - libcxx = callPackage ./libc++ {}; - - libcxxabi = callPackage ./libc++abi.nix {}; - }; -in self diff --git a/pkgs/development/compilers/llvm/4.0/libc++/default.nix b/pkgs/development/compilers/llvm/4.0/libc++/default.nix deleted file mode 100644 index 57e064fb79ad..000000000000 --- a/pkgs/development/compilers/llvm/4.0/libc++/default.nix +++ /dev/null @@ -1,42 +0,0 @@ -{ lib, stdenv, fetch, cmake, llvm, libcxxabi, fixDarwinDylibNames, version }: - -stdenv.mkDerivation rec { - name = "libc++-${version}"; - - src = fetch "libcxx" "15l6bcmwczspbqcq4m2lmzb23g11axr9m8dayn25iys26nn00q43"; - - postUnpack = '' - unpackFile ${libcxxabi.src} - export LIBCXXABI_INCLUDE_DIR="$PWD/$(ls -d libcxxabi-${version}*)/include" - ''; - - preConfigure = '' - # Get headers from the cxxabi source so we can see private headers not installed by the cxxabi package - cmakeFlagsArray=($cmakeFlagsArray -DLIBCXX_CXX_ABI_INCLUDE_PATHS="$LIBCXXABI_INCLUDE_DIR") - ''; - - patchPhase = '' - substituteInPlace lib/CMakeLists.txt --replace "/usr/lib/libc++" "\''${LIBCXX_LIBCXXABI_LIB_PATH}/libc++" - ''; - - buildInputs = [ cmake llvm libcxxabi ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames; - - cmakeFlags = [ - "-DLIBCXX_LIBCXXABI_LIB_PATH=${libcxxabi}/lib" - "-DLIBCXX_LIBCPPABI_VERSION=2" - "-DLIBCXX_CXX_ABI=libcxxabi" - ]; - - enableParallelBuilding = true; - - linkCxxAbi = stdenv.isLinux; - - setupHook = ./setup-hook.sh; - - meta = { - homepage = http://libcxx.llvm.org/; - description = "A new implementation of the C++ standard library, targeting C++11"; - license = with stdenv.lib.licenses; [ ncsa mit ]; - platforms = stdenv.lib.platforms.unix; - }; -} diff --git a/pkgs/development/compilers/llvm/4.0/libc++/setup-hook.sh b/pkgs/development/compilers/llvm/4.0/libc++/setup-hook.sh deleted file mode 100644 index 9022fced6ecf..000000000000 --- a/pkgs/development/compilers/llvm/4.0/libc++/setup-hook.sh +++ /dev/null @@ -1,3 +0,0 @@ -linkCxxAbi="@linkCxxAbi@" -export NIX_CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1" -export NIX_CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}" diff --git a/pkgs/development/compilers/llvm/4.0/libc++abi.nix b/pkgs/development/compilers/llvm/4.0/libc++abi.nix deleted file mode 100644 index fc1a6d84caa8..000000000000 --- a/pkgs/development/compilers/llvm/4.0/libc++abi.nix +++ /dev/null @@ -1,46 +0,0 @@ -{ stdenv, cmake, fetch, libcxx, libunwind, llvm, version }: - -stdenv.mkDerivation { - name = "libc++abi-${version}"; - - src = fetch "libcxxabi" "1frj1wz780xcwq77icfclnw6q4c8bkkdzkqsrmfjv9963kjylsy5"; - - buildInputs = [ cmake ] ++ stdenv.lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD) libunwind; - - postUnpack = '' - unpackFile ${libcxx.src} - unpackFile ${llvm.src} - export cmakeFlags="-DLLVM_PATH=$PWD/$(ls -d llvm-*) -DLIBCXXABI_LIBCXX_PATH=$PWD/$(ls -d libcxx-*)" - '' + stdenv.lib.optionalString stdenv.isDarwin '' - export TRIPLE=x86_64-apple-darwin - ''; - - installPhase = if stdenv.isDarwin - then '' - for file in lib/*.dylib; do - # this should be done in CMake, but having trouble figuring out - # the magic combination of necessary CMake variables - # if you fancy a try, take a look at - # http://www.cmake.org/Wiki/CMake_RPATH_handling - install_name_tool -id $out/$file $file - done - make install - install -d 755 $out/include - install -m 644 ../include/*.h $out/include - '' - else '' - install -d -m 755 $out/include $out/lib - install -m 644 lib/libc++abi.so.1.0 $out/lib - install -m 644 ../include/cxxabi.h $out/include - ln -s libc++abi.so.1.0 $out/lib/libc++abi.so - ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1 - ''; - - meta = { - homepage = http://libcxxabi.llvm.org/; - description = "A new implementation of low level support for a standard C++ library"; - license = with stdenv.lib.licenses; [ ncsa mit ]; - maintainers = with stdenv.lib.maintainers; [ vlstill ]; - platforms = stdenv.lib.platforms.unix; - }; -} diff --git a/pkgs/development/compilers/llvm/4.0/lld.nix b/pkgs/development/compilers/llvm/4.0/lld.nix deleted file mode 100644 index 7fe08cb02625..000000000000 --- a/pkgs/development/compilers/llvm/4.0/lld.nix +++ /dev/null @@ -1,32 +0,0 @@ -{ stdenv -, fetch -, cmake -, zlib -, llvm -, python -, version -}: - -stdenv.mkDerivation { - name = "lld-${version}"; - - src = fetch "lld" "0kmyp7iyf4f76wgy87jczkyhvzhlwfydvxgggl74z0x89xgry745"; - - buildInputs = [ cmake llvm ]; - - outputs = [ "out" "dev" ]; - - enableParallelBuilding = true; - - postInstall = '' - moveToOutput include "$dev" - moveToOutput lib "$dev" - ''; - - meta = { - description = "The LLVM Linker"; - homepage = http://lld.llvm.org/; - license = stdenv.lib.licenses.ncsa; - platforms = stdenv.lib.platforms.all; - }; -} diff --git a/pkgs/development/compilers/llvm/4.0/lldb.nix b/pkgs/development/compilers/llvm/4.0/lldb.nix deleted file mode 100644 index 23667e6afcd7..000000000000 --- a/pkgs/development/compilers/llvm/4.0/lldb.nix +++ /dev/null @@ -1,50 +0,0 @@ -{ stdenv -, fetch -, cmake -, zlib -, ncurses -, swig -, which -, libedit -, libxml2 -, llvm -, clang-unwrapped -, python -, version -, darwin -}: - -stdenv.mkDerivation { - name = "lldb-${version}"; - - src = fetch "lldb" "1qr0ky7llwgjgx1pzkp3pnz32nb6f7lvg8qg6rp5axhgpkx54hz7"; - - patchPhase = '' - # Fix up various paths that assume llvm and clang are installed in the same place - sed -i 's,".*ClangConfig.cmake","${clang-unwrapped}/lib/cmake/clang/ClangConfig.cmake",' \ - cmake/modules/LLDBStandalone.cmake - sed -i 's,".*tools/clang/include","${clang-unwrapped}/include",' \ - cmake/modules/LLDBStandalone.cmake - sed -i 's,"$.LLVM_LIBRARY_DIR.",${llvm}/lib ${clang-unwrapped}/lib,' \ - cmake/modules/LLDBStandalone.cmake - ''; - - buildInputs = [ cmake python which swig ncurses zlib libedit libxml2 llvm ] - ++ stdenv.lib.optionals stdenv.isDarwin [ darwin.libobjc darwin.apple_sdk.libs.xpc ]; - - CXXFLAGS = "-fno-rtti"; - hardeningDisable = [ "format" ]; - - cmakeFlags = [ - "-DLLDB_DISABLE_LIBEDIT=ON" - ]; - - enableParallelBuilding = true; - - meta = with stdenv.lib; { - description = "A next-generation high-performance debugger"; - homepage = http://llvm.org/; - license = licenses.ncsa; - platforms = platforms.allBut platforms.darwin; - }; -} diff --git a/pkgs/development/compilers/llvm/4.0/llvm-outputs.patch b/pkgs/development/compilers/llvm/4.0/llvm-outputs.patch deleted file mode 100644 index 40096fa3497f..000000000000 --- a/pkgs/development/compilers/llvm/4.0/llvm-outputs.patch +++ /dev/null @@ -1,26 +0,0 @@ -diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp -index 94d426b..37f7794 100644 ---- a/tools/llvm-config/llvm-config.cpp -+++ b/tools/llvm-config/llvm-config.cpp -@@ -333,6 +333,21 @@ int main(int argc, char **argv) { - ActiveIncludeOption = "-I" + ActiveIncludeDir; - } - -+ /// Nix-specific multiple-output handling: override ActiveLibDir if --link-shared -+ if (!IsInDevelopmentTree) { -+ bool WantShared = true; -+ for (int i = 1; i < argc; ++i) { -+ StringRef Arg = argv[i]; -+ if (Arg == "--link-shared") -+ WantShared = true; -+ else if (Arg == "--link-static") -+ WantShared = false; // the last one wins -+ } -+ -+ if (WantShared) -+ ActiveLibDir = std::string("@lib@") + "/lib" + LLVM_LIBDIR_SUFFIX; -+ } -+ - /// We only use `shared library` mode in cases where the static library form - /// of the components provided are not available; note however that this is - /// skipped if we're run from within the build dir. However, once installed, diff --git a/pkgs/development/compilers/llvm/4.0/llvm.nix b/pkgs/development/compilers/llvm/4.0/llvm.nix deleted file mode 100644 index 2d36f7cd0fb1..000000000000 --- a/pkgs/development/compilers/llvm/4.0/llvm.nix +++ /dev/null @@ -1,117 +0,0 @@ -{ stdenv -, fetch -, fetchpatch -, perl -, groff -, cmake -, python -, libffi -, binutils -, libxml2 -, valgrind -, ncurses -, version -, release_version -, zlib -, compiler-rt_src -, libcxxabi -, debugVersion ? false -, enableSharedLibraries ? true -, darwin -}: - -let - src = fetch "llvm" "0ic3y9gaissi6ixyj9x1c0pq69wfbl2svhprp33av0b58f7wj9v7"; - shlib = if stdenv.isDarwin then "dylib" else "so"; - - # Used when creating a version-suffixed symlink of libLLVM.dylib - shortVersion = with stdenv.lib; - concatStringsSep "." (take 2 (splitString "." release_version)); -in stdenv.mkDerivation rec { - name = "llvm-${version}"; - - unpackPhase = '' - unpackFile ${src} - mv llvm-${version}* llvm - sourceRoot=$PWD/llvm - unpackFile ${compiler-rt_src} - mv compiler-rt-* $sourceRoot/projects/compiler-rt - ''; - - 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 ]; - - 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. - postPatch = stdenv.lib.optionalString stdenv.isDarwin '' - sed -i 's/os_trace(\(.*\)");$/printf(\1\\n");/g' ./projects/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc - '' - # Patch llvm-config to return correct library path based on --link-{shared,static}. - + stdenv.lib.optionalString (enableSharedLibraries) '' - substitute '${./llvm-outputs.patch}' ./llvm-outputs.patch --subst-var lib - patch -p1 < ./llvm-outputs.patch - ''; - - # hacky fix: created binaries need to be run before installation - preBuild = '' - mkdir -p $out/ - ln -sv $PWD/lib $out - ''; - - cmakeFlags = with stdenv; [ - "-DCMAKE_BUILD_TYPE=${if debugVersion then "Debug" else "Release"}" - "-DLLVM_INSTALL_UTILS=ON" # Needed by rustc - "-DLLVM_BUILD_TESTS=ON" - "-DLLVM_ENABLE_FFI=ON" - "-DLLVM_ENABLE_RTTI=ON" - "-DCOMPILER_RT_INCLUDE_TESTS=OFF" # FIXME: requires clang source code - ] ++ stdenv.lib.optional enableSharedLibraries [ - "-DLLVM_LINK_LLVM_DYLIB=ON" - ] ++ stdenv.lib.optional (!isDarwin) - "-DLLVM_BINUTILS_INCDIR=${binutils.dev}/include" - ++ stdenv.lib.optionals (isDarwin) [ - "-DLLVM_ENABLE_LIBCXX=ON" - "-DCAN_TARGET_i386=false" - "-DCMAKE_LIBTOOL=${darwin.cctools}/bin/libtool" - ]; - - postBuild = '' - rm -fR $out - - paxmark m bin/{lli,llvm-rtdyld} - ''; - - postInstall = "" - + stdenv.lib.optionalString (enableSharedLibraries) '' - moveToOutput "lib/libLLVM-*" "$lib" - moveToOutput "lib/libLLVM.${shlib}" "$lib" - substituteInPlace "$out/lib/cmake/llvm/LLVMExports-release.cmake" \ - --replace "\''${_IMPORT_PREFIX}/lib/libLLVM-" "$lib/lib/libLLVM-" - '' - + stdenv.lib.optionalString (stdenv.isDarwin && enableSharedLibraries) '' - substituteInPlace "$out/lib/cmake/llvm/LLVMExports-release.cmake" \ - --replace "\''${_IMPORT_PREFIX}/lib/libLLVM.dylib" "$lib/lib/libLLVM.dylib" - install_name_tool -id $lib/lib/libLLVM.dylib $lib/lib/libLLVM.dylib - install_name_tool -change @rpath/libLLVM.dylib $lib/lib/libLLVM.dylib $out/bin/llvm-config - ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${shortVersion}.dylib - ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${release_version}.dylib - ''; - - enableParallelBuilding = true; - - passthru.src = src; - - meta = { - description = "Collection of modular and reusable compiler and toolchain technologies"; - homepage = http://llvm.org/; - license = stdenv.lib.licenses.ncsa; - maintainers = with stdenv.lib.maintainers; [ lovek323 raskin viric dtzWill ]; - platforms = stdenv.lib.platforms.all; - }; -} diff --git a/pkgs/development/compilers/llvm/4/clang/default.nix b/pkgs/development/compilers/llvm/4/clang/default.nix new file mode 100644 index 000000000000..5be8ffd91cf1 --- /dev/null +++ b/pkgs/development/compilers/llvm/4/clang/default.nix @@ -0,0 +1,56 @@ +{ stdenv, fetch, cmake, libxml2, libedit, llvm, version, release_version, clang-tools-extra_src, python }: + +let + gcc = if stdenv.cc.isGNU then stdenv.cc.cc else stdenv.cc.cc.gcc; + self = stdenv.mkDerivation { + name = "clang-${version}"; + + unpackPhase = '' + unpackFile ${fetch "cfe" "1lsdyrz82vyrsc7k0ah1zmzzan61s5kakxrkxgfbmklp3pclfkwp"} + mv cfe-${version}* clang + sourceRoot=$PWD/clang + unpackFile ${clang-tools-extra_src} + mv clang-tools-extra-* $sourceRoot/tools/extra + ''; + + buildInputs = [ cmake libedit libxml2 llvm python ]; + + cmakeFlags = [ + "-DCMAKE_CXX_FLAGS=-std=c++11" + ] ++ + # 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 ]; + + postPatch = '' + sed -i -e 's/Args.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/Tools.cpp + sed -i -e 's/DriverArgs.hasArg(options::OPT_nostdlibinc)/true/' lib/Driver/ToolChains.cpp + ''; + + # 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 + ''; + + enableParallelBuilding = true; + + passthru = { + lib = self; # compatibility with gcc, so that `stdenv.cc.cc.lib` works on both + isClang = true; + } // stdenv.lib.optionalAttrs stdenv.isLinux { + inherit gcc; + }; + + meta = { + description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler"; + homepage = http://llvm.org/; + license = stdenv.lib.licenses.ncsa; + platforms = stdenv.lib.platforms.all; + }; + }; +in self diff --git a/pkgs/development/compilers/llvm/4/clang/purity.patch b/pkgs/development/compilers/llvm/4/clang/purity.patch new file mode 100644 index 000000000000..f5fb4c73af47 --- /dev/null +++ b/pkgs/development/compilers/llvm/4/clang/purity.patch @@ -0,0 +1,16 @@ +--- a/lib/Driver/Tools.cpp 2016-08-25 15:48:05.187553443 +0200 ++++ b/lib/Driver/Tools.cpp 2016-08-25 15:48:47.534468882 +0200 +@@ -9420,13 +9420,6 @@ + if (!Args.hasArg(options::OPT_static)) { + if (Args.hasArg(options::OPT_rdynamic)) + CmdArgs.push_back("-export-dynamic"); +- +- if (!Args.hasArg(options::OPT_shared)) { +- const std::string Loader = +- D.DyldPrefix + ToolChain.getDynamicLinker(Args); +- CmdArgs.push_back("-dynamic-linker"); +- CmdArgs.push_back(Args.MakeArgString(Loader)); +- } + } + + CmdArgs.push_back("-o"); diff --git a/pkgs/development/compilers/llvm/4/default.nix b/pkgs/development/compilers/llvm/4/default.nix new file mode 100644 index 000000000000..cbb3852057df --- /dev/null +++ b/pkgs/development/compilers/llvm/4/default.nix @@ -0,0 +1,51 @@ +{ newScope, stdenv, isl, fetchurl, overrideCC, wrapCC, darwin, ccWrapperFun }: +let + callPackage = newScope (self // { inherit stdenv isl release_version version fetch; }); + + release_version = "4.0.0"; + rc = "rc3"; + version = "${release_version}${rc}"; + + fetch = name: sha256: fetchurl { + url = "http://llvm.org/pre-releases/${release_version}/${rc}/${name}-${version}.src.tar.xz"; + # Once 4 is released, use this instead: + # url = "http://llvm.org/releases/${release-version}/${name}-${version}.src.tar.xz"; + inherit sha256; + }; + + compiler-rt_src = fetch "compiler-rt" "0jfqhz95cp15c5688c6l9mr12s0qp86milpcrjlc93dc2jy08ba5"; + clang-tools-extra_src = fetch "clang-tools-extra" "1c9c507w3f5vm153rdd0kmzvv2ski6z439izk01zf5snfwkqxkq8"; + + self = { + llvm = callPackage ./llvm.nix { + inherit compiler-rt_src stdenv; + }; + + clang-unwrapped = callPackage ./clang { + inherit clang-tools-extra_src stdenv; + }; + + clang = wrapCC self.clang-unwrapped; + + libcxxClang = ccWrapperFun { + cc = self.clang-unwrapped; + isClang = true; + inherit (self) stdenv; + /* FIXME is this right? */ + inherit (stdenv.cc) libc nativeTools nativeLibc; + extraPackages = [ self.libcxx self.libcxxabi ]; + }; + + stdenv = overrideCC stdenv self.clang; + + libcxxStdenv = overrideCC stdenv self.libcxxClang; + + lld = callPackage ./lld.nix {}; + + lldb = callPackage ./lldb.nix {}; + + libcxx = callPackage ./libc++ {}; + + libcxxabi = callPackage ./libc++abi.nix {}; + }; +in self diff --git a/pkgs/development/compilers/llvm/4/libc++/default.nix b/pkgs/development/compilers/llvm/4/libc++/default.nix new file mode 100644 index 000000000000..57e064fb79ad --- /dev/null +++ b/pkgs/development/compilers/llvm/4/libc++/default.nix @@ -0,0 +1,42 @@ +{ lib, stdenv, fetch, cmake, llvm, libcxxabi, fixDarwinDylibNames, version }: + +stdenv.mkDerivation rec { + name = "libc++-${version}"; + + src = fetch "libcxx" "15l6bcmwczspbqcq4m2lmzb23g11axr9m8dayn25iys26nn00q43"; + + postUnpack = '' + unpackFile ${libcxxabi.src} + export LIBCXXABI_INCLUDE_DIR="$PWD/$(ls -d libcxxabi-${version}*)/include" + ''; + + preConfigure = '' + # Get headers from the cxxabi source so we can see private headers not installed by the cxxabi package + cmakeFlagsArray=($cmakeFlagsArray -DLIBCXX_CXX_ABI_INCLUDE_PATHS="$LIBCXXABI_INCLUDE_DIR") + ''; + + patchPhase = '' + substituteInPlace lib/CMakeLists.txt --replace "/usr/lib/libc++" "\''${LIBCXX_LIBCXXABI_LIB_PATH}/libc++" + ''; + + buildInputs = [ cmake llvm libcxxabi ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames; + + cmakeFlags = [ + "-DLIBCXX_LIBCXXABI_LIB_PATH=${libcxxabi}/lib" + "-DLIBCXX_LIBCPPABI_VERSION=2" + "-DLIBCXX_CXX_ABI=libcxxabi" + ]; + + enableParallelBuilding = true; + + linkCxxAbi = stdenv.isLinux; + + setupHook = ./setup-hook.sh; + + meta = { + homepage = http://libcxx.llvm.org/; + description = "A new implementation of the C++ standard library, targeting C++11"; + license = with stdenv.lib.licenses; [ ncsa mit ]; + platforms = stdenv.lib.platforms.unix; + }; +} diff --git a/pkgs/development/compilers/llvm/4/libc++/setup-hook.sh b/pkgs/development/compilers/llvm/4/libc++/setup-hook.sh new file mode 100644 index 000000000000..9022fced6ecf --- /dev/null +++ b/pkgs/development/compilers/llvm/4/libc++/setup-hook.sh @@ -0,0 +1,3 @@ +linkCxxAbi="@linkCxxAbi@" +export NIX_CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1" +export NIX_CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}" diff --git a/pkgs/development/compilers/llvm/4/libc++abi.nix b/pkgs/development/compilers/llvm/4/libc++abi.nix new file mode 100644 index 000000000000..fc1a6d84caa8 --- /dev/null +++ b/pkgs/development/compilers/llvm/4/libc++abi.nix @@ -0,0 +1,46 @@ +{ stdenv, cmake, fetch, libcxx, libunwind, llvm, version }: + +stdenv.mkDerivation { + name = "libc++abi-${version}"; + + src = fetch "libcxxabi" "1frj1wz780xcwq77icfclnw6q4c8bkkdzkqsrmfjv9963kjylsy5"; + + buildInputs = [ cmake ] ++ stdenv.lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD) libunwind; + + postUnpack = '' + unpackFile ${libcxx.src} + unpackFile ${llvm.src} + export cmakeFlags="-DLLVM_PATH=$PWD/$(ls -d llvm-*) -DLIBCXXABI_LIBCXX_PATH=$PWD/$(ls -d libcxx-*)" + '' + stdenv.lib.optionalString stdenv.isDarwin '' + export TRIPLE=x86_64-apple-darwin + ''; + + installPhase = if stdenv.isDarwin + then '' + for file in lib/*.dylib; do + # this should be done in CMake, but having trouble figuring out + # the magic combination of necessary CMake variables + # if you fancy a try, take a look at + # http://www.cmake.org/Wiki/CMake_RPATH_handling + install_name_tool -id $out/$file $file + done + make install + install -d 755 $out/include + install -m 644 ../include/*.h $out/include + '' + else '' + install -d -m 755 $out/include $out/lib + install -m 644 lib/libc++abi.so.1.0 $out/lib + install -m 644 ../include/cxxabi.h $out/include + ln -s libc++abi.so.1.0 $out/lib/libc++abi.so + ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1 + ''; + + meta = { + homepage = http://libcxxabi.llvm.org/; + description = "A new implementation of low level support for a standard C++ library"; + license = with stdenv.lib.licenses; [ ncsa mit ]; + maintainers = with stdenv.lib.maintainers; [ vlstill ]; + platforms = stdenv.lib.platforms.unix; + }; +} diff --git a/pkgs/development/compilers/llvm/4/lld.nix b/pkgs/development/compilers/llvm/4/lld.nix new file mode 100644 index 000000000000..7fe08cb02625 --- /dev/null +++ b/pkgs/development/compilers/llvm/4/lld.nix @@ -0,0 +1,32 @@ +{ stdenv +, fetch +, cmake +, zlib +, llvm +, python +, version +}: + +stdenv.mkDerivation { + name = "lld-${version}"; + + src = fetch "lld" "0kmyp7iyf4f76wgy87jczkyhvzhlwfydvxgggl74z0x89xgry745"; + + buildInputs = [ cmake llvm ]; + + outputs = [ "out" "dev" ]; + + enableParallelBuilding = true; + + postInstall = '' + moveToOutput include "$dev" + moveToOutput lib "$dev" + ''; + + meta = { + description = "The LLVM Linker"; + homepage = http://lld.llvm.org/; + license = stdenv.lib.licenses.ncsa; + platforms = stdenv.lib.platforms.all; + }; +} diff --git a/pkgs/development/compilers/llvm/4/lldb.nix b/pkgs/development/compilers/llvm/4/lldb.nix new file mode 100644 index 000000000000..23667e6afcd7 --- /dev/null +++ b/pkgs/development/compilers/llvm/4/lldb.nix @@ -0,0 +1,50 @@ +{ stdenv +, fetch +, cmake +, zlib +, ncurses +, swig +, which +, libedit +, libxml2 +, llvm +, clang-unwrapped +, python +, version +, darwin +}: + +stdenv.mkDerivation { + name = "lldb-${version}"; + + src = fetch "lldb" "1qr0ky7llwgjgx1pzkp3pnz32nb6f7lvg8qg6rp5axhgpkx54hz7"; + + patchPhase = '' + # Fix up various paths that assume llvm and clang are installed in the same place + sed -i 's,".*ClangConfig.cmake","${clang-unwrapped}/lib/cmake/clang/ClangConfig.cmake",' \ + cmake/modules/LLDBStandalone.cmake + sed -i 's,".*tools/clang/include","${clang-unwrapped}/include",' \ + cmake/modules/LLDBStandalone.cmake + sed -i 's,"$.LLVM_LIBRARY_DIR.",${llvm}/lib ${clang-unwrapped}/lib,' \ + cmake/modules/LLDBStandalone.cmake + ''; + + buildInputs = [ cmake python which swig ncurses zlib libedit libxml2 llvm ] + ++ stdenv.lib.optionals stdenv.isDarwin [ darwin.libobjc darwin.apple_sdk.libs.xpc ]; + + CXXFLAGS = "-fno-rtti"; + hardeningDisable = [ "format" ]; + + cmakeFlags = [ + "-DLLDB_DISABLE_LIBEDIT=ON" + ]; + + enableParallelBuilding = true; + + meta = with stdenv.lib; { + description = "A next-generation high-performance debugger"; + homepage = http://llvm.org/; + license = licenses.ncsa; + platforms = platforms.allBut platforms.darwin; + }; +} diff --git a/pkgs/development/compilers/llvm/4/llvm-outputs.patch b/pkgs/development/compilers/llvm/4/llvm-outputs.patch new file mode 100644 index 000000000000..40096fa3497f --- /dev/null +++ b/pkgs/development/compilers/llvm/4/llvm-outputs.patch @@ -0,0 +1,26 @@ +diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp +index 94d426b..37f7794 100644 +--- a/tools/llvm-config/llvm-config.cpp ++++ b/tools/llvm-config/llvm-config.cpp +@@ -333,6 +333,21 @@ int main(int argc, char **argv) { + ActiveIncludeOption = "-I" + ActiveIncludeDir; + } + ++ /// Nix-specific multiple-output handling: override ActiveLibDir if --link-shared ++ if (!IsInDevelopmentTree) { ++ bool WantShared = true; ++ for (int i = 1; i < argc; ++i) { ++ StringRef Arg = argv[i]; ++ if (Arg == "--link-shared") ++ WantShared = true; ++ else if (Arg == "--link-static") ++ WantShared = false; // the last one wins ++ } ++ ++ if (WantShared) ++ ActiveLibDir = std::string("@lib@") + "/lib" + LLVM_LIBDIR_SUFFIX; ++ } ++ + /// We only use `shared library` mode in cases where the static library form + /// of the components provided are not available; note however that this is + /// skipped if we're run from within the build dir. However, once installed, diff --git a/pkgs/development/compilers/llvm/4/llvm.nix b/pkgs/development/compilers/llvm/4/llvm.nix new file mode 100644 index 000000000000..2d36f7cd0fb1 --- /dev/null +++ b/pkgs/development/compilers/llvm/4/llvm.nix @@ -0,0 +1,117 @@ +{ stdenv +, fetch +, fetchpatch +, perl +, groff +, cmake +, python +, libffi +, binutils +, libxml2 +, valgrind +, ncurses +, version +, release_version +, zlib +, compiler-rt_src +, libcxxabi +, debugVersion ? false +, enableSharedLibraries ? true +, darwin +}: + +let + src = fetch "llvm" "0ic3y9gaissi6ixyj9x1c0pq69wfbl2svhprp33av0b58f7wj9v7"; + shlib = if stdenv.isDarwin then "dylib" else "so"; + + # Used when creating a version-suffixed symlink of libLLVM.dylib + shortVersion = with stdenv.lib; + concatStringsSep "." (take 2 (splitString "." release_version)); +in stdenv.mkDerivation rec { + name = "llvm-${version}"; + + unpackPhase = '' + unpackFile ${src} + mv llvm-${version}* llvm + sourceRoot=$PWD/llvm + unpackFile ${compiler-rt_src} + mv compiler-rt-* $sourceRoot/projects/compiler-rt + ''; + + 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 ]; + + 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. + postPatch = stdenv.lib.optionalString stdenv.isDarwin '' + sed -i 's/os_trace(\(.*\)");$/printf(\1\\n");/g' ./projects/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc + '' + # Patch llvm-config to return correct library path based on --link-{shared,static}. + + stdenv.lib.optionalString (enableSharedLibraries) '' + substitute '${./llvm-outputs.patch}' ./llvm-outputs.patch --subst-var lib + patch -p1 < ./llvm-outputs.patch + ''; + + # hacky fix: created binaries need to be run before installation + preBuild = '' + mkdir -p $out/ + ln -sv $PWD/lib $out + ''; + + cmakeFlags = with stdenv; [ + "-DCMAKE_BUILD_TYPE=${if debugVersion then "Debug" else "Release"}" + "-DLLVM_INSTALL_UTILS=ON" # Needed by rustc + "-DLLVM_BUILD_TESTS=ON" + "-DLLVM_ENABLE_FFI=ON" + "-DLLVM_ENABLE_RTTI=ON" + "-DCOMPILER_RT_INCLUDE_TESTS=OFF" # FIXME: requires clang source code + ] ++ stdenv.lib.optional enableSharedLibraries [ + "-DLLVM_LINK_LLVM_DYLIB=ON" + ] ++ stdenv.lib.optional (!isDarwin) + "-DLLVM_BINUTILS_INCDIR=${binutils.dev}/include" + ++ stdenv.lib.optionals (isDarwin) [ + "-DLLVM_ENABLE_LIBCXX=ON" + "-DCAN_TARGET_i386=false" + "-DCMAKE_LIBTOOL=${darwin.cctools}/bin/libtool" + ]; + + postBuild = '' + rm -fR $out + + paxmark m bin/{lli,llvm-rtdyld} + ''; + + postInstall = "" + + stdenv.lib.optionalString (enableSharedLibraries) '' + moveToOutput "lib/libLLVM-*" "$lib" + moveToOutput "lib/libLLVM.${shlib}" "$lib" + substituteInPlace "$out/lib/cmake/llvm/LLVMExports-release.cmake" \ + --replace "\''${_IMPORT_PREFIX}/lib/libLLVM-" "$lib/lib/libLLVM-" + '' + + stdenv.lib.optionalString (stdenv.isDarwin && enableSharedLibraries) '' + substituteInPlace "$out/lib/cmake/llvm/LLVMExports-release.cmake" \ + --replace "\''${_IMPORT_PREFIX}/lib/libLLVM.dylib" "$lib/lib/libLLVM.dylib" + install_name_tool -id $lib/lib/libLLVM.dylib $lib/lib/libLLVM.dylib + install_name_tool -change @rpath/libLLVM.dylib $lib/lib/libLLVM.dylib $out/bin/llvm-config + ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${shortVersion}.dylib + ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${release_version}.dylib + ''; + + enableParallelBuilding = true; + + passthru.src = src; + + meta = { + description = "Collection of modular and reusable compiler and toolchain technologies"; + homepage = http://llvm.org/; + license = stdenv.lib.licenses.ncsa; + maintainers = with stdenv.lib.maintainers; [ lovek323 raskin viric dtzWill ]; + platforms = stdenv.lib.platforms.all; + }; +} -- cgit 1.4.1