Merge #22970: add 4.0-rc2 version of llvmPackages

This commit is contained in:
Vladimír Čunát 2017-02-26 09:37:31 +01:00
commit d444aa4ade
No known key found for this signature in database
GPG key ID: E747DF1F9575A3AA
11 changed files with 447 additions and 0 deletions

View file

@ -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" "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/${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

View file

@ -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");

View file

@ -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 = "rc2";
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" "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

View file

@ -0,0 +1,42 @@
{ 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")
'';
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;
};
}

View file

@ -0,0 +1,3 @@
linkCxxAbi="@linkCxxAbi@"
export NIX_CXXSTDLIB_COMPILE+=" -isystem @out@/include/c++/v1"
export NIX_CXXSTDLIB_LINK=" -stdlib=libc++${linkCxxAbi:+" -lc++abi"}"

View file

@ -0,0 +1,46 @@
{ stdenv, cmake, fetch, libcxx, libunwind, llvm, version }:
stdenv.mkDerivation {
name = "libc++abi-${version}";
src = fetch "libcxxabi" "09hlqlbxpnqi3449nrk43khp4jgd34xwx406mw6igwl8a673pa85";
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;
};
}

View file

@ -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;
};
}

View file

@ -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" "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 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;
};
}

View file

@ -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,

View file

@ -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" "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 "." 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 ];
platforms = stdenv.lib.platforms.all;
};
}

View file

@ -4738,6 +4738,7 @@ with pkgs;
clang = llvmPackages.clang;
clang_40 = lowPrio llvmPackages_40.clang;
clang_39 = llvmPackages_39.clang;
clang_38 = llvmPackages_38.clang;
clang_37 = llvmPackages_37.clang;
@ -5292,10 +5293,13 @@ with pkgs;
lizardfs = callPackage ../tools/filesystems/lizardfs { };
lld = lowPrio llvmPackages_40.lld;
lldb = llvmPackages.lldb;
llvm = llvmPackages.llvm;
llvm_40 = lowPrio llvmPackages_40.llvm;
llvm_39 = llvmPackages_39.llvm;
llvm_38 = llvmPackages_38.llvm;
llvm_37 = llvmPackages_37.llvm;
@ -5333,6 +5337,10 @@ with pkgs;
inherit (stdenvAdapters) overrideCC;
};
llvmPackages_40 = callPackage ../development/compilers/llvm/4.0 {
inherit (stdenvAdapters) overrideCC;
};
manticore = callPackage ../development/compilers/manticore { };
mentorToolchains = recurseIntoAttrs (