llvm: Split llvmFull into separate derivations

Now most packages in the llvm suite are built as separate derivations.
The exceptions are:

* compiler-rt must currently be built with llvm. This increases llvm's
  size by 6 MB
* clang-tools-extra must be built with clang

In addition, the top-level llvm attribute is defaulted to llvm 3.4, and
llvm 3.3 must be accessed by the llvm_33 attribute. This is to make the
out-of-date packages obvious in the hope that eventually all will be
updated to work with 3.4 and 3.3 can be removed. I think we should keep
this policy in the future (latest llvm gets top-level name, the rest are
versioned until they can be removed).

The llvm packages (except libc++, which exception I will try to remove
on the next update) can all be accessed via the llvmPackages attribute,
and there are also aliases for the packages that already existed (llvm,
clang, and dragonegg).

Signed-off-by: Shea Levy <shea@shealevy.com>
This commit is contained in:
Shea Levy 2014-01-20 20:19:53 -05:00
parent 204ec0cd43
commit fea2266290
17 changed files with 282 additions and 133 deletions

View File

@ -1,4 +1,4 @@
{ clangStdenv, fetchgit, llvmFull }:
{ clangStdenv, fetchgit, llvm, clang }:
clangStdenv.mkDerivation {
name = "emacs-clang-complete-async-20130218";
@ -8,7 +8,7 @@ clangStdenv.mkDerivation {
sha256 = "1c8zqi6axbsb951azz9iqx3j52j30nd9ypv396hvids3g02cirrf";
};
buildInputs = [ llvmFull ];
buildInputs = [ llvm clang.clang ];
installPhase = ''
mkdir -p $out/bin

View File

@ -1,27 +1,20 @@
{ stdenv, fetchurl, perl, groff, cmake, python, libffi, binutils, version }:
with { inherit (stdenv.lib) optional optionals; };
assert version == "3.4" || version == "3.3";
stdenv.mkDerivation rec {
{ stdenv, fetchurl, perl, groff, cmake, python, libffi, binutils }:
let
version = "3.3";
in stdenv.mkDerivation rec {
name = "llvm-${version}";
src = fetchurl {
url = "http://llvm.org/releases/${version}/llvm-${version}.src.tar.gz";
sha256 =
if version == "3.4" then "0a169ba045r4apb9cv6ncrwl83l7yiajnzirkcdlhj1cd4nn3995"
else /*3.3*/ "0y3mfbb5qzcpw3v5qncn69x1hdrrrfirgs82ypi2annhf0g6nxk8";
url = "http://llvm.org/releases/${version}/llvm-${version}.src.tar.gz";
sha256 = "0y3mfbb5qzcpw3v5qncn69x1hdrrrfirgs82ypi2annhf0g6nxk8";
};
patches = optionals (version == "3.3") [
patches = [
./more-memory-for-bugpoint.patch # The default rlimits in 3.3 are too low for shared libraries.
./no-rule-aarch64.patch # http://llvm.org/bugs/show_bug.cgi?id=16625
];
# libffi was propagated before, but it wasn't even being used, so
# unless something needs it just an input is fine.
buildInputs = [ perl groff cmake python libffi ]; # ToDo: polly, libc++; enable cxx11?
buildInputs = [ perl groff cmake python libffi ];
# hacky fix: created binaries need to be run before installation
preBuild = let LD = if stdenv.isDarwin then "DYLD" else "LD";
@ -31,9 +24,8 @@ stdenv.mkDerivation rec {
"-DCMAKE_BUILD_TYPE=Release"
"-DLLVM_ENABLE_FFI=ON"
"-DLLVM_BINUTILS_INCDIR=${binutils}/include"
]
++ optional (version == "3.3") "-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=R600" # for mesa
++ optional (!isDarwin) "-DBUILD_SHARED_LIBS=ON";
"-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=R600" # for mesa
] ++ stdenv.lib.optional (!isDarwin) "-DBUILD_SHARED_LIBS=ON";
enableParallelBuilding = true;

View File

@ -0,0 +1,8 @@
diff -Naur clang-3.4-orig/tools/extra/CMakeLists.txt clang-3.4/tools/extra/CMakeLists.txt
--- clang-3.4-orig/tools/extra/CMakeLists.txt 2013-11-07 19:08:23.000000000 -0500
+++ clang-3.4/tools/extra/CMakeLists.txt 2014-01-20 11:47:22.678435223 -0500
@@ -1,3 +1,4 @@
+include(CheckLibraryExists)
check_library_exists(edit el_init "" HAVE_LIBEDIT)
add_subdirectory(clang-apply-replacements)

View File

@ -0,0 +1,41 @@
{ stdenv, fetch, cmake, libxml2, libedit, llvm, version }:
stdenv.mkDerivation {
name = "clang-${version}";
unpackPhase = ''
unpackFile ${fetch "clang" "06rb4j1ifbznl3gfhl98s7ilj0ns01p7y7zap4p7ynmqnc6pia92"}
mv clang-${version} clang
sourceRoot=$PWD/clang
unpackFile ${fetch "clang-tools-extra" "1d1822mwxxl9agmyacqjw800kzz5x8xr0sdmi8fgx5xfa5sii1ds"}
mv clang-tools-extra-${version} $sourceRoot/tools/extra
# !!! Hopefully won't be needed for 3.5
unpackFile ${llvm.src}
export cmakeFlags="$cmakeFlags -DCLANG_PATH_TO_LLVM_SOURCE=$PWD/llvm-${version}"
(cd llvm-${version} && patch -Np1 -i ${./llvm-separate-build.patch})
'';
patches = [ ./clang-separate-build.patch ];
buildInputs = [ cmake libedit libxml2 ];
cmakeFlags = [
"-DCMAKE_BUILD_TYPE=Release"
"-DGCC_INSTALL_PREFIX=${stdenv.gcc.gcc}"
"-DC_INCLUDE_DIRS=${stdenv.gcc.libc}/include/"
"-DCMAKE_CXX_FLAGS=-std=c++11"
"-DCLANG_PATH_TO_LLVM_BUILD=${llvm}"
];
passthru.gcc = stdenv.gcc.gcc;
enableParallelBuilding = true;
meta = {
description = "A c, c++, objective-c, and objective-c++ frontend for the llvm compiler";
homepage = http://llvm.org/;
license = stdenv.lib.licenses.bsd3;
maintainers = [ stdenv.lib.maintainers.shlevy ];
platforms = stdenv.lib.platforms.all;
};
}

View File

@ -0,0 +1,25 @@
{ newScope, stdenv, isl, fetchurl }:
let
callPackage = newScope (self // { inherit stdenv isl version fetch; });
version = "3.4";
fetch = name: sha256: fetchurl {
url = "http://llvm.org/releases/${version}/${name}-${version}.src.tar.gz";
inherit sha256;
};
self = {
llvm = callPackage ./llvm.nix {};
clang = callPackage ./clang.nix {};
lld = callPackage ./lld.nix {};
lldb = callPackage ./lldb.nix {};
polly = callPackage ./polly.nix {};
dragonegg = callPackage ./dragonegg.nix {};
};
in self

View File

@ -1,13 +1,9 @@
{stdenv, fetchurl, llvm, gmp, mpfr, mpc, ncurses, zlib}:
{stdenv, fetch, llvm, gmp, mpfr, mpc, ncurses, zlib, version}:
stdenv.mkDerivation rec {
version = "3.4";
name = "dragonegg-${version}";
src = fetchurl {
url = "http://llvm.org/releases/${version}/${name}.src.tar.gz";
sha256 = "1733czbvby1ww3xkwcwmm0km0bpwhfyxvf56wb0zv5gksp3kbgrl";
};
src = fetch "dragonegg" "1733czbvby1ww3xkwcwmm0km0bpwhfyxvf56wb0zv5gksp3kbgrl";
# The gcc the plugin will be built for (the same used building dragonegg)
GCC = "gcc";
@ -24,7 +20,7 @@ stdenv.mkDerivation rec {
homepage = http://dragonegg.llvm.org/;
description = "gcc plugin that replaces gcc's optimizers and code generators by those in LLVM";
license = "GPLv2+";
maintainers = with stdenv.lib.maintainers; [viric];
maintainers = with stdenv.lib.maintainers; [viric shlevy];
platforms = with stdenv.lib.platforms; linux;
};
}

View File

@ -0,0 +1,31 @@
{ stdenv, fetch, cmake, llvm, ncurses, zlib, python, version }:
stdenv.mkDerivation {
name = "lld-${version}";
src = fetch "lld" "1sd4scqynryfrmcc4h0ljgwn2dgjmbbmf38z50ya6l0janpd2nxz";
preUnpack = ''
# !!! Hopefully won't be needed for 3.5
unpackFile ${llvm.src}
export cmakeFlags="$cmakeFlags -DLLD_PATH_TO_LLVM_SOURCE=$PWD/llvm-${version}"
'';
buildInputs = [ cmake ncurses zlib python ];
cmakeFlags = [
"-DCMAKE_BUILD_TYPE=Release"
"-DCMAKE_CXX_FLAGS=-std=c++11"
"-DLLD_PATH_TO_LLVM_BUILD=${llvm}"
];
enableParallelBuilding = true;
meta = {
description = "A set of modular code for creating linker tools";
homepage = http://llvm.org/;
license = stdenv.lib.licenses.bsd3;
maintainers = [ stdenv.lib.maintainers.shlevy ];
platforms = stdenv.lib.platforms.all;
};
}

View File

@ -0,0 +1,44 @@
{ stdenv
, fetch
, cmake
, zlib
, ncurses
, swig
, which
, libedit
, llvm
, clang
, python
, version
}:
stdenv.mkDerivation {
name = "lldb-${version}";
src = fetch "lldb" "0h8cmjrhjhigk7k2qll1pcf6jfgmbdzkzfz2i048pkfg851s0x4g";
patchPhase = ''
sed -i 's|/usr/bin/env||' \
scripts/Python/finish-swig-Python-LLDB.sh \
scripts/Python/build-swig-Python.sh
'';
buildInputs = [ cmake python which swig ncurses zlib libedit ];
cmakeFlags = [
"-DCMAKE_BUILD_TYPE=Release"
"-DCMAKE_CXX_FLAGS=-std=c++11"
"-DLLDB_PATH_TO_LLVM_BUILD=${llvm}"
"-DLLDB_PATH_TO_CLANG_BUILD=${clang}"
];
enableParallelBuilding = true;
meta = {
description = "A next-generation high-performance debugger";
homepage = http://llvm.org/;
license = stdenv.lib.licenses.bsd3;
maintainers = [ stdenv.lib.maintainers.shlevy ];
platforms = stdenv.lib.platforms.all;
};
}

View File

@ -0,0 +1,12 @@
diff -Naur llvm-3.4-orig/cmake/modules/TableGen.cmake llvm-3.4/cmake/modules/TableGen.cmake
--- llvm-3.4-orig/cmake/modules/TableGen.cmake 2013-10-06 21:00:07.000000000 -0400
+++ llvm-3.4/cmake/modules/TableGen.cmake 2014-01-20 13:06:55.273022149 -0500
@@ -78,8 +78,6 @@
endif()
macro(add_tablegen target project)
- set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_TOOLS_BINARY_DIR})
-
set(${target}_OLD_LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS})
set(LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS} TableGen)
add_llvm_utility(${target} ${ARGN})

