mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-29 02:13:23 +00:00
Enable building clang separately from llvm
Note that there is some duplication when building clang now. The llvm source is unpacked twice, ./configure is run twice, and two small unit test libraries are compiled twice. IMO this is a fair tradeoff for having llvm be a separate build unaffected by changes to clang svn path=/nixpkgs/trunk/; revision=29919
This commit is contained in:
parent
54951e3994
commit
6e3cde6383
42
pkgs/development/compilers/llvm/clang-system-llvm-libs.patch
Normal file
42
pkgs/development/compilers/llvm/clang-system-llvm-libs.patch
Normal file
@ -0,0 +1,42 @@
|
||||
diff -Naur llvm-2.9-orig/Makefile.rules llvm-2.9/Makefile.rules
|
||||
--- llvm-2.9-orig/Makefile.rules 2011-03-25 02:26:58.000000000 -0400
|
||||
+++ llvm-2.9/Makefile.rules 2011-10-19 15:31:38.538674143 -0400
|
||||
@@ -941,7 +941,7 @@
|
||||
@echo "*** llvm-config doesn't exist - rebuilding it."
|
||||
@$(MAKE) -C $(PROJ_OBJ_ROOT)/tools/llvm-config
|
||||
|
||||
-$(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
|
||||
+$(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT):
|
||||
|
||||
ifeq ($(ENABLE_SHARED), 1)
|
||||
# We can take the "auto-import" feature to get rid of using dllimport.
|
||||
@@ -1137,7 +1137,7 @@
|
||||
else
|
||||
SharedLibKindMessage := "Shared Library"
|
||||
endif
|
||||
-$(LibName.SO): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) $(SharedLibDir)/.dir
|
||||
+$(LibName.SO): $(ObjectsO) $(ProjLibsPaths) $(SharedLibDir)/.dir
|
||||
$(Echo) Linking $(BuildMode) $(SharedLibKindMessage) \
|
||||
$(notdir $@)
|
||||
$(Verb) $(Link) $(SharedLinkOptions) -o $@ $(ObjectsO) \
|
||||
@@ -1411,7 +1411,7 @@
|
||||
$(ToolBuildPath): $(ToolDir)/.dir
|
||||
endif
|
||||
|
||||
-$(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
|
||||
+$(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths)
|
||||
$(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg)
|
||||
$(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
|
||||
$(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
|
||||
diff -Naur llvm-2.9-orig/unittests/Makefile.unittest llvm-2.9/unittests/Makefile.unittest
|
||||
--- llvm-2.9-orig/unittests/Makefile.unittest 2011-02-04 12:12:18.000000000 -0500
|
||||
+++ llvm-2.9/unittests/Makefile.unittest 2011-10-19 15:47:27.100035616 -0400
|
||||
@@ -47,7 +47,7 @@
|
||||
Run.Shared := $(SHLIBPATH_VAR)="$(SharedLibDir)$${$(SHLIBPATH_VAR):+:}$$$(SHLIBPATH_VAR)"
|
||||
endif
|
||||
|
||||
-$(LLVMUnitTestExe): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
|
||||
+$(LLVMUnitTestExe): $(ObjectsO) $(ProjLibsPaths)
|
||||
$(Echo) Linking $(BuildMode) unit test $(TESTNAME) $(StripWarnMsg)
|
||||
$(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
|
||||
$(TESTLIBS) $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
|
134
pkgs/development/compilers/llvm/clang-tblgen.patch
Normal file
134
pkgs/development/compilers/llvm/clang-tblgen.patch
Normal file
@ -0,0 +1,134 @@
|
||||
diff -Naur a/tools/clang/include/clang/AST/Makefile b/tools/clang/include/clang/AST/Makefile
|
||||
--- a/tools/clang/include/clang/AST/Makefile 2010-08-18 19:23:40.000000000 -0400
|
||||
+++ b/tools/clang/include/clang/AST/Makefile 2011-10-19 14:19:21.420750346 -0400
|
||||
@@ -6,24 +6,24 @@
|
||||
|
||||
include $(CLANG_LEVEL)/Makefile
|
||||
|
||||
-$(ObjDir)/Attrs.inc.tmp : $(TD_SRC_DIR)/Attr.td $(TBLGEN) \
|
||||
+$(ObjDir)/Attrs.inc.tmp : $(TD_SRC_DIR)/Attr.td \
|
||||
$(ObjDir)/.dir
|
||||
$(Echo) "Building Clang attribute classes with tblgen"
|
||||
$(Verb) $(TableGen) -gen-clang-attr-classes -o $(call SYSPATH, $@) \
|
||||
-I $(PROJ_SRC_DIR)/../../ $<
|
||||
|
||||
-$(ObjDir)/AttrImpl.inc.tmp : $(TD_SRC_DIR)/Attr.td $(TBLGEN) \
|
||||
+$(ObjDir)/AttrImpl.inc.tmp : $(TD_SRC_DIR)/Attr.td \
|
||||
$(ObjDir)/.dir
|
||||
$(Echo) "Building Clang attribute implementations with tblgen"
|
||||
$(Verb) $(TableGen) -gen-clang-attr-impl -o $(call SYSPATH, $@) \
|
||||
-I $(PROJ_SRC_DIR)/../../ $<
|
||||
|
||||
-$(ObjDir)/StmtNodes.inc.tmp : $(TD_SRC_DIR)/StmtNodes.td $(TBLGEN) \
|
||||
+$(ObjDir)/StmtNodes.inc.tmp : $(TD_SRC_DIR)/StmtNodes.td \
|
||||
$(ObjDir)/.dir
|
||||
$(Echo) "Building Clang statement node tables with tblgen"
|
||||
$(Verb) $(TableGen) -gen-clang-stmt-nodes -o $(call SYSPATH, $@) $<
|
||||
|
||||
-$(ObjDir)/DeclNodes.inc.tmp : $(TD_SRC_DIR)/DeclNodes.td $(TBLGEN) \
|
||||
+$(ObjDir)/DeclNodes.inc.tmp : $(TD_SRC_DIR)/DeclNodes.td \
|
||||
$(ObjDir)/.dir
|
||||
$(Echo) "Building Clang declaration node tables with tblgen"
|
||||
$(Verb) $(TableGen) -gen-clang-decl-nodes -o $(call SYSPATH, $@) $<
|
||||
diff -Naur a/tools/clang/include/clang/Basic/Makefile b/tools/clang/include/clang/Basic/Makefile
|
||||
--- a/tools/clang/include/clang/Basic/Makefile 2010-09-09 16:27:36.000000000 -0400
|
||||
+++ b/tools/clang/include/clang/Basic/Makefile 2011-10-19 14:17:54.950837324 -0400
|
||||
@@ -29,20 +29,20 @@
|
||||
CLANG_HAS_VERSION_PATCHLEVEL := 1
|
||||
endif
|
||||
|
||||
-$(ObjDir)/Diagnostic%Kinds.inc.tmp : Diagnostic.td Diagnostic%Kinds.td $(TBLGEN) $(ObjDir)/.dir
|
||||
+$(ObjDir)/Diagnostic%Kinds.inc.tmp : Diagnostic.td Diagnostic%Kinds.td $(ObjDir)/.dir
|
||||
$(Echo) "Building Clang $(patsubst Diagnostic%Kinds.inc.tmp,%,$(@F)) diagnostic tables with tblgen"
|
||||
$(Verb) $(TableGen) -gen-clang-diags-defs -clang-component=$(patsubst Diagnostic%Kinds.inc.tmp,%,$(@F)) -o $(call SYSPATH, $@) $<
|
||||
|
||||
-$(ObjDir)/DiagnosticGroups.inc.tmp : Diagnostic.td DiagnosticGroups.td $(INPUT_TDS) $(TBLGEN) $(ObjDir)/.dir
|
||||
+$(ObjDir)/DiagnosticGroups.inc.tmp : Diagnostic.td DiagnosticGroups.td $(INPUT_TDS) $(ObjDir)/.dir
|
||||
$(Echo) "Building Clang diagnostic groups with tblgen"
|
||||
$(Verb) $(TableGen) -gen-clang-diag-groups -o $(call SYSPATH, $@) $<
|
||||
|
||||
-$(ObjDir)/AttrList.inc.tmp : Attr.td $(TBLGEN) $(ObjDir)/.dir
|
||||
+$(ObjDir)/AttrList.inc.tmp : Attr.td $(ObjDir)/.dir
|
||||
$(Echo) "Building Clang attribute list with tblgen"
|
||||
$(Verb) $(TableGen) -gen-clang-attr-list -o $(call SYSPATH, $@) \
|
||||
-I $(PROJ_SRC_DIR)/../.. $<
|
||||
|
||||
-$(ObjDir)/arm_neon.inc.tmp : arm_neon.td $(TBLGEN) $(ObjDir)/.dir
|
||||
+$(ObjDir)/arm_neon.inc.tmp : arm_neon.td $(ObjDir)/.dir
|
||||
$(Echo) "Building Clang arm_neon.inc with tblgen"
|
||||
$(Verb) $(TableGen) -gen-arm-neon-sema -o $(call SYSPATH, $@) $<
|
||||
|
||||
diff -Naur a/tools/clang/include/clang/Driver/Makefile b/tools/clang/include/clang/Driver/Makefile
|
||||
--- a/tools/clang/include/clang/Driver/Makefile 2010-06-08 16:34:18.000000000 -0400
|
||||
+++ b/tools/clang/include/clang/Driver/Makefile 2011-10-19 14:25:33.739369159 -0400
|
||||
@@ -5,14 +5,14 @@
|
||||
|
||||
include $(CLANG_LEVEL)/Makefile
|
||||
|
||||
-$(ObjDir)/Options.inc.tmp : Options.td OptParser.td $(TBLGEN) $(ObjDir)/.dir
|
||||
+$(ObjDir)/Options.inc.tmp : Options.td OptParser.td $(ObjDir)/.dir
|
||||
$(Echo) "Building Clang Driver Option tables with tblgen"
|
||||
$(Verb) $(TableGen) -gen-opt-parser-defs -o $(call SYSPATH, $@) $<
|
||||
|
||||
-$(ObjDir)/CC1Options.inc.tmp : CC1Options.td OptParser.td $(TBLGEN) $(ObjDir)/.dir
|
||||
+$(ObjDir)/CC1Options.inc.tmp : CC1Options.td OptParser.td $(ObjDir)/.dir
|
||||
$(Echo) "Building Clang CC1 Option tables with tblgen"
|
||||
$(Verb) $(TableGen) -gen-opt-parser-defs -o $(call SYSPATH, $@) $<
|
||||
|
||||
-$(ObjDir)/CC1AsOptions.inc.tmp : CC1AsOptions.td OptParser.td $(TBLGEN) $(ObjDir)/.dir
|
||||
+$(ObjDir)/CC1AsOptions.inc.tmp : CC1AsOptions.td OptParser.td $(ObjDir)/.dir
|
||||
$(Echo) "Building Clang CC1 Assembler Option tables with tblgen"
|
||||
$(Verb) $(TableGen) -gen-opt-parser-defs -o $(call SYSPATH, $@) $<
|
||||
diff -Naur a/tools/clang/include/clang/Lex/Makefile b/tools/clang/include/clang/Lex/Makefile
|
||||
--- a/tools/clang/include/clang/Lex/Makefile 2010-10-19 22:31:43.000000000 -0400
|
||||
+++ b/tools/clang/include/clang/Lex/Makefile 2011-10-19 14:18:25.082807086 -0400
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
include $(CLANG_LEVEL)/Makefile
|
||||
|
||||
-$(ObjDir)/AttrSpellings.inc.tmp : $(TD_SRC_DIR)/Attr.td $(TBLGEN) \
|
||||
+$(ObjDir)/AttrSpellings.inc.tmp : $(TD_SRC_DIR)/Attr.td \
|
||||
$(ObjDir)/.dir
|
||||
$(Echo) "Building Clang attribute spellings with tblgen"
|
||||
$(Verb) $(TableGen) -gen-clang-attr-spelling-list -o $(call SYSPATH, $@) \
|
||||
diff -Naur a/tools/clang/include/clang/Serialization/Makefile b/tools/clang/include/clang/Serialization/Makefile
|
||||
--- a/tools/clang/include/clang/Serialization/Makefile 2010-08-18 19:23:40.000000000 -0400
|
||||
+++ b/tools/clang/include/clang/Serialization/Makefile 2011-10-19 14:25:05.764398164 -0400
|
||||
@@ -6,13 +6,13 @@
|
||||
|
||||
include $(CLANG_LEVEL)/Makefile
|
||||
|
||||
-$(ObjDir)/AttrPCHRead.inc.tmp : $(TD_SRC_DIR)/Attr.td $(TBLGEN) \
|
||||
+$(ObjDir)/AttrPCHRead.inc.tmp : $(TD_SRC_DIR)/Attr.td \
|
||||
$(ObjDir)/.dir
|
||||
$(Echo) "Building Clang PCH reader with tblgen"
|
||||
$(Verb) $(TableGen) -gen-clang-attr-pch-read -o $(call SYSPATH, $@) \
|
||||
-I $(PROJ_SRC_DIR)/../../ $<
|
||||
|
||||
-$(ObjDir)/AttrPCHWrite.inc.tmp : $(TD_SRC_DIR)/Attr.td $(TBLGEN) \
|
||||
+$(ObjDir)/AttrPCHWrite.inc.tmp : $(TD_SRC_DIR)/Attr.td \
|
||||
$(ObjDir)/.dir
|
||||
$(Echo) "Building Clang PCH writer with tblgen"
|
||||
$(Verb) $(TableGen) -gen-clang-attr-pch-write -o $(call SYSPATH, $@) \
|
||||
diff -Naur a/tools/clang/lib/Headers/Makefile b/tools/clang/lib/Headers/Makefile
|
||||
--- a/tools/clang/lib/Headers/Makefile 2010-07-21 21:19:36.000000000 -0400
|
||||
+++ b/tools/clang/lib/Headers/Makefile 2011-10-19 14:15:18.520993127 -0400
|
||||
@@ -49,6 +49,6 @@
|
||||
|
||||
install-local:: $(INSTHEADERS)
|
||||
|
||||
-$(ObjDir)/arm_neon.h.inc.tmp : $(CLANG_LEVEL)/include/clang/Basic/arm_neon.td $(TBLGEN) $(ObjDir)/.dir
|
||||
+$(ObjDir)/arm_neon.h.inc.tmp : $(CLANG_LEVEL)/include/clang/Basic/arm_neon.td $(ObjDir)/.dir
|
||||
$(Echo) "Building Clang arm_neon.h.inc with tblgen"
|
||||
$(Verb) $(TableGen) -gen-arm-neon -o $(call SYSPATH, $@) $<
|
||||
diff -Naur a/tools/clang/lib/StaticAnalyzer/Checkers/Makefile b/tools/clang/lib/StaticAnalyzer/Checkers/Makefile
|
||||
--- a/tools/clang/lib/StaticAnalyzer/Checkers/Makefile 2011-02-15 02:42:38.000000000 -0500
|
||||
+++ b/tools/clang/lib/StaticAnalyzer/Checkers/Makefile 2011-10-19 14:15:58.240953760 -0400
|
||||
@@ -19,6 +19,6 @@
|
||||
|
||||
include $(CLANG_LEVEL)/Makefile
|
||||
|
||||
-$(ObjDir)/Checkers.inc.tmp : Checkers.td $(PROJ_SRC_DIR)/$(CLANG_LEVEL)/include/clang/StaticAnalyzer/Checkers/CheckerBase.td $(TBLGEN) $(ObjDir)/.dir
|
||||
+$(ObjDir)/Checkers.inc.tmp : Checkers.td $(PROJ_SRC_DIR)/$(CLANG_LEVEL)/include/clang/StaticAnalyzer/Checkers/CheckerBase.td $(ObjDir)/.dir
|
||||
$(Echo) "Building Clang SA Checkers tables with tblgen"
|
||||
$(Verb) $(TableGen) -gen-clang-sa-checkers -I $(PROJ_SRC_DIR)/$(CLANG_LEVEL)/include -o $(call SYSPATH, $@) $<
|
62
pkgs/development/compilers/llvm/clang.nix
Normal file
62
pkgs/development/compilers/llvm/clang.nix
Normal file
@ -0,0 +1,62 @@
|
||||
{ stdenv, fetchurl, perl, groff, llvm }:
|
||||
|
||||
assert stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux";
|
||||
let
|
||||
triplet = if (stdenv.system == "i686-linux") then "i686-unknown-linux-gnu"
|
||||
else if (stdenv.system == "x86_64-linux") then "x86_64-unknown-linux-gnu"
|
||||
else throw "System not supported";
|
||||
|
||||
version = "2.9";
|
||||
in
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "clang-${version}";
|
||||
|
||||
CC = if stdenv.gcc ? clang then "clang" else "gcc";
|
||||
|
||||
CXX = if stdenv.gcc ? clang then "clang++" else "g++";
|
||||
|
||||
src = llvm.src;
|
||||
|
||||
buildInputs = [ perl llvm groff ];
|
||||
|
||||
configureFlags = [ "--enable-optimized" "--enable-shared" "--disable-static" ];
|
||||
srcClang = fetchurl {
|
||||
url = "http://llvm.org/releases/${version}/clang-${version}.tgz";
|
||||
sha256 = "1pq9g7qxw761dp6gx3amx39kl9p4zhlymmn8gfmcnw9ag0zizi3h";
|
||||
};
|
||||
|
||||
prePatch = ''
|
||||
pushd tools
|
||||
unpackFile $srcClang
|
||||
mv clang-${version} clang
|
||||
popd
|
||||
find
|
||||
'';
|
||||
|
||||
patches = [ ./clang-include-paths.patch ./clang-ld-flags.patch ./clang-tblgen.patch ./clang-system-llvm-libs.patch ];
|
||||
|
||||
buildFlags = [ "TableGen=tblgen" "LLVM_CONFIG=llvm-config" ];
|
||||
# Set up the header file paths
|
||||
preBuild = ''
|
||||
sed -i -e 's,C_INCLUDE_PATH,"${stdenv.gcc.libc}/include/",' \
|
||||
-e 's,CPP_HOST,"${triplet}",' \
|
||||
-e 's,CPP_INCLUDE_PATH,"${stdenv.gcc.gcc}/include/c++/${stdenv.gcc.gcc.version}",' \
|
||||
tools/clang/lib/Frontend/InitHeaderSearch.cpp
|
||||
|
||||
pushd utils/unittest
|
||||
make
|
||||
popd
|
||||
cd tools/clang
|
||||
'';
|
||||
|
||||
passthru = { gcc = stdenv.gcc.gcc; };
|
||||
|
||||
meta = {
|
||||
homepage = http://clang.llvm.org/;
|
||||
description = "A C language family frontend for LLVM";
|
||||
license = "BSD";
|
||||
maintainers = with stdenv.lib.maintainers; [viric shlevy];
|
||||
platforms = with stdenv.lib.platforms; linux;
|
||||
};
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
{ stdenv, fetchurl, perl, groff, buildClang ? false }:
|
||||
{ stdenv, fetchurl, perl, groff }:
|
||||
|
||||
let version = "2.9"; in
|
||||
|
||||
stdenv.mkDerivation ({
|
||||
stdenv.mkDerivation {
|
||||
name = "llvm-${version}";
|
||||
|
||||
CC = if stdenv.gcc ? clang then "clang" else "gcc";
|
||||
@ -26,48 +26,4 @@ stdenv.mkDerivation ({
|
||||
platforms = with stdenv.lib.platforms; all;
|
||||
};
|
||||
}
|
||||
// stdenv.lib.optionalAttrs buildClang (
|
||||
# I write the assert because 'gcc.libc' will be evaluated although 'triplet' would not
|
||||
# evaluate properly (in the preConfigure below)
|
||||
assert stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux";
|
||||
let
|
||||
triplet = if (stdenv.system == "i686-linux") then "i686-unknown-linux-gnu"
|
||||
else if (stdenv.system == "x86_64-linux") then "x86_64-unknown-linux-gnu"
|
||||
else throw "System not supported";
|
||||
in {
|
||||
name = "clang-${version}";
|
||||
|
||||
srcClang = fetchurl {
|
||||
url = "http://llvm.org/releases/${version}/clang-${version}.tgz";
|
||||
sha256 = "1pq9g7qxw761dp6gx3amx39kl9p4zhlymmn8gfmcnw9ag0zizi3h";
|
||||
};
|
||||
|
||||
prePatch = ''
|
||||
pushd tools
|
||||
unpackFile $srcClang
|
||||
mv clang-${version} clang
|
||||
popd
|
||||
find
|
||||
'';
|
||||
|
||||
patches = [ ./clang-include-paths.patch ./clang-ld-flags.patch ];
|
||||
|
||||
# Set up the header file paths
|
||||
preConfigure = ''
|
||||
sed -i -e 's,C_INCLUDE_PATH,"${stdenv.gcc.libc}/include/",' \
|
||||
-e 's,CPP_HOST,"${triplet}",' \
|
||||
-e 's,CPP_INCLUDE_PATH,"${stdenv.gcc.gcc}/include/c++/${stdenv.gcc.gcc.version}",' \
|
||||
tools/clang/lib/Frontend/InitHeaderSearch.cpp
|
||||
'';
|
||||
|
||||
passthru = { gcc = stdenv.gcc.gcc; };
|
||||
|
||||
meta = {
|
||||
homepage = http://clang.llvm.org/;
|
||||
description = "A C language family frontend for LLVM";
|
||||
license = "BSD";
|
||||
maintainers = with stdenv.lib.maintainers; [viric shlevy];
|
||||
platforms = with stdenv.lib.platforms; linux;
|
||||
};
|
||||
}
|
||||
))
|
||||
|
@ -1640,9 +1640,16 @@ let
|
||||
|
||||
ccl = builderDefsPackage ../development/compilers/ccl {};
|
||||
|
||||
clangBoot = wrapClang (llvm.override { buildClang = true; });
|
||||
clangBootUnwrapped = callPackage ../development/compilers/llvm/clang.nix { };
|
||||
|
||||
clang = wrapClang (llvm.override { buildClang = true; stdenv = stdenvAdapters.overrideGCC stdenv clangBoot; });
|
||||
clangBoot = wrapClang clangBootUnwrapped;
|
||||
|
||||
clangUnwrapped = let clangBootStdenv = stdenvAdapters.overrideGCC stdenv clangBoot; in clangBootUnwrapped.override {
|
||||
stdenv = clangBootStdenv;
|
||||
llvm = llvm.override { stdenv = clangBootStdenv; };
|
||||
};
|
||||
|
||||
clang = wrapClang clangUnwrapped;
|
||||
|
||||
#Use this instead of stdenv to build with clang
|
||||
clangStdenv = stdenvAdapters.overrideGCC stdenv clang;
|
||||
|
Loading…
Reference in New Issue
Block a user