From 9d8ad57abc5462edb246bc6a27f38cc7cf777a02 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Sat, 18 Feb 2017 13:53:46 -0600 Subject: [PATCH 1/6] llvm-4.0: init at rc2 in preparation for release. Also adds 'lld'. --- .../compilers/llvm/4.0/clang/default.nix | 56 +++++++++ .../compilers/llvm/4.0/clang/purity.patch | 16 +++ .../compilers/llvm/4.0/default.nix | 51 ++++++++ .../compilers/llvm/4.0/libc++/darwin.patch | 39 ++++++ .../compilers/llvm/4.0/libc++/default.nix | 40 ++++++ .../compilers/llvm/4.0/libc++/setup-hook.sh | 3 + .../compilers/llvm/4.0/libc++abi.nix | 45 +++++++ pkgs/development/compilers/llvm/4.0/lld.nix | 32 +++++ pkgs/development/compilers/llvm/4.0/lldb.nix | 47 +++++++ .../compilers/llvm/4.0/llvm-outputs.patch | 26 ++++ pkgs/development/compilers/llvm/4.0/llvm.nix | 116 ++++++++++++++++++ pkgs/top-level/all-packages.nix | 8 ++ 12 files changed, 479 insertions(+) create mode 100644 pkgs/development/compilers/llvm/4.0/clang/default.nix create mode 100644 pkgs/development/compilers/llvm/4.0/clang/purity.patch create mode 100644 pkgs/development/compilers/llvm/4.0/default.nix create mode 100644 pkgs/development/compilers/llvm/4.0/libc++/darwin.patch create mode 100644 pkgs/development/compilers/llvm/4.0/libc++/default.nix create mode 100644 pkgs/development/compilers/llvm/4.0/libc++/setup-hook.sh create mode 100644 pkgs/development/compilers/llvm/4.0/libc++abi.nix create mode 100644 pkgs/development/compilers/llvm/4.0/lld.nix create mode 100644 pkgs/development/compilers/llvm/4.0/lldb.nix create mode 100644 pkgs/development/compilers/llvm/4.0/llvm-outputs.patch create mode 100644 pkgs/development/compilers/llvm/4.0/llvm.nix diff --git a/pkgs/development/compilers/llvm/4.0/clang/default.nix b/pkgs/development/compilers/llvm/4.0/clang/default.nix new file mode 100644 index 000000000000..d482f91cb83a --- /dev/null +++ b/pkgs/development/compilers/llvm/4.0/clang/default.nix @@ -0,0 +1,56 @@ +{ stdenv, fetch, cmake, libxml2, libedit, llvm, 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" "1p55db1yfya60r2fnr9bh8pj8fqq5gjc1fnv0c1kmac8yfvwkmkn"} + 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/${version}/lib $out/lib/clang/${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 new file mode 100644 index 000000000000..f5fb4c73af47 --- /dev/null +++ b/pkgs/development/compilers/llvm/4.0/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.0/default.nix b/pkgs/development/compilers/llvm/4.0/default.nix new file mode 100644 index 000000000000..a239825533eb --- /dev/null +++ b/pkgs/development/compilers/llvm/4.0/default.nix @@ -0,0 +1,51 @@ +{ newScope, stdenv, isl, fetchurl, overrideCC, wrapCC, darwin, ccWrapperFun }: +let + callPackage = newScope (self // { inherit stdenv isl version fetch; }); + + version = "4.0.0"; + rc = "rc2"; + + fetch = fetch_v version; + fetch_v = ver: name: sha256: fetchurl { + url = "http://llvm.org/pre-releases/${version}/${rc}/${name}-${version}${rc}.src.tar.xz"; + # Once 4.0 is released, use this instead: + # url = "http://llvm.org/releases/${version}/${name}-${ver}.src.tar.xz"; + inherit sha256; + }; + + compiler-rt_src = fetch "compiler-rt" "07i098rj41h1sq2f30d6161924zr5yd9gx5kans79p7akxxgc0jr"; + clang-tools-extra_src = fetch "clang-tools-extra" "0ypvkv55pw88iaixib29sgz44d4pfs166vpswnrrbkqlhz92ns0z"; + + 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++/darwin.patch b/pkgs/development/compilers/llvm/4.0/libc++/darwin.patch new file mode 100644 index 000000000000..6dd756f01cc2 --- /dev/null +++ b/pkgs/development/compilers/llvm/4.0/libc++/darwin.patch @@ -0,0 +1,39 @@ +--- libcxx-3.8.0.src.org/lib/CMakeLists.txt 2015-12-16 15:41:05.000000000 -0800 ++++ libcxx-3.8.0.src/lib/CMakeLists.txt 2016-06-17 19:40:00.293394500 -0700 +@@ -94,30 +94,30 @@ + add_definitions(-D__STRICT_ANSI__) + add_link_flags( + "-compatibility_version 1" + "-current_version 1" +- "-install_name /usr/lib/libc++.1.dylib" +- "-Wl,-reexport_library,/usr/lib/libc++abi.dylib" ++ "-install_name ${LIBCXX_LIBCXXABI_LIB_PATH}/libc++.1.dylib" ++ "-Wl,-reexport_library,${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib" + "-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++unexp.exp" + "/usr/lib/libSystem.B.dylib") + else() + if ( ${CMAKE_OSX_SYSROOT} ) + list(FIND ${CMAKE_OSX_ARCHITECTURES} "armv7" OSX_HAS_ARMV7) + if (OSX_HAS_ARMV7) + set(OSX_RE_EXPORT_LINE +- "${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib" ++ "${CMAKE_OSX_SYSROOT}${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib" + "-Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++sjlj-abi.exp") + else() + set(OSX_RE_EXPORT_LINE +- "-Wl,-reexport_library,${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib") ++ "-Wl,-reexport_library,${CMAKE_OSX_SYSROOT}${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib") + endif() + else() +- set(OSX_RE_EXPORT_LINE "/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp") ++ set(OSX_RE_EXPORT_LINE "${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp") + endif() + + add_link_flags( + "-compatibility_version 1" +- "-install_name /usr/lib/libc++.1.dylib" ++ "-install_name ${LIBCXX_LIBCXXABI_LIB_PATH}/libc++.1.dylib" + "-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++unexp.exp" + "${OSX_RE_EXPORT_LINE}" + "-Wl,-force_symbols_not_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/notweak.exp" + "-Wl,-force_symbols_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/weak.exp") diff --git a/pkgs/development/compilers/llvm/4.0/libc++/default.nix b/pkgs/development/compilers/llvm/4.0/libc++/default.nix new file mode 100644 index 000000000000..76ca05333231 --- /dev/null +++ b/pkgs/development/compilers/llvm/4.0/libc++/default.nix @@ -0,0 +1,40 @@ +{ lib, stdenv, fetch, cmake, llvm, libcxxabi, fixDarwinDylibNames, version }: + +stdenv.mkDerivation rec { + name = "libc++-${version}"; + + src = fetch "libcxx" "130clvfffqml8hbnlvr596nfjk18n6ifxab27xl66nxhq99wccfn"; + + 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") + ''; + + patches = lib.optional stdenv.isDarwin ./darwin.patch; + + 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 new file mode 100644 index 000000000000..9022fced6ecf --- /dev/null +++ b/pkgs/development/compilers/llvm/4.0/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.0/libc++abi.nix b/pkgs/development/compilers/llvm/4.0/libc++abi.nix new file mode 100644 index 000000000000..52da7cc1988e --- /dev/null +++ b/pkgs/development/compilers/llvm/4.0/libc++abi.nix @@ -0,0 +1,45 @@ +{ stdenv, cmake, fetch, libcxx, libunwind, llvm, version }: + +stdenv.mkDerivation { + name = "libc++abi-${version}"; + + src = fetch "libcxxabi" "09hlqlbxpnqi3449nrk43khp4jgd34xwx406mw6igwl8a673pa85"; + + buildInputs = [ cmake llvm ] ++ stdenv.lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD) libunwind; + + postUnpack = '' + unpackFile ${libcxx.src} + export cmakeFlags="-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 new file mode 100644 index 000000000000..004230ca81ab --- /dev/null +++ b/pkgs/development/compilers/llvm/4.0/lld.nix @@ -0,0 +1,32 @@ +{ stdenv +, fetch +, cmake +, zlib +, llvm +, python +, version +}: + +stdenv.mkDerivation { + name = "lld-${version}"; + + src = fetch "lld" "144vmb13800s33xgd18321lrviw21mjx5dphzszjgvizn4a1sf1p"; + + 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 new file mode 100644 index 000000000000..7bca695fafc1 --- /dev/null +++ b/pkgs/development/compilers/llvm/4.0/lldb.nix @@ -0,0 +1,47 @@ +{ stdenv +, fetch +, cmake +, zlib +, ncurses +, swig +, which +, libedit +, llvm +, clang-unwrapped +, python +, version +}: + +stdenv.mkDerivation { + name = "lldb-${version}"; + + src = fetch "lldb" "0g3il7bz1b0xbcm85c6r64vgn8ppxigi1s39s3xzga4pkllf7k07"; + + 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 llvm ]; + + CXXFLAGS = "-fno-rtti"; + hardeningDisable = [ "format" ]; + + cmakeFlags = [ + "-DLLDB_DISABLE_LIBEDIT=1" + ]; + + enableParallelBuilding = true; + + meta = { + description = "A next-generation high-performance debugger"; + homepage = http://llvm.org/; + license = stdenv.lib.licenses.ncsa; + platforms = stdenv.lib.platforms.all; + }; +} diff --git a/pkgs/development/compilers/llvm/4.0/llvm-outputs.patch b/pkgs/development/compilers/llvm/4.0/llvm-outputs.patch new file mode 100644 index 000000000000..40096fa3497f --- /dev/null +++ b/pkgs/development/compilers/llvm/4.0/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.0/llvm.nix b/pkgs/development/compilers/llvm/4.0/llvm.nix new file mode 100644 index 000000000000..0139f40791cc --- /dev/null +++ b/pkgs/development/compilers/llvm/4.0/llvm.nix @@ -0,0 +1,116 @@ +{ stdenv +, fetch +, fetchpatch +, perl +, groff +, cmake +, python +, libffi +, binutils +, libxml2 +, valgrind +, ncurses +, version +, zlib +, compiler-rt_src +, libcxxabi +, debugVersion ? false +, enableSharedLibraries ? true +, darwin +}: + +let + src = fetch "llvm" "1qfvvblca2aa5shamz66132k30hmpq2mkpfn172xzzlm6znzlmr2"; + 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 "." 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-${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 ]; + platforms = stdenv.lib.platforms.all; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 0bfb6d92a8e8..95a19240a0a8 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -4730,6 +4730,7 @@ with pkgs; clang = llvmPackages.clang; + clang_40 = llvmPackages_40.clang; clang_39 = llvmPackages_39.clang; clang_38 = llvmPackages_38.clang; clang_37 = llvmPackages_37.clang; @@ -5277,10 +5278,13 @@ with pkgs; lizardfs = callPackage ../tools/filesystems/lizardfs { }; + lld = llvmPackages_40.lld; + lldb = llvmPackages.lldb; llvm = llvmPackages.llvm; + llvm_40 = llvmPackages_40.llvm; llvm_39 = llvmPackages_39.llvm; llvm_38 = llvmPackages_38.llvm; llvm_37 = llvmPackages_37.llvm; @@ -5318,6 +5322,10 @@ with pkgs; inherit (stdenvAdapters) overrideCC; }; + llvmPackages_40 = callPackage ../development/compilers/llvm/4.0 { + inherit (stdenvAdapters) overrideCC; + }; + manticore = callPackage ../development/compilers/manticore { }; mentorToolchains = recurseIntoAttrs ( From 2ebb086df167d7881b82af9585c65d43c440ff86 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Sat, 18 Feb 2017 17:30:08 -0600 Subject: [PATCH 2/6] llvm-4.0/libc++abi: Remove LLVM build dep to unbreak Darwin evaluation. --- pkgs/development/compilers/llvm/4.0/libc++abi.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/development/compilers/llvm/4.0/libc++abi.nix b/pkgs/development/compilers/llvm/4.0/libc++abi.nix index 52da7cc1988e..362663ed443f 100644 --- a/pkgs/development/compilers/llvm/4.0/libc++abi.nix +++ b/pkgs/development/compilers/llvm/4.0/libc++abi.nix @@ -5,11 +5,12 @@ stdenv.mkDerivation { src = fetch "libcxxabi" "09hlqlbxpnqi3449nrk43khp4jgd34xwx406mw6igwl8a673pa85"; - buildInputs = [ cmake llvm ] ++ stdenv.lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD) libunwind; + buildInputs = [ cmake ] ++ stdenv.lib.optional (!stdenv.isDarwin && !stdenv.isFreeBSD) libunwind; postUnpack = '' unpackFile ${libcxx.src} - export cmakeFlags="-DLIBCXXABI_LIBCXX_PATH=$PWD/$(ls -d libcxx-*)" + 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 ''; From 753058baef591f68767de08984a463f50ccd8bf2 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Sun, 19 Feb 2017 13:18:01 -0600 Subject: [PATCH 3/6] libc++-4.0rc2: Use substituteInPlace instead of the Darwin patch. On 3.9 the substituteInPlace is equivalent to the patch, hopefully this is a slightly more robust way to make the same substitution for the 4.0 version. Apply this change unconditionally for consistency across versions, even if the changed strings are unused on other platforms. Discussion: https://github.com/NixOS/nixpkgs/pull/22970#discussion_r101926144 --- .../compilers/llvm/4.0/libc++/darwin.patch | 39 ------------------- .../compilers/llvm/4.0/libc++/default.nix | 4 +- 2 files changed, 3 insertions(+), 40 deletions(-) delete mode 100644 pkgs/development/compilers/llvm/4.0/libc++/darwin.patch diff --git a/pkgs/development/compilers/llvm/4.0/libc++/darwin.patch b/pkgs/development/compilers/llvm/4.0/libc++/darwin.patch deleted file mode 100644 index 6dd756f01cc2..000000000000 --- a/pkgs/development/compilers/llvm/4.0/libc++/darwin.patch +++ /dev/null @@ -1,39 +0,0 @@ ---- libcxx-3.8.0.src.org/lib/CMakeLists.txt 2015-12-16 15:41:05.000000000 -0800 -+++ libcxx-3.8.0.src/lib/CMakeLists.txt 2016-06-17 19:40:00.293394500 -0700 -@@ -94,30 +94,30 @@ - add_definitions(-D__STRICT_ANSI__) - add_link_flags( - "-compatibility_version 1" - "-current_version 1" -- "-install_name /usr/lib/libc++.1.dylib" -- "-Wl,-reexport_library,/usr/lib/libc++abi.dylib" -+ "-install_name ${LIBCXX_LIBCXXABI_LIB_PATH}/libc++.1.dylib" -+ "-Wl,-reexport_library,${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib" - "-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++unexp.exp" - "/usr/lib/libSystem.B.dylib") - else() - if ( ${CMAKE_OSX_SYSROOT} ) - list(FIND ${CMAKE_OSX_ARCHITECTURES} "armv7" OSX_HAS_ARMV7) - if (OSX_HAS_ARMV7) - set(OSX_RE_EXPORT_LINE -- "${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib" -+ "${CMAKE_OSX_SYSROOT}${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib" - "-Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++sjlj-abi.exp") - else() - set(OSX_RE_EXPORT_LINE -- "-Wl,-reexport_library,${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib") -+ "-Wl,-reexport_library,${CMAKE_OSX_SYSROOT}${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib") - endif() - else() -- set(OSX_RE_EXPORT_LINE "/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp") -+ set(OSX_RE_EXPORT_LINE "${LIBCXX_LIBCXXABI_LIB_PATH}/libc++abi.dylib -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp") - endif() - - add_link_flags( - "-compatibility_version 1" -- "-install_name /usr/lib/libc++.1.dylib" -+ "-install_name ${LIBCXX_LIBCXXABI_LIB_PATH}/libc++.1.dylib" - "-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++unexp.exp" - "${OSX_RE_EXPORT_LINE}" - "-Wl,-force_symbols_not_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/notweak.exp" - "-Wl,-force_symbols_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/weak.exp") diff --git a/pkgs/development/compilers/llvm/4.0/libc++/default.nix b/pkgs/development/compilers/llvm/4.0/libc++/default.nix index 76ca05333231..9f950e601b21 100644 --- a/pkgs/development/compilers/llvm/4.0/libc++/default.nix +++ b/pkgs/development/compilers/llvm/4.0/libc++/default.nix @@ -15,7 +15,9 @@ stdenv.mkDerivation rec { cmakeFlagsArray=($cmakeFlagsArray -DLIBCXX_CXX_ABI_INCLUDE_PATHS="$LIBCXXABI_INCLUDE_DIR") ''; - patches = lib.optional stdenv.isDarwin ./darwin.patch; + patchPhase = '' + substituteInPlace lib/CMakeLists.txt --replace "/usr/lib/libc++" "\''${LIBCXX_LIBCXXABI_LIB_PATH}/libc++" + ''; buildInputs = [ cmake llvm libcxxabi ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames; From a5aedafbd9819880aa27c455345cfa7c26a68424 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Sun, 19 Feb 2017 14:33:47 -0600 Subject: [PATCH 4/6] llvm-4.0: Distinguish release version, fix naming to clarify rc2. --- .../development/compilers/llvm/4.0/clang/default.nix | 4 ++-- pkgs/development/compilers/llvm/4.0/default.nix | 12 ++++++------ pkgs/development/compilers/llvm/4.0/llvm.nix | 5 +++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/pkgs/development/compilers/llvm/4.0/clang/default.nix b/pkgs/development/compilers/llvm/4.0/clang/default.nix index d482f91cb83a..f566cd6d21c2 100644 --- a/pkgs/development/compilers/llvm/4.0/clang/default.nix +++ b/pkgs/development/compilers/llvm/4.0/clang/default.nix @@ -1,4 +1,4 @@ -{ stdenv, fetch, cmake, libxml2, libedit, llvm, version, clang-tools-extra_src, python }: +{ 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; @@ -33,7 +33,7 @@ let # Clang expects to find sanitizer libraries in its own prefix postInstall = '' ln -sv ${llvm}/lib/LLVMgold.so $out/lib - ln -sv ${llvm}/lib/clang/${version}/lib $out/lib/clang/${version}/ + ln -sv ${llvm}/lib/clang/${release_version}/lib $out/lib/clang/${release_version}/ ln -sv $out/bin/clang $out/bin/cpp ''; diff --git a/pkgs/development/compilers/llvm/4.0/default.nix b/pkgs/development/compilers/llvm/4.0/default.nix index a239825533eb..f407b2cdc9f5 100644 --- a/pkgs/development/compilers/llvm/4.0/default.nix +++ b/pkgs/development/compilers/llvm/4.0/default.nix @@ -1,15 +1,15 @@ { newScope, stdenv, isl, fetchurl, overrideCC, wrapCC, darwin, ccWrapperFun }: let - callPackage = newScope (self // { inherit stdenv isl version fetch; }); + callPackage = newScope (self // { inherit stdenv isl release_version version fetch; }); - version = "4.0.0"; + release_version = "4.0.0"; rc = "rc2"; + version = "${release_version}${rc}"; - fetch = fetch_v version; - fetch_v = ver: name: sha256: fetchurl { - url = "http://llvm.org/pre-releases/${version}/${rc}/${name}-${version}${rc}.src.tar.xz"; + 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/${version}/${name}-${ver}.src.tar.xz"; + # url = "http://llvm.org/releases/${release-version}/${name}-${version}.src.tar.xz"; inherit sha256; }; diff --git a/pkgs/development/compilers/llvm/4.0/llvm.nix b/pkgs/development/compilers/llvm/4.0/llvm.nix index 0139f40791cc..d54390e5ee8d 100644 --- a/pkgs/development/compilers/llvm/4.0/llvm.nix +++ b/pkgs/development/compilers/llvm/4.0/llvm.nix @@ -11,6 +11,7 @@ , valgrind , ncurses , version +, release_version , zlib , compiler-rt_src , libcxxabi @@ -25,7 +26,7 @@ let # Used when creating a version-suffixed symlink of libLLVM.dylib shortVersion = with stdenv.lib; - concatStringsSep "." (take 2 (splitString "." version)); + concatStringsSep "." (take 2 (splitString "." release_version)); in stdenv.mkDerivation rec { name = "llvm-${version}"; @@ -99,7 +100,7 @@ in stdenv.mkDerivation rec { 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-${version}.dylib + ln -s $lib/lib/libLLVM.dylib $lib/lib/libLLVM-${release_version}.dylib ''; enableParallelBuilding = true; From 7ea342708afd4dc4a48064d1b6067b8584d326e8 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Sun, 19 Feb 2017 12:11:48 -0600 Subject: [PATCH 5/6] lldb-4.0rc2: Try to fix but ultimately disable on Darwin. Currently it's failing due to needing Foundation.h, but LLDB on Nix-Darwin is a bit sketchy anyway due to code-signing requirements. --- pkgs/development/compilers/llvm/4.0/lldb.nix | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pkgs/development/compilers/llvm/4.0/lldb.nix b/pkgs/development/compilers/llvm/4.0/lldb.nix index 7bca695fafc1..f37e6fdfafc2 100644 --- a/pkgs/development/compilers/llvm/4.0/lldb.nix +++ b/pkgs/development/compilers/llvm/4.0/lldb.nix @@ -6,10 +6,12 @@ , swig , which , libedit +, libxml2 , llvm , clang-unwrapped , python , version +, darwin }: stdenv.mkDerivation { @@ -27,21 +29,22 @@ stdenv.mkDerivation { cmake/modules/LLDBStandalone.cmake ''; - buildInputs = [ cmake python which swig ncurses zlib libedit llvm ]; + 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=1" + "-DLLDB_DISABLE_LIBEDIT=ON" ]; enableParallelBuilding = true; - meta = { + meta = with stdenv.lib; { description = "A next-generation high-performance debugger"; homepage = http://llvm.org/; - license = stdenv.lib.licenses.ncsa; - platforms = stdenv.lib.platforms.all; + license = licenses.ncsa; + platforms = platforms.allBut platforms.darwin; }; } From e55b829c6925421f732d30d622da4af0681a56ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= Date: Sun, 26 Feb 2017 09:35:38 +0100 Subject: [PATCH 6/6] llvmPackages: mark 4.0 as lowPrio For example, "nix-env -i clang" should not install the RC version. /cc #22970. --- pkgs/top-level/all-packages.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 95a19240a0a8..31f898fb9228 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -4730,7 +4730,7 @@ with pkgs; clang = llvmPackages.clang; - clang_40 = llvmPackages_40.clang; + clang_40 = lowPrio llvmPackages_40.clang; clang_39 = llvmPackages_39.clang; clang_38 = llvmPackages_38.clang; clang_37 = llvmPackages_37.clang; @@ -5278,13 +5278,13 @@ with pkgs; lizardfs = callPackage ../tools/filesystems/lizardfs { }; - lld = llvmPackages_40.lld; + lld = lowPrio llvmPackages_40.lld; lldb = llvmPackages.lldb; llvm = llvmPackages.llvm; - llvm_40 = llvmPackages_40.llvm; + llvm_40 = lowPrio llvmPackages_40.llvm; llvm_39 = llvmPackages_39.llvm; llvm_38 = llvmPackages_38.llvm; llvm_37 = llvmPackages_37.llvm;