View File

@ -0,0 +1,55 @@
{ stdenv
, fetch
, perl
, groff
, cmake
, python
, libffi
, binutils
, libxml2
, valgrind
, ncurses
, version
}:
let
src = fetch "llvm" "0a169ba045r4apb9cv6ncrwl83l7yiajnzirkcdlhj1cd4nn3995";
in stdenv.mkDerivation rec {
name = "llvm-${version}";
unpackPhase = ''
unpackFile ${src}
mv llvm-${version} llvm
sourceRoot=$PWD/llvm
unpackFile ${fetch "compiler-rt" "0p5b6varxdqn7q3n77xym63hhq4qqxd2981pfpa65r1w72qqjz7k"}
mv compiler-rt-${version} $sourceRoot/projects/compiler-rt
'';
buildInputs = [ perl groff cmake libxml2 python libffi valgrind ncurses ];
# hacky fix: created binaries need to be run before installation
preBuild = ''
mkdir -p $out/
ln -sv $PWD/lib $out
'';
postBuild = "rm -fR $out";
cmakeFlags = with stdenv; [
"-DCMAKE_BUILD_TYPE=Release"
"-DLLVM_ENABLE_FFI=ON"
"-DLLVM_BINUTILS_INCDIR=${binutils}/include"
"-DCMAKE_CXX_FLAGS=-std=c++11"
] ++ stdenv.lib.optional (!isDarwin) "-DBUILD_SHARED_LIBS=ON";
enableParallelBuilding = true;
passthru.src = src;
meta = {
description = "Collection of modular and reusable compiler and toolchain technologies";
homepage = http://llvm.org/;
license = stdenv.lib.licenses.bsd3;
maintainers = with stdenv.lib.maintainers; [ shlevy lovek323 raskin viric ];
platforms = stdenv.lib.platforms.all;
};
}

