Making clang build for llvm 2.7

(I've not tested the usage of c++ headers though, but it builds c and c++ simple programs)

svn path=/nixpkgs/trunk/; revision=22236
This commit is contained in:
Lluís Batlle i Rossell 2010-06-12 21:52:39 +00:00
parent 1babf6ea14
commit 22a839c86d
5 changed files with 258 additions and 6 deletions

View File

@ -199,7 +199,7 @@ stdenv.mkDerivation ({
passthru = { inherit langC langCC langAda langFortran langTreelang langVhdl
enableMultilib; };
enableMultilib version; };
meta = {
homepage = http://gcc.gnu.org/;

View File

@ -277,7 +277,7 @@ stdenv.mkDerivation ({
else null;
passthru = { inherit langC langCC langAda langFortran langTreelang langVhdl
enableMultilib; };
enableMultilib version; };
meta = {
homepage = http://gcc.gnu.org/;

View File

@ -0,0 +1,205 @@
diff --git a/tools/clang/lib/Frontend/InitHeaderSearch.cpp b/tools/clang/lib/Frontend/InitHeaderSearch.cpp
index cd749d2..b5591f6 100644
--- a/tools/clang/lib/Frontend/InitHeaderSearch.cpp
+++ b/tools/clang/lib/Frontend/InitHeaderSearch.cpp
@@ -393,51 +393,7 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple) {
AddPath(*i, System, false, false, false);
return;
}
- llvm::Triple::OSType os = triple.getOS();
- switch (os) {
- case llvm::Triple::Win32:
- {
- std::string VSDir;
- std::string WindowsSDKDir;
- if (getVisualStudioDir(VSDir)) {
- AddPath(VSDir + "\\VC\\include", System, false, false, false);
- if (getWindowsSDKDir(WindowsSDKDir))
- AddPath(WindowsSDKDir, System, false, false, false);
- else
- AddPath(VSDir + "\\VC\\PlatformSDK\\Include",
- System, false, false, false);
- }
- else {
- // Default install paths.
- AddPath("C:/Program Files/Microsoft Visual Studio 9.0/VC/include",
- System, false, false, false);
- AddPath(
- "C:/Program Files/Microsoft Visual Studio 9.0/VC/PlatformSDK/Include",
- System, false, false, false);
- AddPath("C:/Program Files/Microsoft Visual Studio 8/VC/include",
- System, false, false, false);
- AddPath(
- "C:/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK/Include",
- System, false, false, false);
- // For some clang developers.
- AddPath("G:/Program Files/Microsoft Visual Studio 9.0/VC/include",
- System, false, false, false);
- AddPath(
- "G:/Program Files/Microsoft Visual Studio 9.0/VC/PlatformSDK/Include",
- System, false, false, false);
- }
- }
- break;
- case llvm::Triple::MinGW64:
- case llvm::Triple::MinGW32:
- AddPath("c:/mingw/include", System, true, false, false);
- break;
- default:
- break;
- }
-
- AddPath("/usr/local/include", System, true, false, false);
- AddPath("/usr/include", System, false, false, false);
+ AddPath(C_INCLUDE_PATH, System, false, false, false);
}
void InitHeaderSearch::AddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple) {
@@ -453,144 +409,9 @@ void InitHeaderSearch::AddDefaultCPlusPlusIncludePaths(const llvm::Triple &tripl
CXX_INCLUDE_32BIT_DIR, CXX_INCLUDE_64BIT_DIR, triple);
return;
}
- // FIXME: temporary hack: hard-coded paths.
- switch (os) {
- case llvm::Triple::Cygwin:
- AddPath("/lib/gcc/i686-pc-cygwin/3.4.4/include",
- System, true, false, false);
- AddPath("/lib/gcc/i686-pc-cygwin/3.4.4/include/c++",
- System, true, false, false);
- break;
- case llvm::Triple::MinGW64:
- // Try gcc 4.4.0
- AddMinGWCPlusPlusIncludePaths("c:/MinGW/lib/gcc", "mingw64", "4.4.0");
- // Try gcc 4.3.0
- AddMinGWCPlusPlusIncludePaths("c:/MinGW/lib/gcc", "mingw64", "4.3.0");
- // Fall through.
- case llvm::Triple::MinGW32:
- // Try gcc 4.4.0
- AddMinGWCPlusPlusIncludePaths("c:/MinGW/lib/gcc", "mingw32", "4.4.0");
- // Try gcc 4.3.0
- AddMinGWCPlusPlusIncludePaths("c:/MinGW/lib/gcc", "mingw32", "4.3.0");
- break;
- case llvm::Triple::Darwin:
- AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2.1",
- "i686-apple-darwin10", "", "x86_64", triple);
- AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.0.0",
- "i686-apple-darwin8", "", "", triple);
- break;
- case llvm::Triple::DragonFly:
- AddPath("/usr/include/c++/4.1", System, true, false, false);
- break;
- case llvm::Triple::Linux:
- // Exherbo (2010-01-25)
- AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.3",
- "x86_64-pc-linux-gnu", "32", "", triple);
- AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.3",
- "i686-pc-linux-gnu", "", "", triple);
- // Debian sid
- AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4",
- "x86_64-linux-gnu", "32", "", triple);
- AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4",
- "i486-linux-gnu", "64", "", triple);
- // Ubuntu 7.10 - Gutsy Gibbon
- AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.1.3",
- "i486-linux-gnu", "", "", triple);
- // Ubuntu 9.04
- AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.3",
- "x86_64-linux-gnu","32", "", triple);
- // Ubuntu 9.10
- AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.1",
- "x86_64-linux-gnu", "32", "", triple);
- // Fedora 8
- AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.1.2",
- "i386-redhat-linux", "", "", triple);
- // Fedora 9
- AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.0",
- "i386-redhat-linux", "", "", triple);
- // Fedora 10
- AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.2",
- "i386-redhat-linux","", "", triple);
-
- // Fedora 10 x86_64
- AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.2",
- "x86_64-redhat-linux", "32", "", triple);
-
- // Fedora 11
- AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.1",
- "i586-redhat-linux","", "", triple);
-
- // Fedora 12
- AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.2",
- "i686-redhat-linux","", "", triple);
-
- // Fedora 12 (February-2010+)
- AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.3",
- "i686-redhat-linux","", "", triple);
-
- // openSUSE 11.1 32 bit
- AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3",
- "i586-suse-linux", "", "", triple);
- // openSUSE 11.1 64 bit
- AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3",
- "x86_64-suse-linux", "32", "", triple);
- // openSUSE 11.2
- AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4",
- "i586-suse-linux", "", "", triple);
- AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4",
- "x86_64-suse-linux", "", "", triple);
- // Arch Linux 2008-06-24
- AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.1",
- "i686-pc-linux-gnu", "", "", triple);
- AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3.1",
- "x86_64-unknown-linux-gnu", "", "", triple);
- // Gentoo x86 2009.1 stable
- AddGnuCPlusPlusIncludePaths(
- "/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4",
- "i686-pc-linux-gnu", "", "", triple);
- // Gentoo x86 2009.0 stable
- AddGnuCPlusPlusIncludePaths(
- "/usr/lib/gcc/i686-pc-linux-gnu/4.3.2/include/g++-v4",
- "i686-pc-linux-gnu", "", "", triple);
- // Gentoo x86 2008.0 stable
- AddGnuCPlusPlusIncludePaths(
- "/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4",
- "i686-pc-linux-gnu", "", "", triple);
- // Ubuntu 8.10
- AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3",
- "i486-pc-linux-gnu", "", "", triple);
- // Ubuntu 9.04
- AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.3",
- "i486-linux-gnu","", "", triple);
- // Gentoo amd64 stable
- AddGnuCPlusPlusIncludePaths(
- "/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/include/g++-v4",
- "i686-pc-linux-gnu", "", "", triple);
-
- // Gentoo amd64 gcc 4.3.2
- AddGnuCPlusPlusIncludePaths(
- "/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/include/g++-v4",
- "x86_64-pc-linux-gnu", "", "", triple);
-
- // Gentoo amd64 gcc 4.4.3
- AddGnuCPlusPlusIncludePaths(
- "/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.3/include/g++-v4",
- "x86_64-pc-linux-gnu", "32", "", triple);
-
- break;
- case llvm::Triple::FreeBSD:
- AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2", "", "", "", triple);
- break;
- case llvm::Triple::Solaris:
- // Solaris - Fall though..
- case llvm::Triple::AuroraUX:
- // AuroraUX
- AddGnuCPlusPlusIncludePaths("/opt/gcc4/include/c++/4.2.4",
- "i386-pc-solaris2.11", "", "", triple);
- break;
- default:
- break;
- }
+ AddGnuCPlusPlusIncludePaths(
+ CPP_INCLUDE_PATH,
+ CPP_HOST, "", "", triple);
}
void InitHeaderSearch::AddDefaultSystemIncludePaths(const LangOptions &Lang,

View File

@ -1,6 +1,7 @@
{stdenv, fetchurl, gcc, flex, perl, libtool, groff}:
{stdenv, fetchurl, fetchsvn, gcc, flex, perl, libtool, groff
, buildClang ? false}:
stdenv.mkDerivation {
stdenv.mkDerivation ({
name = "llvm-2.7";
src = fetchurl {
url = http://llvm.org/releases/2.7/llvm-2.7.tgz;
@ -9,6 +10,8 @@ stdenv.mkDerivation {
buildInputs = [ gcc flex perl libtool groff ];
configureFlags = [ "--enable-optimized" "--enable-shared" ];
meta = {
homepage = http://llvm.org/;
description = "Collection of modular and reusable compiler and toolchain technologies";
@ -16,3 +19,43 @@ stdenv.mkDerivation {
platforms = with stdenv.lib.platforms; all;
};
}
//
(if buildClang then
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 {
srcClang = fetchsvn {
url = http://llvm.org/svn/llvm-project/cfe/tags/RELEASE_27;
rev = 105900;
sha256 = "0sfj9glc5yi5fb23h1xihs11l420wzghkm5pk4kwg6pw4w19xg00";
};
prePatch = ''
pushd tools
cp -R "$srcClang" clang
chmod u+w -R clang
popd
'';
patches = [ ./clang-include-paths.patch ];
# Set up the header file paths
preConfigure = ''
sed -i -e 's,C_INCLUDE_PATH,"${gcc.libc}/include/",' \
-e 's,CPP_HOST,"${triplet}",' \
-e 's,CPP_INCLUDE_PATH,"${gcc.gcc}/include/c++/${gcc.gcc.version}",' \
tools/clang/lib/Frontend/InitHeaderSearch.cpp
'';
meta = {
homepage = http://clang.llvm.org/;
description = "A C language family frontend for LLVM";
maintainers = with stdenv.lib.maintainers; [viric];
platforms = with stdenv.lib.platforms; linux;
};
}
else {}
))

View File

@ -2003,6 +2003,10 @@ let
ccl = builderDefsPackage ../development/compilers/ccl {};
clang = llvm.override {
buildClang = true;
};
dylan = import ../development/compilers/gwydion-dylan {
inherit fetchurl stdenv perl boehmgc yacc flex readline;
dylan =
@ -2505,8 +2509,8 @@ let
inherit (xlibs) libXi inputproto libX11 xproto libXext xextproto;
};
llvm = import ../development/compilers/llvm {
inherit fetchurl stdenv gcc flex perl libtool groff;
llvm = makeOverridable (import ../development/compilers/llvm) {
inherit fetchurl fetchsvn stdenv gcc flex perl libtool groff;
};
llvmGCC = builderDefsPackage (import ../development/compilers/llvm/llvm-gcc.nix) {