summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Yao <ryao@gentoo.org>2012-05-26 01:34:57 +0000
committerRichard Yao <ryao@gentoo.org>2012-05-26 01:34:57 +0000
commit4ab45421122d83848656a2cdb3d2e5db29034ddd (patch)
tree3ca85b8f24022fd168529eb175eae5c30a55cccd /sys-devel/clang
parentSort USE flags. Patch by Arfrever. (diff)
downloadhistorical-4ab45421122d83848656a2cdb3d2e5db29034ddd.tar.gz
historical-4ab45421122d83848656a2cdb3d2e5db29034ddd.tar.bz2
historical-4ab45421122d83848656a2cdb3d2e5db29034ddd.zip
Fix bug #406163, bug #409269, bug #417171, bug #417537 and bug #417541 in Clang 3.1
Package-Manager: portage-2.1.10.49/cvs/Linux x86_64
Diffstat (limited to 'sys-devel/clang')
-rw-r--r--sys-devel/clang/ChangeLog12
-rw-r--r--sys-devel/clang/Manifest8
-rw-r--r--sys-devel/clang/clang-3.1-r1.ebuild (renamed from sys-devel/clang/clang-3.1.ebuild)19
-rw-r--r--sys-devel/clang/files/clang-3.1-gentoo-freebsd-fix-cxx-paths.patch187
-rw-r--r--sys-devel/clang/files/clang-3.1-gentoo-freebsd-fix-lib-path.patch12
-rw-r--r--sys-devel/clang/files/clang-3.1-gentoo-linux-fix-cxx-include.patch13
-rw-r--r--sys-devel/clang/files/clang-3.1-gentoo-runtime-gcc-detection.patch26
7 files changed, 272 insertions, 5 deletions
diff --git a/sys-devel/clang/ChangeLog b/sys-devel/clang/ChangeLog
index e16ff795cea4..30768ed21e96 100644
--- a/sys-devel/clang/ChangeLog
+++ b/sys-devel/clang/ChangeLog
@@ -1,6 +1,16 @@
# ChangeLog for sys-devel/clang
# Copyright 1999-2012 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/sys-devel/clang/ChangeLog,v 1.62 2012/05/24 13:00:09 ryao Exp $
+# $Header: /var/cvsroot/gentoo-x86/sys-devel/clang/ChangeLog,v 1.63 2012/05/26 01:34:57 ryao Exp $
+
+*clang-3.1-r1 (26 May 2012)
+
+ 26 May 2012; Richard Yao <ryao@gentoo.org> +clang-3.1-r1.ebuild,
+ +files/clang-3.1-gentoo-freebsd-fix-cxx-paths.patch,
+ +files/clang-3.1-gentoo-freebsd-fix-lib-path.patch,
+ +files/clang-3.1-gentoo-linux-fix-cxx-include.patch,
+ +files/clang-3.1-gentoo-runtime-gcc-detection.patch, -clang-3.1.ebuild:
+ Fix bug #406163, bug #409269, bug #417171, bug #417537 and bug #417541 in
+ Clang 3.1
*clang-3.0-r4 (24 May 2012)
diff --git a/sys-devel/clang/Manifest b/sys-devel/clang/Manifest
index 2eacad6a5137..0e52a8c11b3d 100644
--- a/sys-devel/clang/Manifest
+++ b/sys-devel/clang/Manifest
@@ -10,6 +10,10 @@ AUX clang-3.0-gentoo-binutils-apple.patch 1113 RMD160 117b47ecb72589f5226bba9add
AUX clang-3.0-linux-runtime-gcc-detection.patch 1728 RMD160 113d1b57ac276bd0eb312ae9540be82575706c99 SHA1 327be62747e8c78bea725036e3d4113a12816725 SHA256 aed41e3d05c57d2dd027a13023b12c2ea0d90b56427b0af393264f2a5a242595
AUX clang-3.0-recognize-amd-k10-enable-sse4a.patch 2555 RMD160 de8ebe104708ac4f8c2effae7b0982e92bd31564 SHA1 5065ca8005a8a47649d5bc18eac78db12e5c27db SHA256 46d05e49cefe2f86a562062d7b11e03ecb4ec7a146ee9f674d9a31dda4af9faf
AUX clang-3.1-fix_cxx_include_root.patch 1132 RMD160 68e10411c7848dcedd58707f3284766c05a024fc SHA1 37ce2ac8dca7b0ccf63136f9c1898503b98e5ec4 SHA256 9b26379cc9f73dbc9d395a64e46bcec5544866409be6258316ad4fb6ec697f1b
+AUX clang-3.1-gentoo-freebsd-fix-cxx-paths.patch 7959 RMD160 c00347f375bde4ef8c3aed9f1fe839175997fa6a SHA1 115bc02cf3ff10020da1d5fb6236ed38bf4aa635 SHA256 60e2477ff37baa3c43877a5962e39d88b1ad885f50aee418a44f53d7f5e87632
+AUX clang-3.1-gentoo-freebsd-fix-lib-path.patch 646 RMD160 5c78398bf16c0cad3cc1d4c018cd8eb3dfeac30d SHA1 e9d5e4183ab8729d167afcdb7923ab8e9abe7c49 SHA256 4e0ac4fd0d5ce22d055c010d6696f8e625cfe56b10e26dc6575c81084c151751
+AUX clang-3.1-gentoo-linux-fix-cxx-include.patch 836 RMD160 1ec5d07904cb6f8bac1bd6b364a23529695385ec SHA1 1e9d097f521bc1ac5ee04971442c069b07c20607 SHA256 5fa3d5094321084fdffad75492007c5f194cab2d4bb3b6d5eceaeae28ee1a1c0
+AUX clang-3.1-gentoo-runtime-gcc-detection.patch 1272 RMD160 c204c5aac4eb7be0247c65f2fee6246d63b3cb72 SHA1 a86028612d67b16d77973735028778260cbd3832 SHA256 d50176ae5aa1264bc8dd18c8e25e316d14bc0e8237e58980779d7f76d528d187
DIST clang-2.8.tgz 5666777 RMD160 f00956b6de29cc09f3992aeabd140f2189c6cf39 SHA1 94977c84ce136307dbbeade95e67bfe3c25161ff SHA256 ed83481553e6a39a8a2953e89630d881d87833506f096a90f18d93ec2bdee0c1
DIST clang-2.9.tgz 6243772 RMD160 4ab79cbd0e2ad25a2272e6ee2fbbf546818dbd73 SHA1 5fd3b5cec050ec12858c1602b23cf096282ad4a4 SHA256 70c41f3f782a71cbaa7bc8d6ea29fce4263ad3e8558dfecc6dc11cdef17909df
DIST clang-3.0.tar.gz 7240578 RMD160 640b309116db4357627c0b81ebba5dab824d9eeb SHA1 1fa11f07f957bd9c9de003d1b5a7a9ba1e0055e4 SHA256 b64e72da356d7c3428cfd7ac620d49ec042c84eaee13c26024879f555f4e126d
@@ -21,7 +25,7 @@ DIST llvm-3.1.src.tar.gz 11077429 RMD160 ceb0ef36ab6109da7a8568b04de759752dbee5a
EBUILD clang-2.8-r3.ebuild 6768 RMD160 7b552f45bca12124fe5659a9d3690b60706d14cb SHA1 c3b42800e461cda5852961f912e4ac0609062e0c SHA256 604b2964d566197adda982e6c1e6cdcc3365596ccfabadafe60e316049edabd7
EBUILD clang-2.9-r1.ebuild 6431 RMD160 cb9ed182675f9a76beb2caa0fc1fe26bfc534dd9 SHA1 1a7a912396c7d1823cd1867bb4be9679a31b2c0e SHA256 f9993c92ea46a43debdf55563b70093530e1eabebcee270c01e4d0e3b9490d1a
EBUILD clang-3.0-r4.ebuild 7155 RMD160 65d79627dfaa26bfd327dd173bb4b2b69883e4ca SHA1 ded3b2503e357a8335a816774fb4fcc4deceb50c SHA256 012f34451fdaaf2cc6947e013ba584a8df07bd37b15fb48ba436da71da436aad
-EBUILD clang-3.1.ebuild 5379 RMD160 6625c32a7856f6878b42319dc425813626c86f56 SHA1 a98914e57f356e02bd88432618cfd11bb50fd6b5 SHA256 8a8c2658b2b940524bc71ad8b3b82f545d7877b756a0a5e5b0b2bd240a345b65
+EBUILD clang-3.1-r1.ebuild 6078 RMD160 9240f45ff4f9b9fefde458968aa4002bd6409aa3 SHA1 60421abed151ce0a463b978c2d15d0236fb16d97 SHA256 92f13108a43de981b35437e9b7b68861fce5be395f313d4298b53d2e7e6999fe
EBUILD clang-9999.ebuild 5654 RMD160 841c52548946fbb662ecf07653d8f7d77ba83607 SHA1 f1a1639d29f9da5e775c9df29620df16168fe801 SHA256 f6c8ec9c9439859eae3f1a71d55e91fe8f51ba07249cddaaf2191898743cd7cd
-MISC ChangeLog 11971 RMD160 d7e70af5dab452c359d453cbf8f52ce6bf84d5af SHA1 c13106987bd39a5d6e1d30b2d6fd428146bda7d8 SHA256 59e9ec18a0185e189120d73f687f87e6c8ba7bb6414a388abb15f2b3e2e38d24
+MISC ChangeLog 12394 RMD160 c45d72533cf03153869f4f56bca930316201b210 SHA1 4e9c83a492476ed643204463afc505c5004ce480 SHA256 a9bf629cb7fbf98f72c7043fdc84f419a52e77aa3e67ef20e6e51c02f2c888b6
MISC metadata.xml 1433 RMD160 bff5bd3bda0d6f2e8cbf2fb08e69e373c3184276 SHA1 3607c4f901a2f06ced2fa1fbbe81d83b579f5f1d SHA256 b1863d24caf445334a13132900dad174f320b12adcf5df278dcbf41d180ba03d
diff --git a/sys-devel/clang/clang-3.1.ebuild b/sys-devel/clang/clang-3.1-r1.ebuild
index 6fdd456047be..0843db9e4053 100644
--- a/sys-devel/clang/clang-3.1.ebuild
+++ b/sys-devel/clang/clang-3.1-r1.ebuild
@@ -1,6 +1,6 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/sys-devel/clang/clang-3.1.ebuild,v 1.1 2012/05/23 20:46:57 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/sys-devel/clang/clang-3.1-r1.ebuild,v 1.1 2012/05/26 01:34:57 ryao Exp $
EAPI=4
@@ -18,7 +18,7 @@ SRC_URI="http://llvm.org/releases/${PV}/llvm-${PV}.src.tar.gz
LICENSE="UoI-NCSA"
SLOT="0"
KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux ~ppc-macos"
-IUSE="debug multitarget +static-analyzer test"
+IUSE="debug kernel_FreeBSD multitarget +static-analyzer test"
DEPEND="static-analyzer? ( dev-lang/perl )"
RDEPEND="~sys-devel/llvm-${PV}[multitarget=]"
@@ -69,6 +69,18 @@ src_prepare() {
sed -e "/^llc_props =/s/os.path.join(llvm_tools_dir, 'llc')/'llc'/" \
-i tools/clang/test/lit.cfg || die "test path sed failed"
+ # Automatically select active system GCC's libraries, bug #406163
+ epatch "${FILESDIR}"/${P}-gentoo-runtime-gcc-detection.patch
+
+ # Fix search paths on FreeBSD, bug #409269
+ epatch "${FILESDIR}"/${P}-gentoo-freebsd-fix-lib-path.patch
+
+ # Fix regression caused by removal of USE=system-cxx-headers, bug #417541
+ epatch "${FILESDIR}"/${P}-gentoo-freebsd-fix-cxx-paths.patch
+
+ # Fix regression that prevents Clang from building itself on Linux, bug #417537
+ epatch "${FILESDIR}"/${P}-gentoo-linux-fix-cxx-include.patch
+
# User patches
epatch_user
}
@@ -165,6 +177,9 @@ src_install() {
eend $?
done
fi
+
+ # Remove unnecessary headers on FreeBSD, bug #417171
+ use kernel_FreeBSD && rm "${ED}/usr/lib/clang/3.1/include/"{arm_neon,std,float,iso,limits,tgmath,varargs}*.h
}
pkg_postinst() {
diff --git a/sys-devel/clang/files/clang-3.1-gentoo-freebsd-fix-cxx-paths.patch b/sys-devel/clang/files/clang-3.1-gentoo-freebsd-fix-cxx-paths.patch
new file mode 100644
index 000000000000..987aa22d9518
--- /dev/null
+++ b/sys-devel/clang/files/clang-3.1-gentoo-freebsd-fix-cxx-paths.patch
@@ -0,0 +1,187 @@
+diff --git a/a/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.cpp b/b/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.cpp
+index 1e282f2..1d6835b 100644
+--- a/a/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.cpp
++++ b/b/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.cpp
+@@ -2305,6 +2305,161 @@ void Linux::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
+ }
+ }
+
++void FreeBSD::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
++ ArgStringList &CC1Args) const {
++ const Driver &D = getDriver();
++
++ if (DriverArgs.hasArg(options::OPT_nostdinc))
++ return;
++
++ if (!DriverArgs.hasArg(options::OPT_nostdlibinc))
++ addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/usr/local/include");
++
++ if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
++ llvm::sys::Path P(D.ResourceDir);
++ P.appendComponent("include");
++ addSystemInclude(DriverArgs, CC1Args, P.str());
++ }
++
++ if (DriverArgs.hasArg(options::OPT_nostdlibinc))
++ return;
++
++ // Check for configure-time C include directories.
++ StringRef CIncludeDirs(C_INCLUDE_DIRS);
++ if (CIncludeDirs != "") {
++ SmallVector<StringRef, 5> dirs;
++ CIncludeDirs.split(dirs, ":");
++ for (SmallVectorImpl<StringRef>::iterator I = dirs.begin(), E = dirs.end();
++ I != E; ++I) {
++ StringRef Prefix = llvm::sys::path::is_absolute(*I) ? D.SysRoot : "";
++ addExternCSystemInclude(DriverArgs, CC1Args, Prefix + *I);
++ }
++ return;
++ }
++
++ // Lacking those, try to detect the correct set of system includes for the
++ // target triple.
++
++ // Implement generic Debian multiarch support.
++ const StringRef X86_64MultiarchIncludeDirs[] = {
++ "/usr/include/x86_64-linux-gnu",
++
++ // FIXME: These are older forms of multiarch. It's not clear that they're
++ // in use in any released version of Debian, so we should consider
++ // removing them.
++ "/usr/include/i686-linux-gnu/64",
++ "/usr/include/i486-linux-gnu/64"
++ };
++ const StringRef X86MultiarchIncludeDirs[] = {
++ "/usr/include/i386-linux-gnu",
++
++ // FIXME: These are older forms of multiarch. It's not clear that they're
++ // in use in any released version of Debian, so we should consider
++ // removing them.
++ "/usr/include/x86_64-linux-gnu/32",
++ "/usr/include/i686-linux-gnu",
++ "/usr/include/i486-linux-gnu"
++ };
++ const StringRef ARMMultiarchIncludeDirs[] = {
++ "/usr/include/arm-linux-gnueabi"
++ };
++ const StringRef MIPSMultiarchIncludeDirs[] = {
++ "/usr/include/mips-linux-gnu"
++ };
++ const StringRef MIPSELMultiarchIncludeDirs[] = {
++ "/usr/include/mipsel-linux-gnu"
++ };
++ const StringRef PPCMultiarchIncludeDirs[] = {
++ "/usr/include/powerpc-linux-gnu"
++ };
++ const StringRef PPC64MultiarchIncludeDirs[] = {
++ "/usr/include/powerpc64-linux-gnu"
++ };
++ ArrayRef<StringRef> MultiarchIncludeDirs;
++ if (getTriple().getArch() == llvm::Triple::x86_64) {
++ MultiarchIncludeDirs = X86_64MultiarchIncludeDirs;
++ } else if (getTriple().getArch() == llvm::Triple::x86) {
++ MultiarchIncludeDirs = X86MultiarchIncludeDirs;
++ } else if (getTriple().getArch() == llvm::Triple::arm) {
++ MultiarchIncludeDirs = ARMMultiarchIncludeDirs;
++ } else if (getTriple().getArch() == llvm::Triple::mips) {
++ MultiarchIncludeDirs = MIPSMultiarchIncludeDirs;
++ } else if (getTriple().getArch() == llvm::Triple::mipsel) {
++ MultiarchIncludeDirs = MIPSELMultiarchIncludeDirs;
++ } else if (getTriple().getArch() == llvm::Triple::ppc) {
++ MultiarchIncludeDirs = PPCMultiarchIncludeDirs;
++ } else if (getTriple().getArch() == llvm::Triple::ppc64) {
++ MultiarchIncludeDirs = PPC64MultiarchIncludeDirs;
++ }
++ for (ArrayRef<StringRef>::iterator I = MultiarchIncludeDirs.begin(),
++ E = MultiarchIncludeDirs.end();
++ I != E; ++I) {
++ if (llvm::sys::fs::exists(D.SysRoot + *I)) {
++ addExternCSystemInclude(DriverArgs, CC1Args, D.SysRoot + *I);
++ break;
++ }
++ }
++
++ if (getTriple().getOS() == llvm::Triple::RTEMS)
++ return;
++
++ // Add an include of '/include' directly. This isn't provided by default by
++ // system GCCs, but is often used with cross-compiling GCCs, and harmless to
++ // add even when Clang is acting as-if it were a system compiler.
++ addExternCSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/include");
++
++ addExternCSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/usr/include");
++}
++
++/// \brief Helper to add the thre variant paths for a libstdc++ installation.
++/*static*/ bool FreeBSD::addLibStdCXXIncludePaths(Twine Base, Twine TargetArchDir,
++ const ArgList &DriverArgs,
++ ArgStringList &CC1Args) {
++ if (!llvm::sys::fs::exists(Base))
++ return false;
++ addSystemInclude(DriverArgs, CC1Args, Base);
++ addSystemInclude(DriverArgs, CC1Args, Base + "/" + TargetArchDir);
++ addSystemInclude(DriverArgs, CC1Args, Base + "/backward");
++ return true;
++}
++
++void FreeBSD::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
++ ArgStringList &CC1Args) const {
++ if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
++ DriverArgs.hasArg(options::OPT_nostdincxx))
++ return;
++
++ // Check if libc++ has been enabled and provide its include paths if so.
++ if (GetCXXStdlibType(DriverArgs) == ToolChain::CST_Libcxx) {
++ // libc++ is always installed at a fixed path on Linux currently.
++ addSystemInclude(DriverArgs, CC1Args,
++ getDriver().SysRoot + "/usr/include/c++/v1");
++ return;
++ }
++
++ // We need a detected GCC installation on Linux to provide libstdc++'s
++ // headers. We handled the libc++ case above.
++ if (!GCCInstallation.isValid())
++ return;
++
++ // By default, look for the C++ headers in an include directory adjacent to
++ // the lib directory of the GCC installation. Note that this is expect to be
++ // equivalent to '/usr/include/c++/X.Y' in almost all cases.
++ StringRef LibDir = GCCInstallation.getParentLibPath();
++ StringRef InstallDir = GCCInstallation.getInstallPath();
++ StringRef Version = GCCInstallation.getVersion();
++ if (!addLibStdCXXIncludePaths(LibDir + "/../include/c++/" + Version,
++ (GCCInstallation.getTriple().str() +
++ GCCInstallation.getMultiarchSuffix()),
++ DriverArgs, CC1Args)) {
++ // Gentoo is weird and places its headers inside the GCC install, so if the
++ // first attempt to find the headers fails, try this pattern.
++ addLibStdCXXIncludePaths(InstallDir + "/include/g++-v4",
++ getDriver().DefaultTargetTriple,
++ DriverArgs, CC1Args);
++ }
++}
++
+ /// DragonFly - DragonFly tool chain which can call as(1) and ld(1) directly.
+
+ DragonFly::DragonFly(const Driver &D, const llvm::Triple& Triple, const ArgList &Args)
+diff --git a/a/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.h b/b/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.h
+index eaa6be1..bba891e 100644
+--- a/a/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.h
++++ b/b/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.h
+@@ -489,6 +489,16 @@ public:
+
+ virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
+ const ActionList &Inputs) const;
++
++ virtual void AddClangSystemIncludeArgs(const ArgList &DriverArgs,
++ ArgStringList &CC1Args) const;
++ virtual void AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
++ ArgStringList &CC1Args) const;
++
++private:
++ static bool addLibStdCXXIncludePaths(Twine Base, Twine TargetArchDir,
++ const ArgList &DriverArgs,
++ ArgStringList &CC1Args);
+ };
+
+ class LLVM_LIBRARY_VISIBILITY NetBSD : public Generic_ELF {
diff --git a/sys-devel/clang/files/clang-3.1-gentoo-freebsd-fix-lib-path.patch b/sys-devel/clang/files/clang-3.1-gentoo-freebsd-fix-lib-path.patch
new file mode 100644
index 000000000000..69ce7820df2b
--- /dev/null
+++ b/sys-devel/clang/files/clang-3.1-gentoo-freebsd-fix-lib-path.patch
@@ -0,0 +1,12 @@
+diff -upNr a/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.cpp b/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.cpp
+--- a/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.cpp 2012-05-24 04:08:48.393073000 -0400
++++ b/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.cpp 2012-05-24 04:11:38.113153421 -0400
+@@ -1635,6 +1635,8 @@ FreeBSD::FreeBSD(const Driver &D, const
+ getFilePaths().push_back(getDriver().SysRoot + "/usr/lib32");
+ else
+ getFilePaths().push_back(getDriver().SysRoot + "/usr/lib");
++
++ getFilePaths().push_back(GCCInstallation.getInstallPath());
+ }
+
+ Tool &FreeBSD::SelectTool(const Compilation &C, const JobAction &JA,
diff --git a/sys-devel/clang/files/clang-3.1-gentoo-linux-fix-cxx-include.patch b/sys-devel/clang/files/clang-3.1-gentoo-linux-fix-cxx-include.patch
new file mode 100644
index 000000000000..0a8beef5300b
--- /dev/null
+++ b/sys-devel/clang/files/clang-3.1-gentoo-linux-fix-cxx-include.patch
@@ -0,0 +1,13 @@
+diff -upNr a/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.cpp b/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.cpp
+--- a/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.cpp 2012-05-25 20:32:28.859469000 -0400
++++ b/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.cpp 2012-05-25 20:33:15.988680000 -0400
+@@ -2305,8 +2305,7 @@ void Linux::AddClangCXXStdlibIncludeArgs
+ // Gentoo is weird and places its headers inside the GCC install, so if the
+ // first attempt to find the headers fails, try this pattern.
+ addLibStdCXXIncludePaths(InstallDir + "/include/g++-v4",
+- (GCCInstallation.getTriple().str() +
+- GCCInstallation.getMultiarchSuffix()),
++ getDriver().DefaultTargetTriple,
+ DriverArgs, CC1Args);
+ }
+ }
diff --git a/sys-devel/clang/files/clang-3.1-gentoo-runtime-gcc-detection.patch b/sys-devel/clang/files/clang-3.1-gentoo-runtime-gcc-detection.patch
new file mode 100644
index 000000000000..6f0fca07ebb6
--- /dev/null
+++ b/sys-devel/clang/files/clang-3.1-gentoo-runtime-gcc-detection.patch
@@ -0,0 +1,26 @@
+diff -upNr a/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.cpp b/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.cpp
+--- a/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.cpp 2012-05-24 03:32:31.593191000 -0400
++++ b/llvm-3.1.src/tools/clang/lib/Driver/ToolChains.cpp 2012-05-24 03:38:31.733163513 -0400
+@@ -1145,6 +1145,22 @@ Generic_GCC::GCCInstallationDetector::GC
+ Prefixes.push_back(D.InstalledDir + "/..");
+ }
+
++ llvm::OwningPtr<llvm::MemoryBuffer> File;
++ if (!llvm::MemoryBuffer::getFile(D.SysRoot + "/etc/env.d/gcc/config-" + D.DefaultTargetTriple, File))
++ {
++ bool Exists;
++ const std::string VersionText = File.get()->getBuffer().rsplit('-').second.substr(0,5).str();
++ const std::string GentooPath = D.SysRoot + "/usr/lib/gcc/" + D.DefaultTargetTriple + "/" + VersionText;
++ if (!llvm::sys::fs::exists(GentooPath + "/crtbegin.o", Exists) && Exists)
++ {
++ Version = GCCVersion::Parse(VersionText);
++ GCCInstallPath = GentooPath;
++ GCCParentLibPath = GCCInstallPath + "/../../..";
++ IsValid = true;
++ return;
++ }
++ }
++
+ // Loop over the various components which exist and select the best GCC
+ // installation available. GCC installs are ranked by version number.
+ Version = GCCVersion::Parse("0.0.0");