View File

@ -0,0 +1,12 @@
diff -Naur polly-3.4-orig/CMakeLists.txt polly-3.4/CMakeLists.txt
--- polly-3.4-orig/CMakeLists.txt 2013-11-21 06:51:46.000000000 -0500
+++ polly-3.4/CMakeLists.txt 2014-01-20 18:49:34.907919933 -0500
@@ -53,7 +53,7 @@
execute_process(COMMAND "${LLVM_INSTALL_ROOT}/bin/llvm-config" --cxxflags
OUTPUT_VARIABLE LLVM_CXX_FLAGS
OUTPUT_STRIP_TRAILING_WHITESPACE)
- set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${LLVM_CXX_FLAGS})
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LLVM_CXX_FLAGS}")
endif(NOT DEFINED LLVM_MAIN_SRC_DIR)
set(POLLY_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})

View File

@ -0,0 +1,27 @@
{ stdenv, fetch, cmake, isl, python, gmp, llvm, version }:
stdenv.mkDerivation {
name = "polly-${version}";
src = fetch "polly" "1rqflmgzg1vzjm0r32c5ck8x3q0qm3g0hh8ggbjazh6x7nvmy6lz";
patches = [ ./polly-separate-build.patch ];
buildInputs = [ cmake isl python gmp ];
cmakeFlags = [
"-DCMAKE_BUILD_TYPE=Release"
"-DCMAKE_CXX_FLAGS=-std=c++11"
"-DLLVM_INSTALL_ROOT=${llvm}"
];
enableParallelBuilding = true;
meta = {
description = "A polyhedral optimizer for llvm";
homepage = http://llvm.org/;
license = stdenv.lib.licenses.bsd3;
maintainers = [ stdenv.lib.maintainers.shlevy ];
platforms = stdenv.lib.platforms.all;
};
}

View File

@ -1,89 +0,0 @@
{ stdenv
, fetchurl
, perl, groff
, cmake
, libxml2
, python
, libffi
, zlib
, ncurses
, isl
, gmp
, doxygen
, binutils
, swig
, which
, libedit
, valgrind
}:
let
version = "3.4";
fetch = name: sha256: fetchurl {
url = "http://llvm.org/releases/${version}/${name}-${version}.src.tar.gz";
inherit sha256;
};
inherit (stdenv.lib) concatStrings mapAttrsToList;
in stdenv.mkDerivation {
name = "llvm-full-${version}";
unpackPhase = ''
unpackFile ${fetch "llvm" "0a169ba045r4apb9cv6ncrwl83l7yiajnzirkcdlhj1cd4nn3995"}
mv llvm-${version} llvm
sourceRoot=$PWD/llvm
${concatStrings (mapAttrsToList (name: { location, sha256 }: ''
unpackFile ${fetch name sha256}
mv ${name}-${version} $sourceRoot/${location}
'') {
clang = { location = "tools/clang"; sha256 = "06rb4j1ifbznl3gfhl98s7ilj0ns01p7y7zap4p7ynmqnc6pia92"; };
clang-tools-extra = { location = "tools/clang/tools/extra"; sha256 = "1d1822mwxxl9agmyacqjw800kzz5x8xr0sdmi8fgx5xfa5sii1ds"; };
compiler-rt = { location = "projects/compiler-rt"; sha256 = "0p5b6varxdqn7q3n77xym63hhq4qqxd2981pfpa65r1w72qqjz7k"; };
lld = { location = "tools/lld"; sha256 = "1sd4scqynryfrmcc4h0ljgwn2dgjmbbmf38z50ya6l0janpd2nxz"; };
lldb = { location = "tools/lldb"; sha256 = "0h8cmjrhjhigk7k2qll1pcf6jfgmbdzkzfz2i048pkfg851s0x4g"; };
polly = { location = "tools/polly"; sha256 = "1rqflmgzg1vzjm0r32c5ck8x3q0qm3g0hh8ggbjazh6x7nvmy6lz"; };
})}
sed -i 's|/usr/bin/env||' \
$sourceRoot/tools/lldb/scripts/Python/finish-swig-Python-LLDB.sh \
$sourceRoot/tools/lldb/scripts/Python/build-swig-Python.sh
'';
buildInputs = [ perl
groff
cmake
libxml2
python
libffi
zlib
ncurses
isl
gmp
doxygen
swig
which
libedit
valgrind
];
cmakeFlags = [
"-DCMAKE_BUILD_TYPE=Release"
"-DLLVM_ENABLE_FFI=ON"
"-DGCC_INSTALL_PREFIX=${stdenv.gcc.gcc}"
"-DC_INCLUDE_DIRS=${stdenv.gcc.libc}/include/"
"-DLLVM_BINUTILS_INCDIR=${binutils}/include"
"-DCMAKE_CXX_FLAGS=-std=c++11"
];
passthru.gcc = stdenv.gcc.gcc;
enableParallelBuilding = true;
meta = {
description = "Collection of modular and reusable compiler and toolchain technologies";
homepage = http://llvm.org/;
license = stdenv.lib.licenses.bsd3;
maintainers = [ stdenv.lib.maintainers.shlevy ];
platforms = stdenv.lib.platforms.all;
};
}

View File

@ -1,4 +1,4 @@
{ stdenv, fetchurl, fetchsvn, cmake, libcxxabi }:
{ stdenv, fetchurl, fetchsvn, cmake, libcxxabi, python }:
let
version = "3.4";
@ -11,7 +11,7 @@ in stdenv.mkDerivation rec {
sha256 = "1sqd5qhqj7qnn9zjxx9bv7ky4f7xgmh9sbgd53y1kszhg41217xx";
};
buildInputs = [ cmake libcxxabi ];
buildInputs = [ cmake libcxxabi python ];
cmakeFlags = [ "-DCMAKE_BUILD_TYPE=Release"
"-DLIBCXX_LIBCXXABI_INCLUDE_PATHS=${libcxxabi}/include"

View File

@ -2298,12 +2298,9 @@ let
ccl = builderDefsPackage ../development/compilers/ccl {};
clang = wrapClang llvmFull;
clang = wrapClang llvmPackages.clang;
llvmFullSelf = clangWrapSelf (llvmFull.override {
stdenv = libcxxStdenv;
});
clangSelf = clangWrapSelf llvmPackagesSelf.clang;
clangWrapSelf = build: (import ../build-support/clang-wrapper) {
clang = build;
@ -2318,7 +2315,7 @@ let
#Use this instead of stdenv to build with clang
clangStdenv = lowPrio (stdenvAdapters.overrideGCC stdenv clang);
libcxxStdenv = stdenvAdapters.overrideGCC stdenv (clangWrapSelf llvmFull);
libcxxStdenv = stdenvAdapters.overrideGCC stdenv (clangWrapSelf llvmPackages.clang);
clean = callPackage ../development/compilers/clean { };
@ -2751,6 +2748,7 @@ let
julia = callPackage ../development/compilers/julia {
liblapack = liblapack.override {shared = true;};
llvm = llvm_33;
};
lazarus = builderDefsPackage (import ../development/compilers/fpc/lazarus.nix) {
@ -2761,17 +2759,14 @@ let
lessc = callPackage ../development/compilers/lessc { };
llvm = llvm_33;
llvm_34 = callPackage ../development/compilers/llvm {
version = "3.4";
llvm = llvmPackages.llvm;
llvm_33 = callPackage ../development/compilers/llvm/3.3/llvm.nix {
stdenv = if stdenv.isDarwin
then stdenvAdapters.overrideGCC stdenv gccApple
else stdenv;
};
llvm_33 = llvm_34.override { version = "3.3"; };
llvmFull = callPackage ../development/compilers/llvm/full.nix {
isl = isl_0_12;
};
llvmPackages = recurseIntoAttrs (import ../development/compilers/llvm/3.4 { inherit newScope stdenv fetchurl; isl = isl_0_12; });
llvmPackagesSelf = recurseIntoAttrs (import ../development/compilers/llvm/3.4 { inherit newScope fetchurl; isl = isl_0_12; stdenv = libcxxStdenv; });
mentorToolchains = recurseIntoAttrs (
callPackage_i686 ../development/compilers/mentor {}
@ -3961,7 +3956,7 @@ let
dssi = callPackage ../development/libraries/dssi {};
dragonegg = callPackage ../development/compilers/llvm/dragonegg.nix { llvm = llvmFull; };
dragonegg = llvmPackages.dragonegg;
dxflib = callPackage ../development/libraries/dxflib {};
@ -5084,7 +5079,7 @@ let
mesaSupported = lib.elem system lib.platforms.mesaPlatforms;
mesa_original = callPackage ../development/libraries/mesa { };
mesa_original = callPackage ../development/libraries/mesa { llvm = llvm_33; };
mesa_noglu = if stdenv.isDarwin
then darwinX11AndOpenGL // { driverLink = mesa_noglu; }
else mesa_original;