summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenda Xu <heroxbd@gentoo.org>2015-11-12 17:23:13 +0900
committerBenda Xu <heroxbd@gentoo.org>2015-11-12 17:23:13 +0900
commit54f0d5937f1587c16d68927a9a471d06612714e3 (patch)
treefe750c7028db566ae1bcc165244734017141451e /sys-devel/llvm/files
parentdev-lang/perl: 5.22 for RAP. (diff)
downloadheroxbd-54f0d5937f1587c16d68927a9a471d06612714e3.tar.gz
heroxbd-54f0d5937f1587c16d68927a9a471d06612714e3.tar.bz2
heroxbd-54f0d5937f1587c16d68927a9a471d06612714e3.zip
sys-devel/llvm: add.
Diffstat (limited to 'sys-devel/llvm/files')
-rw-r--r--sys-devel/llvm/files/cl-patches/0001-r600-Add-some-intrinsic-definitions.patch64
-rw-r--r--sys-devel/llvm/files/cl-patches/0002-r600-Add-get_global_size-and-get_local_size-intrinsi.patch27
-rw-r--r--sys-devel/llvm/files/clang-3.1-gentoo-runtime-gcc-detection-v3.patch29
-rw-r--r--sys-devel/llvm/files/clang-3.3-gcc-header-path.patch90
-rw-r--r--sys-devel/llvm/files/clang-3.3-gentoo-install.patch71
-rw-r--r--sys-devel/llvm/files/clang-3.4-darwin_build_fix.patch47
-rw-r--r--sys-devel/llvm/files/clang-3.4-darwin_prefix-include-paths.patch18
-rw-r--r--sys-devel/llvm/files/clang-3.4-gentoo-install.patch80
-rw-r--r--sys-devel/llvm/files/clang-3.5-gentoo-install.patch57
-rw-r--r--sys-devel/llvm/files/clang-3.5-gentoo-runtime-gcc-detection-v3.patch42
-rw-r--r--sys-devel/llvm/files/clang-3.6-fbsd-gcc49.patch25
-rw-r--r--sys-devel/llvm/files/clang-3.6-gentoo-install.patch48
-rw-r--r--sys-devel/llvm/files/clang-3.7-strip_doc_refs.patch42
-rw-r--r--sys-devel/llvm/files/cmake/0002-cmake-Support-overriding-Sphinx-HTML-doc-install-dir.patch36
-rw-r--r--sys-devel/llvm/files/cmake/0003-cmake-Add-an-ordering-dep-between-HTML-man-Sphinx-ta.patch32
-rw-r--r--sys-devel/llvm/files/cmake/0004-cmake-Do-not-install-libgtest.patch28
-rw-r--r--sys-devel/llvm/files/cmake/clang-0001-Install-clang-runtime-into-usr-lib-without-suffix-3.8.patch37
-rw-r--r--sys-devel/llvm/files/cmake/clang-0001-Install-clang-runtime-into-usr-lib-without-suffix.patch52
-rw-r--r--sys-devel/llvm/files/cmake/clang-0002-cmake-Make-CLANG_LIBDIR_SUFFIX-overridable.patch28
-rw-r--r--sys-devel/llvm/files/cmake/compiler-rt-0001-cmake-Install-compiler-rt-into-usr-lib-without-suffi.patch25
-rw-r--r--sys-devel/llvm/files/cmake/llvm-3.7.0-ocaml-multilib.patch43
-rw-r--r--sys-devel/llvm/files/cmake/llvm-3.8-allow_custom_cmake_build_types.patch14
-rw-r--r--sys-devel/llvm/files/llvm-2.6-commandguide-nops.patch30
-rw-r--r--sys-devel/llvm/files/llvm-2.7-nodoctargz.patch47
-rw-r--r--sys-devel/llvm/files/llvm-2.8-alignof.patch59
-rw-r--r--sys-devel/llvm/files/llvm-2.8-darwin8.patch15
-rw-r--r--sys-devel/llvm/files/llvm-2.9-Operator.h-c++0x.patch57
-rw-r--r--sys-devel/llvm/files/llvm-2.9-gcc4.7.patch14
-rw-r--r--sys-devel/llvm/files/llvm-2.9-nodoctargz.patch39
-rw-r--r--sys-devel/llvm/files/llvm-3.0-PPCCompilationCallbackC_static.patch27
-rw-r--r--sys-devel/llvm/files/llvm-3.0-PPC_macro.patch43
-rw-r--r--sys-devel/llvm/files/llvm-3.0-gold_LTO_link.patch10
-rw-r--r--sys-devel/llvm/files/llvm-3.0-ocaml_install.patch16
-rw-r--r--sys-devel/llvm/files/llvm-3.0-set_soname.patch12
-rw-r--r--sys-devel/llvm/files/llvm-3.1-ExecutionEngine_tests_xfail_arm.patch27
-rw-r--r--sys-devel/llvm/files/llvm-3.1-docs-pod-markup-fixes.patch28
-rw-r--r--sys-devel/llvm/files/llvm-3.1-fix_debug_line_info.patch65
-rw-r--r--sys-devel/llvm/files/llvm-3.1-ivybridge_support.patch13
-rw-r--r--sys-devel/llvm/files/llvm-3.2-nodoctargz.patch45
-rw-r--r--sys-devel/llvm/files/llvm-3.3-R600_debug.patch22
-rw-r--r--sys-devel/llvm/files/llvm-3.3-cmake-modulepath.patch24
-rw-r--r--sys-devel/llvm/files/llvm-3.3-gentoo-install.patch141
-rw-r--r--sys-devel/llvm/files/llvm-3.3-insecure-rpath.patch30
-rw-r--r--sys-devel/llvm/files/llvm-3.3-r2-gentoo-install.patch117
-rw-r--r--sys-devel/llvm/files/llvm-3.4-cmake-configparser.patch35
-rw-r--r--sys-devel/llvm/files/llvm-3.4-fix_varargs.patch148
-rw-r--r--sys-devel/llvm/files/llvm-3.4-gentoo-install.patch96
-rw-r--r--sys-devel/llvm/files/llvm-3.5-gcc-4.9.patch43
-rw-r--r--sys-devel/llvm/files/llvm-3.5-gentoo-install.patch83
-rw-r--r--sys-devel/llvm/files/llvm-3.5.0-fix_LLVMExports_cmake.patch39
-rw-r--r--sys-devel/llvm/files/llvm-3.5.2-gcc-5.1.patch14
-rw-r--r--sys-devel/llvm/files/llvm-3.6-gentoo-install.patch82
-rw-r--r--sys-devel/llvm/files/llvm-3.6.0-ocaml-ctypes-0.4.0.patch35
-rw-r--r--sys-devel/llvm/files/llvm-3.7-nodoctargz.patch49
54 files changed, 2440 insertions, 0 deletions
diff --git a/sys-devel/llvm/files/cl-patches/0001-r600-Add-some-intrinsic-definitions.patch b/sys-devel/llvm/files/cl-patches/0001-r600-Add-some-intrinsic-definitions.patch
new file mode 100644
index 0000000..9d99c9c
--- /dev/null
+++ b/sys-devel/llvm/files/cl-patches/0001-r600-Add-some-intrinsic-definitions.patch
@@ -0,0 +1,64 @@
+From e25389b66b5ced3a2b5461077dcc9a505d334e3d Mon Sep 17 00:00:00 2001
+From: Tom Stellard <thomas.stellard@amd.com>
+Date: Tue, 13 Mar 2012 14:12:21 -0400
+Subject: [PATCH 1/2] r600: Add some intrinsic definitions
+
+---
+ include/llvm/Intrinsics.td | 1 +
+ include/llvm/IntrinsicsR600.td | 35 +++++++++++++++++++++++++++++++++++
+ 2 files changed, 36 insertions(+), 0 deletions(-)
+ create mode 100644 include/llvm/IntrinsicsR600.td
+
+diff --git a/include/llvm/Intrinsics.td b/include/llvm/Intrinsics.td
+index 069f907..e90dd85 100644
+--- a/include/llvm/Intrinsics.td
++++ b/include/llvm/Intrinsics.td
+@@ -441,3 +441,4 @@ include "llvm/IntrinsicsCellSPU.td"
+ include "llvm/IntrinsicsXCore.td"
+ include "llvm/IntrinsicsPTX.td"
+ include "llvm/IntrinsicsHexagon.td"
++include "llvm/IntrinsicsR600.td"
+diff --git a/include/llvm/IntrinsicsR600.td b/include/llvm/IntrinsicsR600.td
+new file mode 100644
+index 0000000..789fecb
+--- /dev/null
++++ b/include/llvm/IntrinsicsR600.td
+@@ -0,0 +1,35 @@
++//===- IntrinsicsR600.td - Defines R600 intrinsics ---------*- tablegen -*-===//
++//
++// The LLVM Compiler Infrastructure
++//
++// This file is distributed under the University of Illinois Open Source
++// License. See LICENSE.TXT for details.
++//
++//===----------------------------------------------------------------------===//
++//
++// This file defines all of the R600-specific intrinsics.
++//
++//===----------------------------------------------------------------------===//
++//
++// Authors: Tom Stellard <thomas.stellard@amd.com>
++//
++
++let TargetPrefix = "r600" in {
++
++class R600ReadPreloadRegisterIntrinsic<string name>
++ : Intrinsic<[llvm_i32_ty], [], [IntrNoMem]>,
++ GCCBuiltin<name>;
++
++multiclass R600ReadPreloadRegisterIntrinsic_xyz<string prefix> {
++ def _x : R600ReadPreloadRegisterIntrinsic<!strconcat(prefix, "_x")>;
++ def _y : R600ReadPreloadRegisterIntrinsic<!strconcat(prefix, "_y")>;
++ def _z : R600ReadPreloadRegisterIntrinsic<!strconcat(prefix, "_z")>;
++}
++
++defm int_r600_read_ngroups : R600ReadPreloadRegisterIntrinsic_xyz <
++ "__builtin_r600_read_ngroups">;
++defm int_r600_read_tgid : R600ReadPreloadRegisterIntrinsic_xyz <
++ "__builtin_r600_read_tgid">;
++defm int_r600_read_tidig : R600ReadPreloadRegisterIntrinsic_xyz <
++ "__builtin_r600_read_tidig">;
++} // End TargetPrefix = "r600"
+--
+1.7.7.6
+
diff --git a/sys-devel/llvm/files/cl-patches/0002-r600-Add-get_global_size-and-get_local_size-intrinsi.patch b/sys-devel/llvm/files/cl-patches/0002-r600-Add-get_global_size-and-get_local_size-intrinsi.patch
new file mode 100644
index 0000000..db176dd
--- /dev/null
+++ b/sys-devel/llvm/files/cl-patches/0002-r600-Add-get_global_size-and-get_local_size-intrinsi.patch
@@ -0,0 +1,27 @@
+From 17667fa3450470f7c89fc2ba4631d908cf510749 Mon Sep 17 00:00:00 2001
+From: Tom Stellard <thomas.stellard@amd.com>
+Date: Wed, 14 Mar 2012 11:19:35 -0400
+Subject: [PATCH 2/2] r600: Add get_global_size and get_local_size intrinsics
+
+---
+ include/llvm/IntrinsicsR600.td | 4 ++++
+ 1 files changed, 4 insertions(+), 0 deletions(-)
+
+diff --git a/include/llvm/IntrinsicsR600.td b/include/llvm/IntrinsicsR600.td
+index 789fecb..0473acb 100644
+--- a/include/llvm/IntrinsicsR600.td
++++ b/include/llvm/IntrinsicsR600.td
+@@ -26,6 +26,10 @@ multiclass R600ReadPreloadRegisterIntrinsic_xyz<string prefix> {
+ def _z : R600ReadPreloadRegisterIntrinsic<!strconcat(prefix, "_z")>;
+ }
+
++defm int_r600_read_global_size : R600ReadPreloadRegisterIntrinsic_xyz <
++ "__builtin_r600_read_global_size">;
++defm int_r600_read_local_size : R600ReadPreloadRegisterIntrinsic_xyz <
++ "__builtin_r600_read_local_size">;
+ defm int_r600_read_ngroups : R600ReadPreloadRegisterIntrinsic_xyz <
+ "__builtin_r600_read_ngroups">;
+ defm int_r600_read_tgid : R600ReadPreloadRegisterIntrinsic_xyz <
+--
+1.7.7.6
+
diff --git a/sys-devel/llvm/files/clang-3.1-gentoo-runtime-gcc-detection-v3.patch b/sys-devel/llvm/files/clang-3.1-gentoo-runtime-gcc-detection-v3.patch
new file mode 100644
index 0000000..49f1085
--- /dev/null
+++ b/sys-devel/llvm/files/clang-3.1-gentoo-runtime-gcc-detection-v3.patch
@@ -0,0 +1,29 @@
+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,25 @@ Generic_GCC::GCCInstallationDetector::GC
+ Prefixes.push_back(D.InstalledDir + "/..");
+ }
+
++ llvm::OwningPtr<llvm::MemoryBuffer> File;
++ for (unsigned k = 0, ke = CandidateTripleAliases.size(); k < ke; ++k) {
++ if (!llvm::MemoryBuffer::getFile(D.SysRoot + "/etc/env.d/gcc/config-" + CandidateTripleAliases[k].str(), 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/" + CandidateTripleAliases[k].str() + "/" + VersionText;
++ if (!llvm::sys::fs::exists(GentooPath + "/crtbegin.o", Exists) && Exists)
++ {
++ Version = GCCVersion::Parse(VersionText);
++ GCCInstallPath = GentooPath;
++ GCCParentLibPath = GCCInstallPath + "/../../..";
++ GCCTriple.setTriple(CandidateTripleAliases[k]);
++ 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");
diff --git a/sys-devel/llvm/files/clang-3.3-gcc-header-path.patch b/sys-devel/llvm/files/clang-3.3-gcc-header-path.patch
new file mode 100644
index 0000000..dc9a4f7
--- /dev/null
+++ b/sys-devel/llvm/files/clang-3.3-gcc-header-path.patch
@@ -0,0 +1,90 @@
+Backport handling of 'g++-vX.Y' header location.
+
+Fixes: https://bugs.gentoo.org/show_bug.cgi?id=487584
+---
+ tools/clang/lib/Driver/ToolChains.cpp | 20 ++++++++++++--------
+ tools/clang/lib/Driver/ToolChains.h | 3 +++
+ 2 files changed, 15 insertions(+), 8 deletions(-)
+
+diff --git a/tools/clang/lib/Driver/ToolChains.cpp b/tools/clang/lib/Driver/ToolChains.cpp
+index 7c9e9c0..e38d42d 100644
+--- a/tools/clang/lib/Driver/ToolChains.cpp
++++ b/tools/clang/lib/Driver/ToolChains.cpp
+@@ -917,17 +917,19 @@ Darwin_Generic_GCC::ComputeEffectiveClangTriple(const ArgList &Args,
+ /// This is the primary means of forming GCCVersion objects.
+ /*static*/
+ Generic_GCC::GCCVersion Linux::GCCVersion::Parse(StringRef VersionText) {
+- const GCCVersion BadVersion = { VersionText.str(), -1, -1, -1, "" };
++ const GCCVersion BadVersion = { VersionText.str(), -1, -1, -1, "", "", "" };
+ std::pair<StringRef, StringRef> First = VersionText.split('.');
+ std::pair<StringRef, StringRef> Second = First.second.split('.');
+
+- GCCVersion GoodVersion = { VersionText.str(), -1, -1, -1, "" };
++ GCCVersion GoodVersion = { VersionText.str(), -1, -1, -1, "", "", "" };
+ if (First.first.getAsInteger(10, GoodVersion.Major) ||
+ GoodVersion.Major < 0)
+ return BadVersion;
++ GoodVersion.MajorStr = First.first.str();
+ if (Second.first.getAsInteger(10, GoodVersion.Minor) ||
+ GoodVersion.Minor < 0)
+ return BadVersion;
++ GoodVersion.MinorStr = Second.first.str();
+
+ // First look for a number prefix and parse that if present. Otherwise just
+ // stash the entire patch string in the suffix, and leave the number
+@@ -945,7 +947,7 @@ Generic_GCC::GCCVersion Linux::GCCVersion::Parse(StringRef VersionText) {
+ if (PatchText.slice(0, EndNumber).getAsInteger(10, GoodVersion.Patch) ||
+ GoodVersion.Patch < 0)
+ return BadVersion;
+- GoodVersion.PatchSuffix = PatchText.substr(EndNumber).str();
++ GoodVersion.PatchSuffix = PatchText.substr(EndNumber);
+ }
+ }
+
+@@ -2590,11 +2592,11 @@ void Linux::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
+ // equivalent to '/usr/include/c++/X.Y' in almost all cases.
+ StringRef LibDir = GCCInstallation.getParentLibPath();
+ StringRef InstallDir = GCCInstallation.getInstallPath();
+- StringRef Version = GCCInstallation.getVersion().Text;
+ StringRef TripleStr = GCCInstallation.getTriple().str();
++ const GCCVersion &Version = GCCInstallation.getVersion();
+
+ if (addLibStdCXXIncludePaths(LibDir.str() + "/../include",
+- "/c++/" + Version.str(),
++ "/c++/" + Version.Text,
+ TripleStr,
+ GCCInstallation.getMultiarchSuffix(),
+ DriverArgs, CC1Args))
+@@ -2602,10 +2604,12 @@ void Linux::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
+
+ const std::string IncludePathCandidates[] = {
+ // Gentoo is weird and places its headers inside the GCC install, so if the
+- // first attempt to find the headers fails, try this pattern.
+- InstallDir.str() + "/include/g++-v4",
++ // first attempt to find the headers fails, try these patterns.
++ InstallDir.str() + "/include/g++-v" + Version.MajorStr + "." +
++ Version.MinorStr,
++ InstallDir.str() + "/include/g++-v" + Version.MajorStr,
+ // Android standalone toolchain has C++ headers in yet another place.
+- LibDir.str() + "/../" + TripleStr.str() + "/include/c++/" + Version.str(),
++ LibDir.str() + "/../" + TripleStr.str() + "/include/c++/" + Version.Text,
+ // Freescale SDK C++ headers are directly in <sysroot>/usr/include/c++,
+ // without a subdirectory corresponding to the gcc version.
+ LibDir.str() + "/../include/c++",
+diff --git a/tools/clang/lib/Driver/ToolChains.h b/tools/clang/lib/Driver/ToolChains.h
+index 3afd8dd..04cf467 100644
+--- a/tools/clang/lib/Driver/ToolChains.h
++++ b/tools/clang/lib/Driver/ToolChains.h
+@@ -48,6 +48,9 @@ protected:
+ /// \brief The parsed major, minor, and patch numbers.
+ int Major, Minor, Patch;
+
++ /// \brief The text of the parsed major, and major+minor versions.
++ std::string MajorStr, MinorStr;
++
+ /// \brief Any textual suffix on the patch number.
+ std::string PatchSuffix;
+
+--
+1.8.3.2
+
diff --git a/sys-devel/llvm/files/clang-3.3-gentoo-install.patch b/sys-devel/llvm/files/clang-3.3-gentoo-install.patch
new file mode 100644
index 0000000..5519fbc
--- /dev/null
+++ b/sys-devel/llvm/files/clang-3.3-gentoo-install.patch
@@ -0,0 +1,71 @@
+From 1a539a8868070e49966c6b5f5e4b9f1257acd7dc Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <gentoo@mgorny.alt.pl>
+Date: Fri, 19 Jul 2013 10:23:57 +0200
+Subject: [PATCH] clang gentoo install
+
+---
+ tools/clang/lib/Driver/Tools.cpp | 4 ++--
+ tools/clang/tools/scan-build/scan-build | 4 ++--
+ tools/clang/tools/scan-view/scan-view | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/tools/clang/lib/Driver/Tools.cpp b/tools/clang/lib/Driver/Tools.cpp
+index e014980..6e60513 100644
+--- a/tools/clang/lib/Driver/Tools.cpp
++++ b/tools/clang/lib/Driver/Tools.cpp
+@@ -219,7 +219,7 @@ static void addProfileRT(const ToolChain &TC, const ArgList &Args,
+ // libprofile_rt.so. We used to use the -l:libprofile_rt.a syntax, but that is
+ // not supported by old linkers.
+ std::string ProfileRT =
+- std::string(TC.getDriver().Dir) + "/../lib/libprofile_rt.a";
++ "-l:libprofile_rt.a";
+
+ CmdArgs.push_back(Args.MakeArgString(ProfileRT));
+ }
+@@ -6177,7 +6177,7 @@ void gnutools::Link::ConstructJob(Compilation &C, const JobAction &JA,
+ // forward.
+ if (D.IsUsingLTO(Args) || Args.hasArg(options::OPT_use_gold_plugin)) {
+ CmdArgs.push_back("-plugin");
+- std::string Plugin = ToolChain.getDriver().Dir + "/../lib/LLVMgold.so";
++ std::string Plugin = ToolChain.getDriver().Dir + "/../@libdir@/LLVMgold.so";
+ CmdArgs.push_back(Args.MakeArgString(Plugin));
+
+ // Try to pass driver level flags relevant to LTO code generation down to
+diff --git a/tools/clang/tools/scan-build/scan-build b/tools/clang/tools/scan-build/scan-build
+index 22d5289..dcb4822 100755
+--- a/tools/clang/tools/scan-build/scan-build
++++ b/tools/clang/tools/scan-build/scan-build
+@@ -410,7 +410,7 @@ sub CopyFiles {
+
+ my $Dir = shift;
+
+- my $JS = Cwd::realpath("$RealBin/sorttable.js");
++ my $JS = Cwd::realpath("@EPREFIX@/usr/share/llvm/sorttable.js");
+
+ DieDiag("Cannot find 'sorttable.js'.\n")
+ if (! -r $JS);
+@@ -420,7 +420,7 @@ sub CopyFiles {
+ DieDiag("Could not copy 'sorttable.js' to '$Dir'.\n")
+ if (! -r "$Dir/sorttable.js");
+
+- my $CSS = Cwd::realpath("$RealBin/scanview.css");
++ my $CSS = Cwd::realpath("@EPREFIX@/usr/share/llvm/scanview.css");
+
+ DieDiag("Cannot find 'scanview.css'.\n")
+ if (! -r $CSS);
+diff --git a/tools/clang/tools/scan-view/scan-view b/tools/clang/tools/scan-view/scan-view
+index fb27da6..1f8ddb8 100755
+--- a/tools/clang/tools/scan-view/scan-view
++++ b/tools/clang/tools/scan-view/scan-view
+@@ -54,7 +54,7 @@ def start_browser(port, options):
+ webbrowser.open(url)
+
+ def run(port, options, root):
+- import ScanView
++ from clang import ScanView
+ try:
+ print 'Starting scan-view at: http://%s:%d'%(options.host,
+ port)
+--
+1.8.3.2
+
diff --git a/sys-devel/llvm/files/clang-3.4-darwin_build_fix.patch b/sys-devel/llvm/files/clang-3.4-darwin_build_fix.patch
new file mode 100644
index 0000000..113b04b
--- /dev/null
+++ b/sys-devel/llvm/files/clang-3.4-darwin_build_fix.patch
@@ -0,0 +1,47 @@
+Our (gcc/binutils) toolchain doesn't do ARM targets, hence we will get
+"unable to interface with target machine" errors while building if we
+attempt to. Disable those targets.
+
+Patch by Reza Jelveh from
+https://github.com/fishman/timebomb-gentoo-osx-overlay/blob/master/sys-devel/llvm/files/llvm-3.4-fix_darwin_build.patch
+
+--- a/projects/compiler-rt/make/platform/clang_darwin_embedded.mk
++++ b/projects/compiler-rt/make/platform/clang_darwin_embedded.mk
+@@ -27,20 +27,20 @@ UniversalArchs :=
+ # Soft-float version of the runtime. No floating-point instructions will be used
+ # and the ABI (out of necessity) passes floating values in normal registers:
+ # non-VFP variant of the AAPCS.
+-Configs += soft_static
+-UniversalArchs.soft_static := armv6m armv7m armv7em armv7
++# Configs += soft_static
++# UniversalArchs.soft_static := armv6m armv7m armv7em armv7
+
+ # Hard-float version of the runtime. On ARM VFP instructions and registers are
+ # allowed, and floating point values get passed in them. VFP variant of the
+ # AAPCS.
+ Configs += hard_static
+-UniversalArchs.hard_static := armv7em armv7 i386 x86_64
++UniversalArchs.hard_static := i386 x86_64
+
+-Configs += soft_pic
+-UniversalArchs.soft_pic := armv6m armv7m armv7em armv7
++# Configs += soft_pic
++# UniversalArchs.soft_pic := armv6m armv7m armv7em armv7
+
+ Configs += hard_pic
+-UniversalArchs.hard_pic := armv7em armv7 i386 x86_64
++UniversalArchs.hard_pic := i386 x86_64
+
+ CFLAGS := -Wall -Werror -Oz -fomit-frame-pointer -ffreestanding
+
+--- a/tools/clang/runtime/compiler-rt/Makefile
++++ b/tools/clang/runtime/compiler-rt/Makefile
+@@ -85,7 +85,7 @@ RuntimeLibrary.darwin.Configs := \
+ profile_osx.a profile_ios.a \
+ ubsan_osx.a
+ RuntimeLibrary.darwin_embedded.Configs := \
+- soft_static.a hard_static.a soft_pic.a hard_pic.a
++ hard_static.a hard_pic.a
+
+ # Support building compiler-rt with relocatable SDKs.
+ #
diff --git a/sys-devel/llvm/files/clang-3.4-darwin_prefix-include-paths.patch b/sys-devel/llvm/files/clang-3.4-darwin_prefix-include-paths.patch
new file mode 100644
index 0000000..f5f1d9e
--- /dev/null
+++ b/sys-devel/llvm/files/clang-3.4-darwin_prefix-include-paths.patch
@@ -0,0 +1,18 @@
+--- tools/clang/lib/Frontend/InitHeaderSearch.cpp
++++ tools/clang/lib/Frontend/InitHeaderSearch.cpp
+@@ -233,6 +233,7 @@
+ case llvm::Triple::Bitrig:
+ break;
+ default:
++ AddPath("@GENTOO_PORTAGE_EPREFIX@/usr/include", System, false);
+ // FIXME: temporary hack: hard-coded paths.
+ AddPath("/usr/local/include", System, false);
+ break;
+@@ -505,6 +506,7 @@
+ // Add the default framework include paths on Darwin.
+ if (HSOpts.UseStandardSystemIncludes) {
+ if (triple.isOSDarwin()) {
++ AddPath("@GENTOO_PORTAGE_EPREFIX@/Frameworks", System, true);
+ AddPath("/System/Library/Frameworks", System, true);
+ AddPath("/Library/Frameworks", System, true);
+ }
diff --git a/sys-devel/llvm/files/clang-3.4-gentoo-install.patch b/sys-devel/llvm/files/clang-3.4-gentoo-install.patch
new file mode 100644
index 0000000..0a1d9eb
--- /dev/null
+++ b/sys-devel/llvm/files/clang-3.4-gentoo-install.patch
@@ -0,0 +1,80 @@
+From a12fc090b3b43fe25c7de50c09782611e3834aeb Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
+Date: Sat, 14 Jun 2014 19:35:33 +0200
+Subject: [PATCH] clang gentoo fixes
+
+---
+ tools/clang/lib/Driver/Tools.cpp | 6 +++---
+ tools/clang/tools/scan-build/scan-build | 4 ++--
+ tools/clang/tools/scan-view/scan-view | 2 +-
+ 3 files changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/tools/clang/lib/Driver/Tools.cpp b/tools/clang/lib/Driver/Tools.cpp
+index b013eb5..dbbcacb 100644
+--- a/tools/clang/lib/Driver/Tools.cpp
++++ b/tools/clang/lib/Driver/Tools.cpp
+@@ -222,7 +222,7 @@ static void addProfileRT(const ToolChain &TC, const ArgList &Args,
+ // libprofile_rt.so. We used to use the -l:libprofile_rt.a syntax, but that is
+ // not supported by old linkers.
+ std::string ProfileRT =
+- std::string(TC.getDriver().Dir) + "/../lib/libprofile_rt.a";
++ "-l:libprofile_rt.a";
+
+ CmdArgs.push_back(Args.MakeArgString(ProfileRT));
+ }
+@@ -5911,7 +5911,7 @@ void freebsd::Link::ConstructJob(Compilation &C, const JobAction &JA,
+ // forward.
+ if (D.IsUsingLTO(Args)) {
+ CmdArgs.push_back("-plugin");
+- std::string Plugin = ToolChain.getDriver().Dir + "/../lib/LLVMgold.so";
++ std::string Plugin = ToolChain.getDriver().Dir + "/../@libdir@/LLVMgold.so";
+ CmdArgs.push_back(Args.MakeArgString(Plugin));
+
+ // Try to pass driver level flags relevant to LTO code generation down to
+@@ -6534,7 +6534,7 @@ void gnutools::Link::ConstructJob(Compilation &C, const JobAction &JA,
+ // forward.
+ if (D.IsUsingLTO(Args)) {
+ CmdArgs.push_back("-plugin");
+- std::string Plugin = ToolChain.getDriver().Dir + "/../lib/LLVMgold.so";
++ std::string Plugin = ToolChain.getDriver().Dir + "/../@libdir@/LLVMgold.so";
+ CmdArgs.push_back(Args.MakeArgString(Plugin));
+
+ // Try to pass driver level flags relevant to LTO code generation down to
+diff --git a/tools/clang/tools/scan-build/scan-build b/tools/clang/tools/scan-build/scan-build
+index 0f119f6..58f78d9 100755
+--- a/tools/clang/tools/scan-build/scan-build
++++ b/tools/clang/tools/scan-build/scan-build
+@@ -419,7 +419,7 @@ sub CopyFiles {
+
+ my $Dir = shift;
+
+- my $JS = Cwd::realpath("$RealBin/sorttable.js");
++ my $JS = Cwd::realpath("@EPREFIX@/usr/share/llvm/sorttable.js");
+
+ DieDiag("Cannot find 'sorttable.js'.\n")
+ if (! -r $JS);
+@@ -429,7 +429,7 @@ sub CopyFiles {
+ DieDiag("Could not copy 'sorttable.js' to '$Dir'.\n")
+ if (! -r "$Dir/sorttable.js");
+
+- my $CSS = Cwd::realpath("$RealBin/scanview.css");
++ my $CSS = Cwd::realpath("@EPREFIX@/usr/share/llvm/scanview.css");
+
+ DieDiag("Cannot find 'scanview.css'.\n")
+ if (! -r $CSS);
+diff --git a/tools/clang/tools/scan-view/scan-view b/tools/clang/tools/scan-view/scan-view
+index fb27da6..1f8ddb8 100755
+--- a/tools/clang/tools/scan-view/scan-view
++++ b/tools/clang/tools/scan-view/scan-view
+@@ -54,7 +54,7 @@ def start_browser(port, options):
+ webbrowser.open(url)
+
+ def run(port, options, root):
+- import ScanView
++ from clang import ScanView
+ try:
+ print 'Starting scan-view at: http://%s:%d'%(options.host,
+ port)
+--
+2.0.0
+
diff --git a/sys-devel/llvm/files/clang-3.5-gentoo-install.patch b/sys-devel/llvm/files/clang-3.5-gentoo-install.patch
new file mode 100644
index 0000000..5d4261d
--- /dev/null
+++ b/sys-devel/llvm/files/clang-3.5-gentoo-install.patch
@@ -0,0 +1,57 @@
+---
+ tools/clang/lib/Driver/Tools.cpp | 2 +-
+ tools/clang/tools/scan-build/scan-build | 4 ++--
+ tools/clang/tools/scan-view/scan-view | 2 +-
+ 3 files changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/tools/clang/lib/Driver/Tools.cpp b/tools/clang/lib/Driver/Tools.cpp
+index 187ed38..55bcd99 100644
+--- a/tools/clang/lib/Driver/Tools.cpp
++++ b/tools/clang/lib/Driver/Tools.cpp
+@@ -1404,7 +1404,7 @@ static void AddGoldPlugin(const ToolChain &ToolChain, const ArgList &Args,
+ // as gold requires -plugin to come before any -plugin-opt that -Wl might
+ // forward.
+ CmdArgs.push_back("-plugin");
+- std::string Plugin = ToolChain.getDriver().Dir + "/../lib/LLVMgold.so";
++ std::string Plugin = ToolChain.getDriver().Dir + "/../@libdir@/LLVMgold.so";
+ CmdArgs.push_back(Args.MakeArgString(Plugin));
+
+ // Try to pass driver level flags relevant to LTO code generation down to
+diff --git a/tools/clang/tools/scan-build/scan-build b/tools/clang/tools/scan-build/scan-build
+index 0f119f6..58f78d9 100755
+--- a/tools/clang/tools/scan-build/scan-build
++++ b/tools/clang/tools/scan-build/scan-build
+@@ -419,7 +419,7 @@
+
+ my $Dir = shift;
+
+- my $JS = Cwd::realpath("$RealBin/sorttable.js");
++ my $JS = Cwd::realpath("@EPREFIX@/usr/share/llvm/sorttable.js");
+
+ DieDiag("Cannot find 'sorttable.js'.\n")
+ if (! -r $JS);
+@@ -429,7 +429,7 @@
+ DieDiag("Could not copy 'sorttable.js' to '$Dir'.\n")
+ if (! -r "$Dir/sorttable.js");
+
+- my $CSS = Cwd::realpath("$RealBin/scanview.css");
++ my $CSS = Cwd::realpath("@EPREFIX@/usr/share/llvm/scanview.css");
+
+ DieDiag("Cannot find 'scanview.css'.\n")
+ if (! -r $CSS);
+diff --git a/tools/clang/tools/scan-view/scan-view b/tools/clang/tools/scan-view/scan-view
+index fb27da6..1f8ddb8 100755
+--- a/tools/clang/tools/scan-view/scan-view
++++ b/tools/clang/tools/scan-view/scan-view
+@@ -54,7 +54,7 @@ def start_browser(port, options):
+ webbrowser.open(url)
+
+ def run(port, options, root):
+- import ScanView
++ from clang import ScanView
+ try:
+ print 'Starting scan-view at: http://%s:%d'%(options.host,
+ port)
+--
+1.8.4.4
+
diff --git a/sys-devel/llvm/files/clang-3.5-gentoo-runtime-gcc-detection-v3.patch b/sys-devel/llvm/files/clang-3.5-gentoo-runtime-gcc-detection-v3.patch
new file mode 100644
index 0000000..1f81af0
--- /dev/null
+++ b/sys-devel/llvm/files/clang-3.5-gentoo-runtime-gcc-detection-v3.patch
@@ -0,0 +1,42 @@
+From 916572e1243633ddf913c8f32771a3a7f70fd853 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
+Date: Fri, 5 Sep 2014 16:49:35 +0200
+Subject: [PATCH] Support obtaining active toolchain from gcc-config.
+
+---
+ tools/clang/lib/Driver/ToolChains.cpp | 19 +++++++++++++++++++
+ 1 file changed, 19 insertions(+)
+
+diff --git a/tools/clang/lib/Driver/ToolChains.cpp b/tools/clang/lib/Driver/ToolChains.cpp
+index b46f69d..2d4374d 100644
+--- a/tools/clang/lib/Driver/ToolChains.cpp
++++ b/tools/clang/lib/Driver/ToolChains.cpp
+@@ -1253,6 +1253,25 @@ Generic_GCC::GCCInstallationDetector::init(
+ Prefixes.push_back("/usr");
+ }
+
++ for (unsigned k = 0, ke = CandidateTripleAliases.size(); k < ke; ++k) {
++ llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> File =
++ llvm::MemoryBuffer::getFile(D.SysRoot + "/etc/env.d/gcc/config-" + CandidateTripleAliases[k].str());
++ if (File)
++ {
++ const std::string VersionText = File.get()->getBuffer().rsplit('-').second.substr(0,5).str();
++ const std::string GentooPath = D.SysRoot + "/usr/lib/gcc/" + CandidateTripleAliases[k].str() + "/" + VersionText;
++ if (llvm::sys::fs::exists(GentooPath + "/crtbegin.o"))
++ {
++ Version = GCCVersion::Parse(VersionText);
++ GCCInstallPath = GentooPath;
++ GCCParentLibPath = GCCInstallPath + "/../../..";
++ GCCTriple.setTriple(CandidateTripleAliases[k]);
++ 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");
+--
+2.1.0
+
diff --git a/sys-devel/llvm/files/clang-3.6-fbsd-gcc49.patch b/sys-devel/llvm/files/clang-3.6-fbsd-gcc49.patch
new file mode 100644
index 0000000..31f5fc2
--- /dev/null
+++ b/sys-devel/llvm/files/clang-3.6-fbsd-gcc49.patch
@@ -0,0 +1,25 @@
+Fix build fails with using gcc-4.9 on Gentoo/FreeBSD
+https://bugs.gentoo.org/show_bug.cgi?id=548444
+
+diff --git a/llvm-3.6.0.src/tools/clang/lib/Driver/MSVCToolChain.cpp b/llvm-3.6.0.src/tools/clang/lib/Driver/MSVCToolChain.cpp
+index d6bd5c3..372f76f 100644
+--- a/llvm-3.6.0.src/tools/clang/lib/Driver/MSVCToolChain.cpp
++++ b/llvm-3.6.0.src/tools/clang/lib/Driver/MSVCToolChain.cpp
+@@ -22,6 +22,8 @@
+ #include "llvm/Support/FileSystem.h"
+ #include "llvm/Support/Process.h"
+
++#include <cstdio>
++
+ // Include the necessary headers to interface with the Windows registry and
+ // environment.
+ #if defined(LLVM_ON_WIN32)
+@@ -212,7 +214,7 @@ bool MSVCToolChain::getWindowsSDKDir(std::string &path, int &major,
+ "SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\$VERSION",
+ "InstallationFolder", path, &sdkVersion);
+ if (!sdkVersion.empty())
+- ::sscanf(sdkVersion.c_str(), "v%d.%d", &major, &minor);
++ std::sscanf(sdkVersion.c_str(), "v%d.%d", &major, &minor);
+ return hasSDKDir && !path.empty();
+ }
+
diff --git a/sys-devel/llvm/files/clang-3.6-gentoo-install.patch b/sys-devel/llvm/files/clang-3.6-gentoo-install.patch
new file mode 100644
index 0000000..6d76ba9
--- /dev/null
+++ b/sys-devel/llvm/files/clang-3.6-gentoo-install.patch
@@ -0,0 +1,48 @@
+---
+ tools/clang/lib/Driver/Tools.cpp | 2 +-
+ tools/clang/tools/scan-build/scan-build | 4 ++--
+ tools/clang/tools/scan-view/scan-view | 2 +-
+ 3 files changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/tools/clang/lib/Driver/Tools.cpp b/tools/clang/lib/Driver/Tools.cpp
+index 187ed38..55bcd99 100644
+--- a/tools/clang/lib/Driver/Tools.cpp
++++ b/tools/clang/lib/Driver/Tools.cpp
+diff --git a/tools/clang/tools/scan-build/scan-build b/tools/clang/tools/scan-build/scan-build
+index 0f119f6..58f78d9 100755
+--- a/tools/clang/tools/scan-build/scan-build
++++ b/tools/clang/tools/scan-build/scan-build
+@@ -419,7 +419,7 @@
+
+ my $Dir = shift;
+
+- my $JS = Cwd::realpath("$RealBin/sorttable.js");
++ my $JS = Cwd::realpath("@EPREFIX@/usr/share/llvm/sorttable.js");
+
+ DieDiag("Cannot find 'sorttable.js'.\n")
+ if (! -r $JS);
+@@ -429,7 +429,7 @@
+ DieDiag("Could not copy 'sorttable.js' to '$Dir'.\n")
+ if (! -r "$Dir/sorttable.js");
+
+- my $CSS = Cwd::realpath("$RealBin/scanview.css");
++ my $CSS = Cwd::realpath("@EPREFIX@/usr/share/llvm/scanview.css");
+
+ DieDiag("Cannot find 'scanview.css'.\n")
+ if (! -r $CSS);
+diff --git a/tools/clang/tools/scan-view/scan-view b/tools/clang/tools/scan-view/scan-view
+index fb27da6..1f8ddb8 100755
+--- a/tools/clang/tools/scan-view/scan-view
++++ b/tools/clang/tools/scan-view/scan-view
+@@ -54,7 +54,7 @@ def start_browser(port, options):
+ webbrowser.open(url)
+
+ def run(port, options, root):
+- import ScanView
++ from clang import ScanView
+ try:
+ print 'Starting scan-view at: http://%s:%d'%(options.host,
+ port)
+--
+1.8.4.4
+
diff --git a/sys-devel/llvm/files/clang-3.7-strip_doc_refs.patch b/sys-devel/llvm/files/clang-3.7-strip_doc_refs.patch
new file mode 100644
index 0000000..9576b92
--- /dev/null
+++ b/sys-devel/llvm/files/clang-3.7-strip_doc_refs.patch
@@ -0,0 +1,42 @@
+--- tools/clang/docs/AddressSanitizer.rst 2015-06-26 01:36:44.000000000 +0200
++++ tools/clang/docs/AddressSanitizer.rst 2015-08-23 15:35:10.399174574 +0200
+@@ -198,7 +198,7 @@
+ Some code should not be instrumented by AddressSanitizer. One may use the
+ function attribute ``__attribute__((no_sanitize("address")))``
+ (which has deprecated synonyms
+-:ref:`no_sanitize_address <langext-address_sanitizer>` and
++`no_sanitize_address` and
+ `no_address_safety_analysis`) to disable instrumentation of a particular
+ function. This attribute may not be supported by other compilers, so we suggest
+ to use it together with ``__has_feature(address_sanitizer)``.
+--- tools/clang/docs/MemorySanitizer.rst 2015-02-26 16:59:30.000000000 +0100
++++ tools/clang/docs/MemorySanitizer.rst 2015-08-23 15:35:28.002200413 +0200
+@@ -82,7 +82,7 @@
+
+ Some code should not be checked by MemorySanitizer.
+ One may use the function attribute
+-:ref:`no_sanitize_memory <langext-memory_sanitizer>`
++`no_sanitize_memory`
+ to disable uninitialized checks in a particular function.
+ MemorySanitizer may still instrument such functions to avoid false positives.
+ This attribute may not be
+--- tools/clang/docs/ThreadSanitizer.rst 2015-02-18 23:26:20.000000000 +0100
++++ tools/clang/docs/ThreadSanitizer.rst 2015-08-23 15:34:53.918150364 +0200
+@@ -88,7 +88,7 @@
+
+ Some code should not be instrumented by ThreadSanitizer.
+ One may use the function attribute
+-:ref:`no_sanitize_thread <langext-thread_sanitizer>`
++`no_sanitize_thread`
+ to disable instrumentation of plain (non-atomic) loads/stores in a particular function.
+ ThreadSanitizer still instruments such functions to avoid false positives and
+ provide meaningful stack traces.
+@@ -102,7 +102,7 @@
+ ThreadSanitizer supports ``src`` and ``fun`` entity types in
+ :doc:`SanitizerSpecialCaseList`, that can be used to suppress data race reports in
+ the specified source files or functions. Unlike functions marked with
+-:ref:`no_sanitize_thread <langext-thread_sanitizer>` attribute,
++`no_sanitize_thread` attribute,
+ blacklisted functions are not instrumented at all. This can lead to false positives
+ due to missed synchronization via atomic operations and missed stack frames in reports.
+
diff --git a/sys-devel/llvm/files/cmake/0002-cmake-Support-overriding-Sphinx-HTML-doc-install-dir.patch b/sys-devel/llvm/files/cmake/0002-cmake-Support-overriding-Sphinx-HTML-doc-install-dir.patch
new file mode 100644
index 0000000..3e57f0d
--- /dev/null
+++ b/sys-devel/llvm/files/cmake/0002-cmake-Support-overriding-Sphinx-HTML-doc-install-dir.patch
@@ -0,0 +1,36 @@
+From 2ec240a76253839cd1c5dc2e964f55698ae468fc Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
+Date: Mon, 8 Jun 2015 06:43:00 +0200
+Subject: [PATCH 2/4] cmake: Support overriding Sphinx HTML doc install
+ directory
+
+Provide ${PROJECT}_INSTALL_HTML variables (e.g. LLVM_INSTALL_HTML) to
+override Sphinx HTML doc install directory.
+
+Fixes: https://llvm.org/bugs/show_bug.cgi?id=23780
+---
+ cmake/modules/AddSphinxTarget.cmake | 8 ++++++--
+ 1 file changed, 6 insertions(+), 2 deletions(-)
+
+diff --git a/cmake/modules/AddSphinxTarget.cmake b/cmake/modules/AddSphinxTarget.cmake
+index 045dc23..9c9c444 100644
+--- a/cmake/modules/AddSphinxTarget.cmake
++++ b/cmake/modules/AddSphinxTarget.cmake
+@@ -53,8 +53,12 @@ function (add_sphinx_target builder project)
+ DESTINATION share/man/man1)
+
+ elseif (builder STREQUAL html)
+- install(DIRECTORY "${SPHINX_BUILD_DIR}"
+- DESTINATION "share/doc/${project}")
++ string(TOUPPER "${project}" project_upper)
++ set(${project_upper}_INSTALL_HTML "share/doc/${project}/html"
++ CACHE STRING "HTML documentation install directory for ${project}")
++
++ install(DIRECTORY "${SPHINX_BUILD_DIR}/"
++ DESTINATION "${${project_upper}_INSTALL_HTML}")
+ else()
+ message(WARNING Installation of ${builder} not supported)
+ endif()
+--
+2.4.3
+
diff --git a/sys-devel/llvm/files/cmake/0003-cmake-Add-an-ordering-dep-between-HTML-man-Sphinx-ta.patch b/sys-devel/llvm/files/cmake/0003-cmake-Add-an-ordering-dep-between-HTML-man-Sphinx-ta.patch
new file mode 100644
index 0000000..b1c74c6
--- /dev/null
+++ b/sys-devel/llvm/files/cmake/0003-cmake-Add-an-ordering-dep-between-HTML-man-Sphinx-ta.patch
@@ -0,0 +1,32 @@
+From 4f7092ba05cccfeea7d26177d93f3d7a57d9bce2 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
+Date: Mon, 8 Jun 2015 14:29:03 +0200
+Subject: [PATCH 3/4] cmake: Add an ordering dep between HTML & man Sphinx
+ targets
+
+Add a dependency between HTML & manpage Sphinx targets to prevent two
+instances of Sphinx from running in parallel, and therefore solves race
+conditions reusing the same doctree directory.
+
+Fixes: https://llvm.org/bugs/show_bug.cgi?id=23781
+---
+ docs/CMakeLists.txt | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt
+index da27627..63309a6 100644
+--- a/docs/CMakeLists.txt
++++ b/docs/CMakeLists.txt
+@@ -100,6 +100,9 @@ if (LLVM_ENABLE_SPHINX)
+
+ if (${SPHINX_OUTPUT_MAN})
+ add_sphinx_target(man llvm)
++ if (${SPHINX_OUTPUT_HTML})
++ add_dependencies(docs-llvm-html docs-llvm-man)
++ endif()
+ endif()
+
+ endif()
+--
+2.4.3
+
diff --git a/sys-devel/llvm/files/cmake/0004-cmake-Do-not-install-libgtest.patch b/sys-devel/llvm/files/cmake/0004-cmake-Do-not-install-libgtest.patch
new file mode 100644
index 0000000..92ca2e4
--- /dev/null
+++ b/sys-devel/llvm/files/cmake/0004-cmake-Do-not-install-libgtest.patch
@@ -0,0 +1,28 @@
+From d9f80393cfd4e586242ac3efd4e6ba6b49ce39ae Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
+Date: Tue, 9 Jun 2015 11:58:52 +0200
+Subject: [PATCH 4/4] cmake: Do not install libgtest
+
+libgtest is an internal test dependency, and should not be installed to
+the live system as a part of LLVM.
+---
+ utils/unittest/CMakeLists.txt | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/utils/unittest/CMakeLists.txt b/utils/unittest/CMakeLists.txt
+index b34e22a..3fe5884 100644
+--- a/utils/unittest/CMakeLists.txt
++++ b/utils/unittest/CMakeLists.txt
+@@ -41,6 +41,9 @@ if (PTHREAD_LIBRARY_PATH)
+ list(APPEND LIBS pthread)
+ endif()
+
++# Delay building until the tests pull it in, and avoid installing it
++set(EXCLUDE_FROM_ALL ON)
++
+ add_llvm_library(gtest
+ googletest/src/gtest-all.cc
+
+--
+2.4.3
+
diff --git a/sys-devel/llvm/files/cmake/clang-0001-Install-clang-runtime-into-usr-lib-without-suffix-3.8.patch b/sys-devel/llvm/files/cmake/clang-0001-Install-clang-runtime-into-usr-lib-without-suffix-3.8.patch
new file mode 100644
index 0000000..cf2ca59
--- /dev/null
+++ b/sys-devel/llvm/files/cmake/clang-0001-Install-clang-runtime-into-usr-lib-without-suffix-3.8.patch
@@ -0,0 +1,37 @@
+diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
+index fa7780f..e3a6c8f 100644
+--- a/tools/clang/lib/Driver/Driver.cpp
++++ b/tools/clang/lib/Driver/Driver.cpp
+@@ -66,8 +66,7 @@ Driver::Driver(StringRef ClangExecutable, StringRef DefaultTargetTriple,
+ if (ClangResourceDir != "") {
+ llvm::sys::path::append(P, ClangResourceDir);
+ } else {
+- StringRef ClangLibdirSuffix(CLANG_LIBDIR_SUFFIX);
+- llvm::sys::path::append(P, "..", Twine("lib") + ClangLibdirSuffix, "clang",
++ llvm::sys::path::append(P, "..", "lib", "clang",
+ CLANG_VERSION_STRING);
+ }
+ ResourceDir = P.str();
+diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp
+index f078b37..0c514fc 100644
+--- a/tools/clang/lib/Frontend/CompilerInvocation.cpp
++++ b/tools/clang/lib/Frontend/CompilerInvocation.cpp
+@@ -1097,7 +1097,7 @@ std::string CompilerInvocation::GetResourcesPath(const char *Argv0,
+ if (ClangResourceDir != "")
+ llvm::sys::path::append(P, ClangResourceDir);
+ else
+- llvm::sys::path::append(P, "..", Twine("lib") + CLANG_LIBDIR_SUFFIX,
++ llvm::sys::path::append(P, "..", "lib",
+ "clang", CLANG_VERSION_STRING);
+
+ return P.str();
+diff --git a/lib/Headers/CMakeLists.txt b/lib/Headers/CMakeLists.txt
+index 7de5fbe..49f439b 100644
+--- a/tools/clang/lib/Headers/CMakeLists.txt
++++ b/tools/clang/lib/Headers/CMakeLists.txt
+@@ -98,4 +98,4 @@ set_target_properties(clang-headers PROPERTIES FOLDER "Misc")
+ install(
+ FILES ${files} ${CMAKE_CURRENT_BINARY_DIR}/arm_neon.h
+ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
+- DESTINATION lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include)
++ DESTINATION lib/clang/${CLANG_VERSION}/include)
diff --git a/sys-devel/llvm/files/cmake/clang-0001-Install-clang-runtime-into-usr-lib-without-suffix.patch b/sys-devel/llvm/files/cmake/clang-0001-Install-clang-runtime-into-usr-lib-without-suffix.patch
new file mode 100644
index 0000000..904a72a
--- /dev/null
+++ b/sys-devel/llvm/files/cmake/clang-0001-Install-clang-runtime-into-usr-lib-without-suffix.patch
@@ -0,0 +1,52 @@
+From b28503def986bcbc388a04be0d51cbe80bc59506 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
+Date: Tue, 9 Jun 2015 12:11:50 +0200
+Subject: [PATCH] Install clang runtime into /usr/lib (without suffix)
+
+---
+ lib/Driver/Driver.cpp | 3 +--
+ lib/Frontend/CompilerInvocation.cpp | 3 +--
+ lib/Headers/CMakeLists.txt | 2 +-
+ 3 files changed, 3 insertions(+), 5 deletions(-)
+
+diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
+index a04a1f8..418d46a 100644
+--- a/tools/clang/lib/Driver/Driver.cpp
++++ b/tools/clang//lib/Driver/Driver.cpp
+@@ -66,8 +66,7 @@ Driver::Driver(StringRef ClangExecutable, StringRef DefaultTargetTriple,
+ if (ClangResourceDir != "") {
+ llvm::sys::path::append(P, ClangResourceDir);
+ } else {
+- StringRef ClangLibdirSuffix(CLANG_LIBDIR_SUFFIX);
+- llvm::sys::path::append(P, "..", Twine("lib") + ClangLibdirSuffix, "clang",
++ llvm::sys::path::append(P, "..", "lib", "clang",
+ CLANG_VERSION_STRING);
+ }
+ ResourceDir = P.str();
+diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp
+index 9485767..0b9ecbd 100644
+--- a/tools/clang/lib/Frontend/CompilerInvocation.cpp
++++ b/tools/clang/lib/Frontend/CompilerInvocation.cpp
+@@ -1053,8 +1053,7 @@ std::string CompilerInvocation::GetResourcesPath(const char *Argv0,
+ if (ClangResourceDir != "") {
+ llvm::sys::path::append(P, ClangResourceDir);
+ } else {
+- StringRef ClangLibdirSuffix(CLANG_LIBDIR_SUFFIX);
+- llvm::sys::path::append(P, "..", Twine("lib") + ClangLibdirSuffix, "clang",
++ llvm::sys::path::append(P, "..", "lib", "clang",
+ CLANG_VERSION_STRING);
+ }
+
+diff --git a/lib/Headers/CMakeLists.txt b/lib/Headers/CMakeLists.txt
+index 29a738e..3769d23 100644
+--- a/tools/clang/lib/Headers/CMakeLists.txt
++++ b/tools/clang/lib/Headers/CMakeLists.txt
+@@ -93,4 +93,4 @@ set_target_properties(clang-headers PROPERTIES FOLDER "Misc")
+ install(
+ FILES ${files} ${CMAKE_CURRENT_BINARY_DIR}/arm_neon.h
+ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
+- DESTINATION lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include)
++ DESTINATION lib/clang/${CLANG_VERSION}/include)
+--
+2.4.3
+
diff --git a/sys-devel/llvm/files/cmake/clang-0002-cmake-Make-CLANG_LIBDIR_SUFFIX-overridable.patch b/sys-devel/llvm/files/cmake/clang-0002-cmake-Make-CLANG_LIBDIR_SUFFIX-overridable.patch
new file mode 100644
index 0000000..0b93deb
--- /dev/null
+++ b/sys-devel/llvm/files/cmake/clang-0002-cmake-Make-CLANG_LIBDIR_SUFFIX-overridable.patch
@@ -0,0 +1,28 @@
+From d07632abe23d55eec2aae303a142a97765a77d32 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
+Date: Tue, 9 Jun 2015 12:20:06 +0200
+Subject: [PATCH 2/2] cmake: Make CLANG_LIBDIR_SUFFIX overridable
+
+Make CLANG_LIBDIR_SUFFIX a cache variable so that it can be explicitly
+overriden. It is used purely to find the LLVMgold.so plugin, so we want
+to set it to native suffix.
+---
+ CMakeLists.txt | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 357286b..647f976 100644
+--- a/tools/clang/CMakeLists.txt
++++ b/tools/clang/CMakeLists.txt
+@@ -203,7 +203,7 @@ set(CLANG_VENDOR_UTI "org.llvm.clang" CACHE STRING
+ "Vendor-specific uti.")
+
+ # The libdir suffix must exactly match whatever LLVM's configuration used.
+-set(CLANG_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}")
++set(CLANG_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING "")
+
+ set(CLANG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+ set(CLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
+--
+2.4.3
+
diff --git a/sys-devel/llvm/files/cmake/compiler-rt-0001-cmake-Install-compiler-rt-into-usr-lib-without-suffi.patch b/sys-devel/llvm/files/cmake/compiler-rt-0001-cmake-Install-compiler-rt-into-usr-lib-without-suffi.patch
new file mode 100644
index 0000000..9353800
--- /dev/null
+++ b/sys-devel/llvm/files/cmake/compiler-rt-0001-cmake-Install-compiler-rt-into-usr-lib-without-suffi.patch
@@ -0,0 +1,25 @@
+From 8bd62a681744d3c31a0837c0f84f99ea4987e017 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
+Date: Tue, 9 Jun 2015 12:17:57 +0200
+Subject: [PATCH] cmake: Install compiler-rt into /usr/lib (without suffix)
+
+---
+ CMakeLists.txt | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 0d8a880..5ae98a9 100644
+--- a/projects/compiler-rt/CMakeLists.txt
++++ b/projects/compiler-rt/CMakeLists.txt
+@@ -52,7 +52,7 @@ if (NOT COMPILER_RT_STANDALONE_BUILD)
+ # Setup the paths where compiler-rt runtimes and headers should be stored.
+ set(COMPILER_RT_OUTPUT_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION})
+ set(COMPILER_RT_EXEC_OUTPUT_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
+- set(COMPILER_RT_INSTALL_PATH lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION})
++ set(COMPILER_RT_INSTALL_PATH lib/clang/${CLANG_VERSION})
+ option(COMPILER_RT_INCLUDE_TESTS "Generate and build compiler-rt unit tests."
+ ${LLVM_INCLUDE_TESTS})
+ option(COMPILER_RT_ENABLE_WERROR "Fail and stop if warning is triggered"
+--
+2.4.3
+
diff --git a/sys-devel/llvm/files/cmake/llvm-3.7.0-ocaml-multilib.patch b/sys-devel/llvm/files/cmake/llvm-3.7.0-ocaml-multilib.patch
new file mode 100644
index 0000000..caba3d1
--- /dev/null
+++ b/sys-devel/llvm/files/cmake/llvm-3.7.0-ocaml-multilib.patch
@@ -0,0 +1,43 @@
+--- llvm-3.7.0rc3.src-orig/cmake/modules/AddOCaml.cmake 2015-06-08 05:22:22.000000000 +1000
++++ llvm-3.7.0rc3.src/cmake/modules/AddOCaml.cmake 2015-08-30 19:22:37.216580808 +1000
+@@ -131,7 +131,7 @@
+ if( APPLE )
+ set(ocaml_rpath "@executable_path/../../lib")
+ elseif( UNIX )
+- set(ocaml_rpath "\\$ORIGIN/../../lib")
++ set(ocaml_rpath "\\$ORIGIN/../../${CMAKE_INSTALL_LIBDIR}")
+ endif()
+ list(APPEND ocaml_flags "-ldopt" "-Wl,-rpath,${ocaml_rpath}")
+
+@@ -183,12 +183,12 @@
+ endforeach()
+
+ install(FILES ${install_files}
+- DESTINATION lib/ocaml)
++ DESTINATION ${CMAKE_INSTALL_LIBDIR}/ocaml)
+ install(FILES ${install_shlibs}
+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
+ GROUP_READ GROUP_EXECUTE
+ WORLD_READ WORLD_EXECUTE
+- DESTINATION lib/ocaml)
++ DESTINATION ${CMAKE_INSTALL_LIBDIR}/ocaml)
+
+ foreach( install_file ${install_files} ${install_shlibs} )
+ get_filename_component(filename "${install_file}" NAME)
+--- llvm-3.7.0rc3.src-orig/bindings/ocaml/backends/CMakeLists.txt 2014-12-30 14:24:07.000000000 +1100
++++ llvm-3.7.0rc3.src/bindings/ocaml/backends/CMakeLists.txt 2015-08-30 19:23:49.726583886 +1000
+@@ -23,5 +23,5 @@
+ "${LLVM_LIBRARY_DIR}/ocaml/META.llvm_${TARGET}")
+
+ install(FILES "${LLVM_LIBRARY_DIR}/ocaml/META.llvm_${TARGET}"
+- DESTINATION lib/ocaml)
++ DESTINATION ${CMAKE_INSTALL_LIBDIR}/ocaml)
+ endforeach()
+--- llvm-3.7.0rc3.src-orig/bindings/ocaml/llvm/CMakeLists.txt 2014-12-30 14:24:07.000000000 +1100
++++ llvm-3.7.0rc3.src/bindings/ocaml/llvm/CMakeLists.txt 2015-08-30 19:23:43.561583624 +1000
+@@ -8,4 +8,4 @@
+ "${LLVM_LIBRARY_DIR}/ocaml/META.llvm")
+
+ install(FILES "${LLVM_LIBRARY_DIR}/ocaml/META.llvm"
+- DESTINATION lib/ocaml)
++ DESTINATION ${CMAKE_INSTALL_LIBDIR}/ocaml)
diff --git a/sys-devel/llvm/files/cmake/llvm-3.8-allow_custom_cmake_build_types.patch b/sys-devel/llvm/files/cmake/llvm-3.8-allow_custom_cmake_build_types.patch
new file mode 100644
index 0000000..e42c08a
--- /dev/null
+++ b/sys-devel/llvm/files/cmake/llvm-3.8-allow_custom_cmake_build_types.patch
@@ -0,0 +1,14 @@
+--- a/CMakeLists.txt 2015-08-12 20:04:55.397881480 +0200
++++ b/CMakeLists.txt 2015-08-12 20:05:06.625741113 +0200
+@@ -152,11 +152,6 @@
+
+ string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
+
+-if (CMAKE_BUILD_TYPE AND
+- NOT uppercase_CMAKE_BUILD_TYPE MATCHES "^(DEBUG|RELEASE|RELWITHDEBINFO|MINSIZEREL)$")
+- message(FATAL_ERROR "Invalid value for CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
+-endif()
+-
+ set(LLVM_LIBDIR_SUFFIX "" CACHE STRING "Define suffix of library directory name (32/64)" )
+
+ # They are used as destination of target generators.
diff --git a/sys-devel/llvm/files/llvm-2.6-commandguide-nops.patch b/sys-devel/llvm/files/llvm-2.6-commandguide-nops.patch
new file mode 100644
index 0000000..583fdf9
--- /dev/null
+++ b/sys-devel/llvm/files/llvm-2.6-commandguide-nops.patch
@@ -0,0 +1,30 @@
+--- docs/CommandGuide/Makefile.orig 2009-10-26 16:54:33.000000000 +0100
++++ docs/CommandGuide/Makefile 2009-10-26 17:32:03.000000000 +0100
+@@ -19,7 +19,7 @@
+ DST_PS_DIR=ps/
+
+ # If we are in BUILD_FOR_WEBSITE mode, default to the all target.
+-all:: html man ps
++all:: html man
+
+ clean:
+ rm -f pod2htm*.*~~ $(HTML) $(MAN) $(PS)
+@@ -81,7 +81,7 @@
+ MAN_DIR := $(PROJ_mandir)/man1
+ PS_DIR := $(PROJ_docsdir)/ps
+
+-install-local:: $(HTML) $(INSTALL_MANS) $(PS)
++install-local:: $(HTML) $(INSTALL_MANS)
+ $(Echo) Installing HTML CommandGuide Documentation
+ $(Verb) $(MKDIR) $(HTML_DIR)
+ $(Verb) $(DataInstall) $(HTML) $(HTML_DIR)
+@@ -90,9 +90,6 @@
+ $(Echo) Installing MAN CommandGuide Documentation
+ $(Verb) $(MKDIR) $(MAN_DIR)
+ $(Verb) $(DataInstall) $(INSTALL_MANS) $(MAN_DIR)
+- $(Echo) Installing PS CommandGuide Documentation
+- $(Verb) $(MKDIR) $(PS_DIR)
+- $(Verb) $(DataInstall) $(PS) $(PS_DIR)
+
+ uninstall-local::
+ $(Echo) Uninstalling CommandGuide Documentation
diff --git a/sys-devel/llvm/files/llvm-2.7-nodoctargz.patch b/sys-devel/llvm/files/llvm-2.7-nodoctargz.patch
new file mode 100644
index 0000000..cce09eb
--- /dev/null
+++ b/sys-devel/llvm/files/llvm-2.7-nodoctargz.patch
@@ -0,0 +1,47 @@
+--- docs/Makefile.orig 2010-04-26 15:00:58.000000000 +0200
++++ docs/Makefile 2010-04-26 15:03:12.000000000 +0200
+@@ -46,13 +46,12 @@
+ # 'make generated BUILD_FOR_WEBSITE=1'
+ generated:: doxygen ocamldoc
+
+-install-html: $(PROJ_OBJ_DIR)/html.tar.gz
++install-html:
+ $(Echo) Installing HTML documentation
+ $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_docsdir)/html
+ $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_docsdir)/html/img
+ $(Verb) $(DataInstall) $(HTML) $(DESTDIR)$(PROJ_docsdir)/html
+ $(Verb) $(DataInstall) $(IMAGES) $(DESTDIR)$(PROJ_docsdir)/html/img
+- $(Verb) $(DataInstall) $(PROJ_OBJ_DIR)/html.tar.gz $(DESTDIR)$(PROJ_docsdir)
+
+ $(PROJ_OBJ_DIR)/html.tar.gz: $(HTML)
+ $(Echo) Packaging HTML documentation
+@@ -64,12 +63,11 @@
+ install-doxygen: doxygen
+ $(Echo) Installing doxygen documentation
+ $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_docsdir)/html/doxygen
+- $(Verb) $(DataInstall) $(PROJ_OBJ_DIR)/doxygen.tar.gz $(DESTDIR)$(PROJ_docsdir)
+ $(Verb) cd $(PROJ_OBJ_DIR)/doxygen && \
+ $(FIND) . -type f -exec \
+ $(DataInstall) {} $(DESTDIR)$(PROJ_docsdir)/html/doxygen \;
+
+-doxygen: regendoc $(PROJ_OBJ_DIR)/doxygen.tar.gz
++doxygen: regendoc
+
+ regendoc:
+ $(Echo) Building doxygen documentation
+@@ -95,7 +93,6 @@
+ install-ocamldoc: ocamldoc
+ $(Echo) Installing ocamldoc documentation
+ $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_docsdir)/ocamldoc/html
+- $(Verb) $(DataInstall) $(PROJ_OBJ_DIR)/ocamldoc.tar.gz $(DESTDIR)$(PROJ_docsdir)
+ $(Verb) cd $(PROJ_OBJ_DIR)/ocamldoc && \
+ $(FIND) . -type f -exec \
+ $(DataInstall) {} $(DESTDIR)$(PROJ_docsdir)/ocamldoc/html \;
+@@ -105,7 +102,6 @@
+ $(Verb) $(RM) -rf $(PROJ_OBJ_DIR)/ocamldoc.tar*
+ $(Verb) $(TAR) cf $(PROJ_OBJ_DIR)/ocamldoc.tar ocamldoc
+ $(Verb) $(GZIP) $(PROJ_OBJ_DIR)/ocamldoc.tar
+- $(Verb) $(CP) $(PROJ_OBJ_DIR)/ocamldoc.tar.gz $(PROJ_OBJ_DIR)/ocamldoc/html/
+
+ regen-ocamldoc:
+ $(Echo) Building ocamldoc documentation
diff --git a/sys-devel/llvm/files/llvm-2.8-alignof.patch b/sys-devel/llvm/files/llvm-2.8-alignof.patch
new file mode 100644
index 0000000..ae7f314
--- /dev/null
+++ b/sys-devel/llvm/files/llvm-2.8-alignof.patch
@@ -0,0 +1,59 @@
+Index: include/llvm/ADT/StringMap.h
+===================================================================
+--- include/llvm/ADT/StringMap.h (révision 117773)
++++ include/llvm/ADT/StringMap.h (révision 117774)
+@@ -167,7 +167,7 @@
+
+ unsigned AllocSize = static_cast<unsigned>(sizeof(StringMapEntry))+
+ KeyLength+1;
+- unsigned Alignment = alignof<StringMapEntry>();
++ unsigned Alignment = alignOf<StringMapEntry>();
+
+ StringMapEntry *NewItem =
+ static_cast<StringMapEntry*>(Allocator.Allocate(AllocSize,Alignment));
+Index: include/llvm/Support/AlignOf.h
+===================================================================
+--- include/llvm/Support/AlignOf.h (révision 117773)
++++ include/llvm/Support/AlignOf.h (révision 117774)
+@@ -49,12 +49,12 @@
+
+ };
+
+-/// alignof - A templated function that returns the mininum alignment of
++/// alignOf - A templated function that returns the mininum alignment of
+ /// of a type. This provides no extra functionality beyond the AlignOf
+ /// class besides some cosmetic cleanliness. Example usage:
+-/// alignof<int>() returns the alignment of an int.
++/// alignOf<int>() returns the alignment of an int.
+ template <typename T>
+-static inline unsigned alignof() { return AlignOf<T>::Alignment; }
++static inline unsigned alignOf() { return AlignOf<T>::Alignment; }
+
+ } // end namespace llvm
+ #endif
+Index: include/llvm/Support/Allocator.h
+===================================================================
+--- include/llvm/Support/Allocator.h (révision 117773)
++++ include/llvm/Support/Allocator.h (révision 117774)
+@@ -201,7 +201,7 @@
+ char *End = Slab == Allocator.CurSlab ? Allocator.CurPtr :
+ (char *)Slab + Slab->Size;
+ for (char *Ptr = (char*)(Slab+1); Ptr < End; Ptr += sizeof(T)) {
+- Ptr = Allocator.AlignPtr(Ptr, alignof<T>());
++ Ptr = Allocator.AlignPtr(Ptr, alignOf<T>());
+ if (Ptr + sizeof(T) <= End)
+ reinterpret_cast<T*>(Ptr)->~T();
+ }
+Index: include/llvm/CodeGen/SlotIndexes.h
+===================================================================
+--- include/llvm/CodeGen/SlotIndexes.h (révision 117773)
++++ include/llvm/CodeGen/SlotIndexes.h (révision 117774)
+@@ -393,7 +393,7 @@
+ IndexListEntry *entry =
+ static_cast<IndexListEntry*>(
+ ileAllocator.Allocate(sizeof(IndexListEntry),
+- alignof<IndexListEntry>()));
++ alignOf<IndexListEntry>()));
+
+ new (entry) IndexListEntry(mi, index);
+
diff --git a/sys-devel/llvm/files/llvm-2.8-darwin8.patch b/sys-devel/llvm/files/llvm-2.8-darwin8.patch
new file mode 100644
index 0000000..284ab47
--- /dev/null
+++ b/sys-devel/llvm/files/llvm-2.8-darwin8.patch
@@ -0,0 +1,15 @@
+Avoid like in Makefile.rules
+ld: -rpath can only be used when targeting Mac OS X 10.5 or later
+
+--- unittests/Makefile.unittest
++++ unittests/Makefile.unittest
+@@ -37,7 +37,9 @@
+ ifeq ($(ENABLE_SHARED), 1)
+ # Add the absolute path to the dynamic library. This is ok because
+ # we'll never install unittests.
++ifneq ($(DARWIN_MAJVERS),4)
+ LD.Flags += $(RPATH) -Wl,$(SharedLibDir)
++endif
+ # Also set {DYLD,LD}_LIBRARY_PATH because OSX ignores the rpath most
+ # of the time.
+ Run.Shared := $(SHLIBPATH_VAR)="$(SharedLibDir)$${$(SHLIBPATH_VAR):+:}$$$(SHLIBPATH_VAR)"
diff --git a/sys-devel/llvm/files/llvm-2.9-Operator.h-c++0x.patch b/sys-devel/llvm/files/llvm-2.9-Operator.h-c++0x.patch
new file mode 100644
index 0000000..b95d7d7
--- /dev/null
+++ b/sys-devel/llvm/files/llvm-2.9-Operator.h-c++0x.patch
@@ -0,0 +1,57 @@
+--- llvm/trunk/include/llvm/Operator.h 2011/02/07 16:40:21 125006
++++ llvm/trunk/include/llvm/Operator.h 2011/05/08 01:59:22 131062
+@@ -186,28 +186,46 @@
+ };
+
+ class AddOperator
+- : public ConcreteOperator<OverflowingBinaryOperator, Instruction::Add> {};
++ : public ConcreteOperator<OverflowingBinaryOperator, Instruction::Add> {
++ ~AddOperator(); // DO NOT IMPLEMENT
++};
+ class SubOperator
+- : public ConcreteOperator<OverflowingBinaryOperator, Instruction::Sub> {};
++ : public ConcreteOperator<OverflowingBinaryOperator, Instruction::Sub> {
++ ~SubOperator(); // DO NOT IMPLEMENT
++};
+ class MulOperator
+- : public ConcreteOperator<OverflowingBinaryOperator, Instruction::Mul> {};
++ : public ConcreteOperator<OverflowingBinaryOperator, Instruction::Mul> {
++ ~MulOperator(); // DO NOT IMPLEMENT
++};
+ class ShlOperator
+- : public ConcreteOperator<OverflowingBinaryOperator, Instruction::Shl> {};
++ : public ConcreteOperator<OverflowingBinaryOperator, Instruction::Shl> {
++ ~ShlOperator(); // DO NOT IMPLEMENT
++};
+
+
+ class SDivOperator
+- : public ConcreteOperator<PossiblyExactOperator, Instruction::SDiv> {};
++ : public ConcreteOperator<PossiblyExactOperator, Instruction::SDiv> {
++ ~SDivOperator(); // DO NOT IMPLEMENT
++};
+ class UDivOperator
+- : public ConcreteOperator<PossiblyExactOperator, Instruction::UDiv> {};
++ : public ConcreteOperator<PossiblyExactOperator, Instruction::UDiv> {
++ ~UDivOperator(); // DO NOT IMPLEMENT
++};
+ class AShrOperator
+- : public ConcreteOperator<PossiblyExactOperator, Instruction::AShr> {};
++ : public ConcreteOperator<PossiblyExactOperator, Instruction::AShr> {
++ ~AShrOperator(); // DO NOT IMPLEMENT
++};
+ class LShrOperator
+- : public ConcreteOperator<PossiblyExactOperator, Instruction::LShr> {};
++ : public ConcreteOperator<PossiblyExactOperator, Instruction::LShr> {
++ ~LShrOperator(); // DO NOT IMPLEMENT
++};
+
+
+
+ class GEPOperator
+ : public ConcreteOperator<Operator, Instruction::GetElementPtr> {
++ ~GEPOperator(); // DO NOT IMPLEMENT
++
+ enum {
+ IsInBounds = (1 << 0)
+ };
diff --git a/sys-devel/llvm/files/llvm-2.9-gcc4.7.patch b/sys-devel/llvm/files/llvm-2.9-gcc4.7.patch
new file mode 100644
index 0000000..a48ad96
--- /dev/null
+++ b/sys-devel/llvm/files/llvm-2.9-gcc4.7.patch
@@ -0,0 +1,14 @@
+---
+ Intercept.cpp | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/lib/ExecutionEngine/JIT/Intercept.cpp 2012-05-17 16:11:46.956180361 +0200
++++ b/lib/ExecutionEngine/JIT/Intercept.cpp 2012-05-17 16:14:35.256184996 +0200
+@@ -52,6 +52,7 @@
+ #include <sys/stat.h>
+ #endif
+ #include <fcntl.h>
++#include <unistd.h>
+ /* stat functions are redirecting to __xstat with a version number. On x86-64
+ * linking with libc_nonshared.a and -Wl,--export-dynamic doesn't make 'stat'
+ * available as an exported symbol, so we have to add it explicitly.
diff --git a/sys-devel/llvm/files/llvm-2.9-nodoctargz.patch b/sys-devel/llvm/files/llvm-2.9-nodoctargz.patch
new file mode 100644
index 0000000..9507817
--- /dev/null
+++ b/sys-devel/llvm/files/llvm-2.9-nodoctargz.patch
@@ -0,0 +1,39 @@
+--- docs/Makefile.orig 2011-02-28 21:30:46.000000000 +0100
++++ docs/Makefile 2011-02-28 21:35:22.000000000 +0100
+@@ -53,13 +53,12 @@
+ # 'make generated BUILD_FOR_WEBSITE=1'
+ generated:: $(generated_targets)
+
+-install-html: $(PROJ_OBJ_DIR)/html.tar.gz
++install-html:
+ $(Echo) Installing HTML documentation
+ $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_docsdir)/html
+ $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_docsdir)/html/img
+ $(Verb) $(DataInstall) $(HTML) $(DESTDIR)$(PROJ_docsdir)/html
+ $(Verb) $(DataInstall) $(IMAGES) $(DESTDIR)$(PROJ_docsdir)/html/img
+- $(Verb) $(DataInstall) $(PROJ_OBJ_DIR)/html.tar.gz $(DESTDIR)$(PROJ_docsdir)
+
+ $(PROJ_OBJ_DIR)/html.tar.gz: $(HTML)
+ $(Echo) Packaging HTML documentation
+@@ -71,12 +70,11 @@
+ install-doxygen: doxygen
+ $(Echo) Installing doxygen documentation
+ $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_docsdir)/html/doxygen
+- $(Verb) $(DataInstall) $(PROJ_OBJ_DIR)/doxygen.tar.gz $(DESTDIR)$(PROJ_docsdir)
+ $(Verb) cd $(PROJ_OBJ_DIR)/doxygen && \
+ $(FIND) . -type f -exec \
+ $(DataInstall) {} $(DESTDIR)$(PROJ_docsdir)/html/doxygen \;
+
+-doxygen: regendoc $(PROJ_OBJ_DIR)/doxygen.tar.gz
++doxygen: regendoc
+
+ regendoc:
+ $(Echo) Building doxygen documentation
+@@ -102,7 +100,6 @@
+ install-ocamldoc: ocamldoc
+ $(Echo) Installing ocamldoc documentation
+ $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_docsdir)/ocamldoc/html
+- $(Verb) $(DataInstall) $(PROJ_OBJ_DIR)/ocamldoc.tar.gz $(DESTDIR)$(PROJ_docsdir)
+ $(Verb) cd $(PROJ_OBJ_DIR)/ocamldoc && \
+ $(FIND) . -type f -exec \
+ $(DataInstall) {} $(DESTDIR)$(PROJ_docsdir)/ocamldoc/html \;
diff --git a/sys-devel/llvm/files/llvm-3.0-PPCCompilationCallbackC_static.patch b/sys-devel/llvm/files/llvm-3.0-PPCCompilationCallbackC_static.patch
new file mode 100644
index 0000000..04e4024
--- /dev/null
+++ b/sys-devel/llvm/files/llvm-3.0-PPCCompilationCallbackC_static.patch
@@ -0,0 +1,27 @@
+https://bugs.gentoo.org/show_bug.cgi?id=403519
+http://llvm.org/viewvc/llvm-project?view=rev&revision=153938
+
+--- llvm/trunk/lib/Target/PowerPC/PPCJITInfo.cpp 2011/06/15 15:29:47 133059
++++ llvm/trunk/lib/Target/PowerPC/PPCJITInfo.cpp 2012/04/03 06:59:28 153938
+@@ -291,9 +291,10 @@
+ }
+ #endif
+
+-extern "C" void *PPCCompilationCallbackC(unsigned *StubCallAddrPlus4,
+- unsigned *OrigCallAddrPlus4,
+- bool is64Bit) {
++extern "C" {
++static void* LLVM_ATTRIBUTE_USED PPCCompilationCallbackC(unsigned *StubCallAddrPlus4,
++ unsigned *OrigCallAddrPlus4,
++ bool is64Bit) {
+ // Adjust the pointer to the address of the call instruction in the stub
+ // emitted by emitFunctionStub, rather than the instruction after it.
+ unsigned *StubCallAddr = StubCallAddrPlus4 - 1;
+@@ -337,6 +338,7 @@
+ // stack after we restore all regs.
+ return Target;
+ }
++}
+
+
+
diff --git a/sys-devel/llvm/files/llvm-3.0-PPC_macro.patch b/sys-devel/llvm/files/llvm-3.0-PPC_macro.patch
new file mode 100644
index 0000000..c485e9b
--- /dev/null
+++ b/sys-devel/llvm/files/llvm-3.0-PPC_macro.patch
@@ -0,0 +1,43 @@
+Index: llvm-3.0-3.0/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.h
+===================================================================
+--- llvm-3.0-3.0.orig/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.h 2011-07-25 23:24:55.000000000 +0000
++++ llvm-3.0-3.0/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.h 2011-12-02 13:06:48.000000000 +0000
+@@ -34,6 +34,10 @@
+
+ } // End llvm namespace
+
++// Generated files will use "namespace PPC". To avoid symbol clash,
++// undefine PPC here. PPC may be predefined on some hosts.
++#undef PPC
++
+ // Defines symbolic names for PowerPC registers. This defines a mapping from
+ // register name to register number.
+ //
+Index: llvm-3.0-3.0/lib/Target/PowerPC/MCTargetDesc/PPCPredicates.h
+===================================================================
+--- llvm-3.0-3.0.orig/lib/Target/PowerPC/MCTargetDesc/PPCPredicates.h 2011-07-26 00:24:13.000000000 +0000
++++ llvm-3.0-3.0/lib/Target/PowerPC/MCTargetDesc/PPCPredicates.h 2011-12-02 13:06:48.000000000 +0000
+@@ -14,6 +14,10 @@
+ #ifndef LLVM_TARGET_POWERPC_PPCPREDICATES_H
+ #define LLVM_TARGET_POWERPC_PPCPREDICATES_H
+
++// Generated files will use "namespace PPC". To avoid symbol clash,
++// undefine PPC here. PPC may be predefined on some hosts.
++#undef PPC
++
+ namespace llvm {
+ namespace PPC {
+ /// Predicate - These are "(BI << 5) | BO" for various predicates.
+Index: llvm-3.0-3.0/lib/Target/PowerPC/MCTargetDesc/PPCFixupKinds.h
+===================================================================
+--- llvm-3.0-3.0.orig/lib/Target/PowerPC/MCTargetDesc/PPCFixupKinds.h 2011-07-25 19:53:23.000000000 +0000
++++ llvm-3.0-3.0/lib/Target/PowerPC/MCTargetDesc/PPCFixupKinds.h 2011-12-02 16:21:23.000000000 +0000
+@@ -12,6 +12,8 @@
+
+ #include "llvm/MC/MCFixup.h"
+
++#undef PPC
++
+ namespace llvm {
+ namespace PPC {
+ enum Fixups {
diff --git a/sys-devel/llvm/files/llvm-3.0-gold_LTO_link.patch b/sys-devel/llvm/files/llvm-3.0-gold_LTO_link.patch
new file mode 100644
index 0000000..031448d
--- /dev/null
+++ b/sys-devel/llvm/files/llvm-3.0-gold_LTO_link.patch
@@ -0,0 +1,10 @@
+--- tools/gold/Makefile 2011/11/23 03:03:21 145094
++++ tools/gold/Makefile 2011/11/23 03:07:25 145095
+@@ -24,6 +24,6 @@
+ # Because off_t is used in the public API, the largefile parts are required for
+ # ABI compatibility.
+ CXXFLAGS+=-I$(BINUTILS_INCDIR) -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
+-CXXFLAGS+=$(SharedLibDir)/$(SharedPrefix)LTO$(SHLIBEXT)
++CXXFLAGS+=-L$(SharedLibDir)/$(SharedPrefix) -lLTO
+
+ include $(LEVEL)/Makefile.common
diff --git a/sys-devel/llvm/files/llvm-3.0-ocaml_install.patch b/sys-devel/llvm/files/llvm-3.0-ocaml_install.patch
new file mode 100644
index 0000000..18f5cf6
--- /dev/null
+++ b/sys-devel/llvm/files/llvm-3.0-ocaml_install.patch
@@ -0,0 +1,16 @@
+https://bugs.gentoo.org/show_bug.cgi?id=393023
+http://llvm.org/bugs/show_bug.cgi?id=11177
+
+Index: llvm-3.0-3.0/bindings/ocaml/llvm/Makefile
+===================================================================
+--- llvm-3.0-3.0.orig/bindings/ocaml/llvm/Makefile 2011-11-15 12:17:02.785987852 +0100
++++ llvm-3.0-3.0/bindings/ocaml/llvm/Makefile 2011-11-15 12:20:12.661983615 +0100
+@@ -30,7 +30,7 @@
+ $(OcamlDir)/META.llvm: META.llvm
+ $(Verb) $(CP) -f $< $@
+
+-install-meta:: $(ObjDir)/META.llvm
++install-meta:: $(ObjDir)/../META.llvm
+ $(Echo) "Install $(BuildMode) $(DestMETA)"
+ $(Verb) $(MKDIR) $(PROJ_libocamldir)
+ $(Verb) $(DataInstall) META.llvm "$(DestMETA)"
diff --git a/sys-devel/llvm/files/llvm-3.0-set_soname.patch b/sys-devel/llvm/files/llvm-3.0-set_soname.patch
new file mode 100644
index 0000000..69ba74d
--- /dev/null
+++ b/sys-devel/llvm/files/llvm-3.0-set_soname.patch
@@ -0,0 +1,12 @@
+https://bugs.gentoo.org/show_bug.cgi?id=409267
+http://llvm.org/bugs/show_bug.cgi?id=12334
+--- tools/llvm-shlib/Makefile.orig 2012-03-26 18:14:13.071797115 +0200
++++ tools/llvm-shlib/Makefile 2012-03-26 17:31:12.491196254 +0200
+@@ -67,6 +67,7 @@
+ # Include everything from the .a's into the shared library.
+ LLVMLibsOptions := -Wl,--whole-archive $(LLVMLibsOptions) \
+ -Wl,--no-whole-archive
++ LLVMLibsOptions += -Wl,--soname,lib$(LIBRARYNAME)$(SHLIBEXT)
+ endif
+
+ ifeq ($(HOST_OS),Linux)
diff --git a/sys-devel/llvm/files/llvm-3.1-ExecutionEngine_tests_xfail_arm.patch b/sys-devel/llvm/files/llvm-3.1-ExecutionEngine_tests_xfail_arm.patch
new file mode 100644
index 0000000..05a20e6
--- /dev/null
+++ b/sys-devel/llvm/files/llvm-3.1-ExecutionEngine_tests_xfail_arm.patch
@@ -0,0 +1,27 @@
+diff -Naur llvm-3.1.src/test/ExecutionEngine/2002-12-16-ArgTest.ll llvm.src/test/ExecutionEngine/2002-12-16-ArgTest.ll
+--- llvm-3.1.src/test/ExecutionEngine/2002-12-16-ArgTest.ll 2012-04-12 22:13:57.000000000 +0200
++++ llvm.src/test/ExecutionEngine/2002-12-16-ArgTest.ll 2012-10-08 15:06:30.000000000 +0200
+@@ -1,4 +1,5 @@
+ ; RUN: %lli %s > /dev/null
++; XFAIL: arm
+
+ @.LC0 = internal global [10 x i8] c"argc: %d\0A\00" ; <[10 x i8]*> [#uses=1]
+
+diff -Naur llvm-3.1.src/test/ExecutionEngine/test-fp-no-external-funcs.ll llvm.src/test/ExecutionEngine/test-fp-no-external-funcs.ll
+--- llvm-3.1.src/test/ExecutionEngine/test-fp-no-external-funcs.ll 2012-04-12 22:13:57.000000000 +0200
++++ llvm.src/test/ExecutionEngine/test-fp-no-external-funcs.ll 2012-10-08 15:06:30.000000000 +0200
+@@ -1,4 +1,5 @@
+ ; RUN: %lli %s > /dev/null
++; XFAIL: arm
+
+ define double @test(double* %DP, double %Arg) {
+ %D = load double* %DP ; <double> [#uses=1]
+diff -Naur llvm-3.1.src/test/ExecutionEngine/test-fp.ll llvm.src/test/ExecutionEngine/test-fp.ll
+--- llvm-3.1.src/test/ExecutionEngine/test-fp.ll 2012-04-12 22:13:57.000000000 +0200
++++ llvm.src/test/ExecutionEngine/test-fp.ll 2012-10-08 15:06:30.000000000 +0200
+@@ -1,4 +1,5 @@
+ ; RUN: %lli %s > /dev/null
++; XFAIL: arm
+
+ define double @test(double* %DP, double %Arg) {
+ %D = load double* %DP ; <double> [#uses=1]
diff --git a/sys-devel/llvm/files/llvm-3.1-docs-pod-markup-fixes.patch b/sys-devel/llvm/files/llvm-3.1-docs-pod-markup-fixes.patch
new file mode 100644
index 0000000..cd8a62a
--- /dev/null
+++ b/sys-devel/llvm/files/llvm-3.1-docs-pod-markup-fixes.patch
@@ -0,0 +1,28 @@
+--- llvm-3.1.src/docs/CommandGuide/lit.pod~ 2012-03-27 03:01:14.000000000 +0900
++++ llvm-3.1.src/docs/CommandGuide/lit.pod 2013-01-23 12:47:30.297510832 +0900
+@@ -386,8 +386,6 @@
+ ********************
+ PASS: D (4 of 4)
+
+-=back
+-
+ =head2 LIT EXAMPLE TESTS
+
+ The B<lit> distribution contains several example implementations of test suites
+--- llvm-3.1.src/docs/CommandGuide/llvm-cov.pod~ 2011-11-29 08:39:25.000000000 +0900
++++ llvm-3.1.src/docs/CommandGuide/llvm-cov.pod 2013-01-23 13:44:32.184212441 +0900
+@@ -18,12 +18,12 @@
+
+ =over
+
+-=item B<-gcno=filename]
++=item B<-gcno=filename>
+
+ This option selects input description file generated by compiler while instrumenting
+ program.
+
+-=item B<-gcda=filename]
++=item B<-gcda=filename>
+
+ This option selects coverage data file generated by instrumented compiler.
+
diff --git a/sys-devel/llvm/files/llvm-3.1-fix_debug_line_info.patch b/sys-devel/llvm/files/llvm-3.1-fix_debug_line_info.patch
new file mode 100644
index 0000000..de2d46b
--- /dev/null
+++ b/sys-devel/llvm/files/llvm-3.1-fix_debug_line_info.patch
@@ -0,0 +1,65 @@
+From 737fdba46f2b2b7d39bc728d15ea2334c44779e0 Mon Sep 17 00:00:00 2001
+From: Ben Longbons <b.r.longbons@gmail.com>
+Date: Fri, 29 Jun 2012 12:58:34 -0700
+Subject: [PATCH] Revert "Patch to set is_stmt a little better for prologue
+ lines in a function."
+
+This meants that the debugger could find meaningful line information.
+
+This reverts commit 60b35f408bc3194e7ea4e96367c0b42dc5e7f850.
+---
+ lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 7 ++-----
+ test/DebugInfo/X86/ending-run.ll | 6 ++----
+ 2 files changed, 4 insertions(+), 9 deletions(-)
+
+diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+index 3e79a6d..24aedfb 100644
+--- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
++++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+@@ -1093,15 +1093,12 @@ void DwarfDebug::beginInstruction(const MachineInstr *MI) {
+ if (!MI->isDebugValue()) {
+ DebugLoc DL = MI->getDebugLoc();
+ if (DL != PrevInstLoc && (!DL.isUnknown() || UnknownLocations)) {
+- unsigned Flags = 0;
++ unsigned Flags = DWARF2_FLAG_IS_STMT;
+ PrevInstLoc = DL;
+ if (DL == PrologEndLoc) {
+ Flags |= DWARF2_FLAG_PROLOGUE_END;
+ PrologEndLoc = DebugLoc();
+ }
+- if (PrologEndLoc.isUnknown())
+- Flags |= DWARF2_FLAG_IS_STMT;
+-
+ if (!DL.isUnknown()) {
+ const MDNode *Scope = DL.getScope(Asm->MF->getFunction()->getContext());
+ recordSourceLine(DL.getLine(), DL.getCol(), Scope, Flags);
+@@ -1382,7 +1379,7 @@ void DwarfDebug::beginFunction(const MachineFunction *MF) {
+ MF->getFunction()->getContext());
+ recordSourceLine(FnStartDL.getLine(), FnStartDL.getCol(),
+ FnStartDL.getScope(MF->getFunction()->getContext()),
+- 0);
++ DWARF2_FLAG_IS_STMT);
+ }
+ }
+
+diff --git a/test/DebugInfo/X86/ending-run.ll b/test/DebugInfo/X86/ending-run.ll
+index 6935c47..0cd3de1 100644
+--- a/test/DebugInfo/X86/ending-run.ll
++++ b/test/DebugInfo/X86/ending-run.ll
+@@ -1,11 +1,9 @@
+ ; RUN: llc -mtriple=x86_64-apple-darwin %s -o %t -filetype=obj
+ ; RUN: llvm-dwarfdump %t | FileCheck %s
+
+-; Check that the line table starts at 7, not 4, but that the first
+-; statement isn't until line 8.
++; Check that the line table starts at 7, not 4.
+
+-; CHECK-NOT: 0x0000000000000000 7 0 1 0 is_stmt
+-; CHECK: 0x0000000000000000 7 0 1 0
++; CHECK: 0x0000000000000000 7 0 1 0 is_stmt
+ ; CHECK: 0x0000000000000004 8 18 1 0 is_stmt prologue_end
+
+ define i32 @callee(i32 %x) nounwind uwtable ssp {
+--
+1.7.10
+
diff --git a/sys-devel/llvm/files/llvm-3.1-ivybridge_support.patch b/sys-devel/llvm/files/llvm-3.1-ivybridge_support.patch
new file mode 100644
index 0000000..a03ec42
--- /dev/null
+++ b/sys-devel/llvm/files/llvm-3.1-ivybridge_support.patch
@@ -0,0 +1,13 @@
+--- llvm/trunk/lib/Support/Host.cpp 2012/04/23 22:22:46 155401
++++ llvm/trunk/lib/Support/Host.cpp 2012/04/23 22:41:39 155402
+@@ -230,6 +230,10 @@
+ case 45:
+ return "corei7-avx";
+
++ // Ivy Bridge:
++ case 58:
++ return "core-avx-i";
++
+ case 28: // Intel Atom processor. All processors are manufactured using
+ // the 45 nm process
+ return "atom";
diff --git a/sys-devel/llvm/files/llvm-3.2-nodoctargz.patch b/sys-devel/llvm/files/llvm-3.2-nodoctargz.patch
new file mode 100644
index 0000000..3a622b5
--- /dev/null
+++ b/sys-devel/llvm/files/llvm-3.2-nodoctargz.patch
@@ -0,0 +1,45 @@
+--- docs/Makefile.orig 2012-04-30 17:00:01.000000000 +0200
++++ docs/Makefile 2012-04-30 17:15:52.000000000 +0200
+@@ -52,11 +52,10 @@
+ # 'make generated BUILD_FOR_WEBSITE=1'
+ generated:: $(generated_targets)
+
+-install-html: $(PROJ_OBJ_DIR)/html.tar.gz
++install-html:
+ $(Echo) Installing HTML documentation
+ $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_docsdir)/html
+ $(Verb) $(DataInstall) $(HTML) $(DESTDIR)$(PROJ_docsdir)/html
+- $(Verb) $(DataInstall) $(PROJ_OBJ_DIR)/html.tar.gz $(DESTDIR)$(PROJ_docsdir)
+
+ $(PROJ_OBJ_DIR)/html.tar.gz: $(HTML)
+ $(Echo) Packaging HTML documentation
+@@ -68,12 +67,11 @@
+ install-doxygen: doxygen
+ $(Echo) Installing doxygen documentation
+ $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_docsdir)/html/doxygen
+- $(Verb) $(DataInstall) $(PROJ_OBJ_DIR)/doxygen.tar.gz $(DESTDIR)$(PROJ_docsdir)
+ $(Verb) cd $(PROJ_OBJ_DIR)/doxygen && \
+ $(FIND) . -type f -exec \
+ $(DataInstall) {} $(DESTDIR)$(PROJ_docsdir)/html/doxygen \;
+
+-doxygen: regendoc $(PROJ_OBJ_DIR)/doxygen.tar.gz
++doxygen: regendoc
+
+ regendoc:
+ $(Echo) Building doxygen documentation
+@@ -99,7 +97,6 @@
+ install-ocamldoc: ocamldoc
+ $(Echo) Installing ocamldoc documentation
+ $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_docsdir)/ocamldoc/html
+- $(Verb) $(DataInstall) $(PROJ_OBJ_DIR)/ocamldoc.tar.gz $(DESTDIR)$(PROJ_docsdir)
+ $(Verb) cd $(PROJ_OBJ_DIR)/ocamldoc && \
+ $(FIND) . -type f -exec \
+ $(DataInstall) {} $(DESTDIR)$(PROJ_docsdir)/ocamldoc/html \;
+@@ -109,7 +106,6 @@
+ $(Verb) $(RM) -rf $(PROJ_OBJ_DIR)/ocamldoc.tar*
+ $(Verb) $(TAR) cf $(PROJ_OBJ_DIR)/ocamldoc.tar ocamldoc
+ $(Verb) $(GZIPBIN) $(PROJ_OBJ_DIR)/ocamldoc.tar
+- $(Verb) $(CP) $(PROJ_OBJ_DIR)/ocamldoc.tar.gz $(PROJ_OBJ_DIR)/ocamldoc/html/
+
+ regen-ocamldoc:
+ $(Echo) Building ocamldoc documentation
diff --git a/sys-devel/llvm/files/llvm-3.3-R600_debug.patch b/sys-devel/llvm/files/llvm-3.3-R600_debug.patch
new file mode 100644
index 0000000..b104273
--- /dev/null
+++ b/sys-devel/llvm/files/llvm-3.3-R600_debug.patch
@@ -0,0 +1,22 @@
+Fixes compilation of llvm-3.3 on gcc-4.6 and 4.7 when VIDEO_CARDS=radeon
+
+This issue is caused because although Q is a multiset the original code tries to get
+a set iterator which can't be converted in a multiset one.
+
+The fix is as simple as just using a multiset iterator.
+
+Patch by Francisco Blas Izquierdo Riera (klondike)
+Consider the changes in the Public Domain
+https://bugs.gentoo.org/show_bug.cgi?id=474096
+
+--- lib/Target/R600/R600MachineScheduler.cpp
++++ lib/Target/R600/R600MachineScheduler.cpp
+@@ -290,7 +290,7 @@
+ SUnit *R600SchedStrategy::PopInst(std::multiset<SUnit *, CompareSUnit> &Q) {
+ if (Q.empty())
+ return NULL;
+- for (std::set<SUnit *, CompareSUnit>::iterator It = Q.begin(), E = Q.end();
++ for (std::multiset<SUnit *, CompareSUnit>::iterator It = Q.begin(), E = Q.end();
+ It != E; ++It) {
+ SUnit *SU = *It;
+ InstructionsGroupCandidate.push_back(SU->getInstr());
diff --git a/sys-devel/llvm/files/llvm-3.3-cmake-modulepath.patch b/sys-devel/llvm/files/llvm-3.3-cmake-modulepath.patch
new file mode 100644
index 0000000..754ae46
--- /dev/null
+++ b/sys-devel/llvm/files/llvm-3.3-cmake-modulepath.patch
@@ -0,0 +1,24 @@
+--- cmake/modules/LLVMConfig.cmake.in.old 2013-12-30 14:40:54.888983600 +0100
++++ cmake/modules/LLVMConfig.cmake.in 2013-12-30 14:44:15.448970509 +0100
+@@ -39,16 +39,10 @@
+ set(LLVM_LIBRARY_DIRS ${LLVM_INSTALL_PREFIX}/lib)
+ set(LLVM_DEFINITIONS "-D__STDC_LIMIT_MACROS" "-D__STDC_CONSTANT_MACROS")
+
+-# We try to include using the current setting of CMAKE_MODULE_PATH,
+-# which suppossedly was filled by the user with the directory where
+-# this file was installed:
+-include( LLVM-Config OPTIONAL RESULT_VARIABLE LLVMCONFIG_INCLUDED )
+-
+-# If failed, we assume that this is an un-installed build:
+-if( NOT LLVMCONFIG_INCLUDED )
+- set(CMAKE_MODULE_PATH
++# For some reasons without it it fails on Gentoo, see bug #496480
++set(CMAKE_MODULE_PATH
+ ${CMAKE_MODULE_PATH}
+- "@LLVM_SOURCE_DIR@/cmake/modules")
+- include( LLVM-Config )
+-endif()
++ "@LLVM_INSTALL_PREFIX@/share/llvm/cmake")
++
++include(LLVM-Config)
+
diff --git a/sys-devel/llvm/files/llvm-3.3-gentoo-install.patch b/sys-devel/llvm/files/llvm-3.3-gentoo-install.patch
new file mode 100644
index 0000000..e477be5
--- /dev/null
+++ b/sys-devel/llvm/files/llvm-3.3-gentoo-install.patch
@@ -0,0 +1,141 @@
+From 378109dbae7e4772d9b096384904c638a6a34028 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <gentoo@mgorny.alt.pl>
+Date: Fri, 19 Jul 2013 10:10:52 +0200
+Subject: [PATCH 1/2] gentoo install fixes
+
+---
+ Makefile.config.in | 6 +++---
+ Makefile.rules | 7 +++----
+ tools/gold/Makefile | 2 +-
+ tools/llvm-config/BuildVariables.inc.in | 2 ++
+ tools/llvm-config/Makefile | 4 ++++
+ tools/llvm-config/llvm-config.cpp | 5 +++--
+ utils/FileCheck/Makefile | 2 +-
+ 7 files changed, 17 insertions(+), 11 deletions(-)
+
+diff --git a/Makefile.config.in b/Makefile.config.in
+index fd4f6ef..5634ecc 100644
+--- a/Makefile.config.in
++++ b/Makefile.config.in
+@@ -95,10 +95,10 @@ PROJ_internal_prefix := $(prefix)
+ endif
+
+ PROJ_bindir := $(PROJ_prefix)/bin
+-PROJ_libdir := $(PROJ_prefix)/lib
++PROJ_libdir := $(PROJ_prefix)/$(GENTOO_LIBDIR)/llvm
+ PROJ_datadir := $(PROJ_prefix)/share
+-PROJ_docsdir := $(PROJ_prefix)/docs/llvm
+-PROJ_etcdir := $(PROJ_prefix)/etc/llvm
++PROJ_docsdir := $(PROJ_prefix)/share/doc/@PF@
++PROJ_etcdir := @EPREFIX@/etc/llvm
+ PROJ_includedir := $(PROJ_prefix)/include
+ PROJ_infodir := $(PROJ_prefix)/info
+ PROJ_mandir := $(PROJ_prefix)/share/man
+diff --git a/Makefile.rules b/Makefile.rules
+index f0c542b..db252f7 100644
+--- a/Makefile.rules
++++ b/Makefile.rules
+@@ -276,7 +276,7 @@ ifeq ($(ENABLE_OPTIMIZED),1)
+ # Don't use -fomit-frame-pointer on Darwin or FreeBSD.
+ ifneq ($(HOST_OS),FreeBSD)
+ ifneq ($(HOST_OS),Darwin)
+- OmitFramePointer := -fomit-frame-pointer
++ OmitFramePointer :=
+ endif
+ endif
+
+@@ -639,7 +638,7 @@ endif
+ ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
+ ifneq ($(HOST_OS), Darwin)
+ ifdef TOOLNAME
+- LD.Flags += $(RPATH) -Wl,'$$ORIGIN/../lib'
++ LD.Flags += $(RPATH) -Wl,'$$ORIGIN/../lib' $(RPATH) -Wl,'$(PROJ_libdir)'
+ ifdef EXAMPLE_TOOL
+ LD.Flags += $(RPATH) -Wl,$(ExmplDir) $(DynamicFlag)
+ else
+@@ -648,7 +647,7 @@ ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
+ endif
+ else
+ ifneq ($(DARWIN_MAJVERS),4)
+- LD.Flags += $(RPATH) -Wl,@executable_path/../lib
++ LD.Flags += $(RPATH) -Wl,@executable_path/../lib -Wl,'$(PROJ_libdir)'
+ endif
+ ifeq ($(RC_XBS),YES)
+ TempFile := $(shell mkdir -p ${OBJROOT}/dSYMs ; mktemp ${OBJROOT}/dSYMs/llvm-lto.XXXXXX)
+diff --git a/tools/gold/Makefile b/tools/gold/Makefile
+index 496e31c..d36b340 100644
+--- a/tools/gold/Makefile
++++ b/tools/gold/Makefile
+@@ -24,7 +24,7 @@ include $(LEVEL)/Makefile.config
+ # Because off_t is used in the public API, the largefile parts are required for
+ # ABI compatibility.
+ CXXFLAGS += -I$(BINUTILS_INCDIR) -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
+-LDFLAGS += -L$(SharedLibDir)/$(SharedPrefix)
++LDFLAGS += -L$(PROJ_libdir)
+
+ include $(LEVEL)/Makefile.common
+
+diff --git a/tools/llvm-config/BuildVariables.inc.in b/tools/llvm-config/BuildVariables.inc.in
+index fe87afb..fd9f2c6 100644
+--- a/tools/llvm-config/BuildVariables.inc.in
++++ b/tools/llvm-config/BuildVariables.inc.in
+@@ -25,3 +25,5 @@
+ #define LLVM_BUILDMODE "@LLVM_BUILDMODE@"
+ #define LLVM_TARGETS_BUILT "@LLVM_TARGETS_BUILT@"
+ #define LLVM_SYSTEM_LIBS "@LLVM_SYSTEM_LIBS@"
++#define LLVM_RPATH "@LLVM_RPATH@"
++#define LLVM_LIBDIR "@LLVM_LIBDIR@"
+diff --git a/tools/llvm-config/Makefile b/tools/llvm-config/Makefile
+index b20b6bf..fc56781 100644
+--- a/tools/llvm-config/Makefile
++++ b/tools/llvm-config/Makefile
+@@ -55,6 +55,10 @@ $(ObjDir)/BuildVariables.inc: $(BUILDVARIABLES_SRCPATH) Makefile $(ObjDir)/.dir
+ >> temp.sed
+ $(Verb) $(ECHO) 's/@LLVM_TARGETS_BUILT@/$(subst /,\/,$(TARGETS_TO_BUILD))/' \
+ >> temp.sed
++ $(Verb) $(ECHO) 's/@LLVM_RPATH@/$(subst /,\/,$(RPATH))/' \
++ >> temp.sed
++ $(Verb) $(ECHO) 's/@LLVM_LIBDIR@/$(subst /,\/,$(GENTOO_LIBDIR))/' \
++ >> temp.sed
+ $(Verb) $(SED) -f temp.sed < $< > $@
+ $(Verb) $(RM) temp.sed
+
+diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp
+index 7edf5ec..4541c28 100644
+--- a/tools/llvm-config/llvm-config.cpp
++++ b/tools/llvm-config/llvm-config.cpp
+@@ -250,7 +250,7 @@ int main(int argc, char **argv) {
+ ActivePrefix = CurrentExecPrefix;
+ ActiveIncludeDir = ActivePrefix + "/include";
+ ActiveBinDir = ActivePrefix + "/bin";
+- ActiveLibDir = ActivePrefix + "/lib";
++ ActiveLibDir = ActivePrefix + "/" LLVM_LIBDIR "/llvm";
+ ActiveIncludeOption = "-I" + ActiveIncludeDir;
+ }
+
+@@ -277,7 +277,8 @@ int main(int argc, char **argv) {
+ } else if (Arg == "--cxxflags") {
+ OS << ActiveIncludeOption << ' ' << LLVM_CXXFLAGS << '\n';
+ } else if (Arg == "--ldflags") {
+- OS << "-L" << ActiveLibDir << ' ' << LLVM_LDFLAGS
++ OS << "-L" << ActiveLibDir << ' '
++ << LLVM_RPATH << " -Wl," << ActiveLibDir << ' ' << LLVM_LDFLAGS
+ << ' ' << LLVM_SYSTEM_LIBS << '\n';
+ } else if (Arg == "--libs") {
+ PrintLibs = true;
+diff --git a/utils/FileCheck/Makefile b/utils/FileCheck/Makefile
+index 268b7bc..e7674f9 100644
+--- a/utils/FileCheck/Makefile
++++ b/utils/FileCheck/Makefile
+@@ -15,7 +15,7 @@ USEDLIBS = LLVMSupport.a
+ TOOL_NO_EXPORTS = 1
+
+ # Don't install this utility
+-NO_INSTALL = 1
++#NO_INSTALL = 1
+
+ include $(LEVEL)/Makefile.common
+
+--
+1.8.3.2
+
diff --git a/sys-devel/llvm/files/llvm-3.3-insecure-rpath.patch b/sys-devel/llvm/files/llvm-3.3-insecure-rpath.patch
new file mode 100644
index 0000000..659f237
--- /dev/null
+++ b/sys-devel/llvm/files/llvm-3.3-insecure-rpath.patch
@@ -0,0 +1,30 @@
+From d23d21bc76693dd2a43b5d76c68972ac01a055ba Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <gentoo@mgorny.alt.pl>
+Date: Sat, 20 Jul 2013 15:56:56 +0200
+Subject: [PATCH] Remove insecure RUNPATHs.
+
+LLVM seems to build fine without them, and they were removed for 3.4
+already.
+---
+ Makefile.rules | 5 -----
+ 1 file changed, 5 deletions(-)
+
+diff --git a/Makefile.rules b/Makefile.rules
+index db252f7..a29481b 100644
+--- a/Makefile.rules
++++ b/Makefile.rules
+@@ -639,11 +639,6 @@ ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
+ ifneq ($(HOST_OS), Darwin)
+ ifdef TOOLNAME
+ LD.Flags += $(RPATH) -Wl,'$(PROJ_libdir)'
+- ifdef EXAMPLE_TOOL
+- LD.Flags += $(RPATH) -Wl,$(ExmplDir) $(DynamicFlag)
+- else
+- LD.Flags += $(RPATH) -Wl,$(ToolDir) $(DynamicFlag)
+- endif
+ endif
+ else
+ ifneq ($(DARWIN_MAJVERS),4)
+--
+1.8.3.2
+
diff --git a/sys-devel/llvm/files/llvm-3.3-r2-gentoo-install.patch b/sys-devel/llvm/files/llvm-3.3-r2-gentoo-install.patch
new file mode 100644
index 0000000..c5bd8b8
--- /dev/null
+++ b/sys-devel/llvm/files/llvm-3.3-r2-gentoo-install.patch
@@ -0,0 +1,117 @@
+From a554809b6bdbe29b1f775c89104c1088300685ef Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
+Date: Sat, 28 Dec 2013 10:30:28 +0100
+Subject: [PATCH] Update for gentoo install layout.
+
+---
+ Makefile.config.in | 6 +++---
+ Makefile.rules | 8 ++++----
+ tools/llvm-config/BuildVariables.inc.in | 1 +
+ tools/llvm-config/Makefile | 2 ++
+ tools/llvm-config/llvm-config.cpp | 2 +-
+ utils/FileCheck/Makefile | 2 +-
+ 6 files changed, 12 insertions(+), 9 deletions(-)
+
+diff --git a/Makefile.config.in b/Makefile.config.in
+index fd4f6ef..b63786c 100644
+--- a/Makefile.config.in
++++ b/Makefile.config.in
+@@ -95,10 +95,10 @@ PROJ_internal_prefix := $(prefix)
+ endif
+
+ PROJ_bindir := $(PROJ_prefix)/bin
+-PROJ_libdir := $(PROJ_prefix)/lib
++PROJ_libdir := $(PROJ_prefix)/$(GENTOO_LIBDIR)
+ PROJ_datadir := $(PROJ_prefix)/share
+-PROJ_docsdir := $(PROJ_prefix)/docs/llvm
+-PROJ_etcdir := $(PROJ_prefix)/etc/llvm
++PROJ_docsdir := $(PROJ_prefix)/share/doc/@PF@
++PROJ_etcdir := @EPREFIX@/etc/llvm
+ PROJ_includedir := $(PROJ_prefix)/include
+ PROJ_infodir := $(PROJ_prefix)/info
+ PROJ_mandir := $(PROJ_prefix)/share/man
+diff --git a/Makefile.rules b/Makefile.rules
+index f0c542b..6cc19fd 100644
+--- a/Makefile.rules
++++ b/Makefile.rules
+@@ -276,7 +276,7 @@ ifeq ($(ENABLE_OPTIMIZED),1)
+ # Don't use -fomit-frame-pointer on Darwin or FreeBSD.
+ ifneq ($(HOST_OS),FreeBSD)
+ ifneq ($(HOST_OS),Darwin)
+- OmitFramePointer := -fomit-frame-pointer
++ OmitFramePointer :=
+ endif
+ endif
+
+@@ -601,7 +601,7 @@ endif
+ ifdef SHARED_LIBRARY
+ ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
+ ifneq ($(HOST_OS),Darwin)
+- LD.Flags += $(RPATH) -Wl,'$$ORIGIN'
++ LD.Flags +=
+ endif
+ endif
+ endif
+@@ -641,9 +641,9 @@ ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
+ ifdef TOOLNAME
+ LD.Flags += $(RPATH) -Wl,'$$ORIGIN/../lib'
+ ifdef EXAMPLE_TOOL
+- LD.Flags += $(RPATH) -Wl,$(ExmplDir) $(DynamicFlag)
++ LD.Flags += $(DynamicFlag)
+ else
+- LD.Flags += $(RPATH) -Wl,$(ToolDir) $(DynamicFlag)
++ LD.Flags += $(DynamicFlag)
+ endif
+ endif
+ else
+diff --git a/tools/llvm-config/BuildVariables.inc.in b/tools/llvm-config/BuildVariables.inc.in
+index fe87afb..908acd4 100644
+--- a/tools/llvm-config/BuildVariables.inc.in
++++ b/tools/llvm-config/BuildVariables.inc.in
+@@ -25,3 +25,4 @@
+ #define LLVM_BUILDMODE "@LLVM_BUILDMODE@"
+ #define LLVM_TARGETS_BUILT "@LLVM_TARGETS_BUILT@"
+ #define LLVM_SYSTEM_LIBS "@LLVM_SYSTEM_LIBS@"
++#define LLVM_LIBDIR "@LLVM_LIBDIR@"
+diff --git a/tools/llvm-config/Makefile b/tools/llvm-config/Makefile
+index b20b6bf..0aeba45 100644
+--- a/tools/llvm-config/Makefile
++++ b/tools/llvm-config/Makefile
+@@ -55,6 +55,8 @@ $(ObjDir)/BuildVariables.inc: $(BUILDVARIABLES_SRCPATH) Makefile $(ObjDir)/.dir
+ >> temp.sed
+ $(Verb) $(ECHO) 's/@LLVM_TARGETS_BUILT@/$(subst /,\/,$(TARGETS_TO_BUILD))/' \
+ >> temp.sed
++ $(Verb) $(ECHO) 's/@LLVM_LIBDIR@/$(subst /,\/,$(GENTOO_LIBDIR))/' \
++ >> temp.sed
+ $(Verb) $(SED) -f temp.sed < $< > $@
+ $(Verb) $(RM) temp.sed
+
+diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp
+index 7edf5ec..c09b702 100644
+--- a/tools/llvm-config/llvm-config.cpp
++++ b/tools/llvm-config/llvm-config.cpp
+@@ -250,7 +250,7 @@ int main(int argc, char **argv) {
+ ActivePrefix = CurrentExecPrefix;
+ ActiveIncludeDir = ActivePrefix + "/include";
+ ActiveBinDir = ActivePrefix + "/bin";
+- ActiveLibDir = ActivePrefix + "/lib";
++ ActiveLibDir = ActivePrefix + "/" LLVM_LIBDIR;
+ ActiveIncludeOption = "-I" + ActiveIncludeDir;
+ }
+
+diff --git a/utils/FileCheck/Makefile b/utils/FileCheck/Makefile
+index 268b7bc..e7674f9 100644
+--- a/utils/FileCheck/Makefile
++++ b/utils/FileCheck/Makefile
+@@ -15,7 +15,7 @@ USEDLIBS = LLVMSupport.a
+ TOOL_NO_EXPORTS = 1
+
+ # Don't install this utility
+-NO_INSTALL = 1
++#NO_INSTALL = 1
+
+ include $(LEVEL)/Makefile.common
+
+--
+1.8.5.2
+
diff --git a/sys-devel/llvm/files/llvm-3.4-cmake-configparser.patch b/sys-devel/llvm/files/llvm-3.4-cmake-configparser.patch
new file mode 100644
index 0000000..cda8bdc
--- /dev/null
+++ b/sys-devel/llvm/files/llvm-3.4-cmake-configparser.patch
@@ -0,0 +1,35 @@
+From 773560acfad511769017e971991c0305dbc0323d Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
+Date: Wed, 11 Jun 2014 09:40:26 +0200
+Subject: [PATCH] Avoid using external configparser in favor of built-in
+ ConfigParser.
+
+We only support Python 2 anyway, and configparser-3.2 is known to break
+the build. Since some packages actually force version 3.2, and we do not
+to pull in extra dependencies, forcing built-in seems to be the best
+option.
+
+Fixes: https://bugs.gentoo.org/show_bug.cgi?id=500856
+---
+ utils/llvm-build/llvmbuild/componentinfo.py | 5 +----
+ 1 file changed, 1 insertion(+), 4 deletions(-)
+
+diff --git a/utils/llvm-build/llvmbuild/componentinfo.py b/utils/llvm-build/llvmbuild/componentinfo.py
+index eda3a48..c963ef1 100644
+--- a/utils/llvm-build/llvmbuild/componentinfo.py
++++ b/utils/llvm-build/llvmbuild/componentinfo.py
+@@ -3,10 +3,7 @@ Descriptor objects for entities that are part of the LLVM project.
+ """
+
+ from __future__ import absolute_import
+-try:
+- import configparser
+-except:
+- import ConfigParser as configparser
++import ConfigParser as configparser
+ import sys
+
+ from llvmbuild.util import *
+--
+2.0.0
+
diff --git a/sys-devel/llvm/files/llvm-3.4-fix_varargs.patch b/sys-devel/llvm/files/llvm-3.4-fix_varargs.patch
new file mode 100644
index 0000000..377c4da
--- /dev/null
+++ b/sys-devel/llvm/files/llvm-3.4-fix_varargs.patch
@@ -0,0 +1,148 @@
+https://bugs.gentoo.org/show_bug.cgi?id=497298
+http://llvm.org/bugs/show_bug.cgi?id=18346
+
+SVN revisions:
+http://llvm.org/viewvc/llvm-project?view=revision&revision=197503
+http://llvm.org/viewvc/llvm-project?view=revision&revision=197505
+http://llvm.org/viewvc/llvm-project?view=revision&revision=197520
+
+diff -Naur llvm-3.4.orig/lib/Target/X86/X86ISelLowering.cpp llvm-3.4/lib/Target/X86/X86ISelLowering.cpp
+--- llvm-3.4.orig/lib/Target/X86/X86ISelLowering.cpp 2014-01-08 11:22:23.373060109 +0100
++++ llvm-3.4/lib/Target/X86/X86ISelLowering.cpp 2014-01-08 11:23:58.517125907 +0100
+@@ -15226,9 +15226,15 @@
+ MBB->addSuccessor(EndMBB);
+ }
+
++ // Make sure the last operand is EFLAGS, which gets clobbered by the branch
++ // that was just emitted, but clearly shouldn't be "saved".
++ assert((MI->getNumOperands() <= 3 ||
++ !MI->getOperand(MI->getNumOperands() - 1).isReg() ||
++ MI->getOperand(MI->getNumOperands() - 1).getReg() == X86::EFLAGS)
++ && "Expected last argument to be EFLAGS");
+ unsigned MOVOpc = Subtarget->hasFp256() ? X86::VMOVAPSmr : X86::MOVAPSmr;
+ // In the XMM save block, save all the XMM argument registers.
+- for (int i = 3, e = MI->getNumOperands(); i != e; ++i) {
++ for (int i = 3, e = MI->getNumOperands() - 1; i != e; ++i) {
+ int64_t Offset = (i - 3) * 16 + VarArgsFPOffset;
+ MachineMemOperand *MMO =
+ F->getMachineMemOperand(
+diff -Naur llvm-3.4.orig/lib/Target/X86/X86InstrCompiler.td llvm-3.4/lib/Target/X86/X86InstrCompiler.td
+--- llvm-3.4.orig/lib/Target/X86/X86InstrCompiler.td 2014-01-08 11:22:23.374060109 +0100
++++ llvm-3.4/lib/Target/X86/X86InstrCompiler.td 2014-01-08 11:23:39.654112857 +0100
+@@ -72,7 +72,7 @@
+
+
+ // x86-64 va_start lowering magic.
+-let usesCustomInserter = 1 in {
++let usesCustomInserter = 1, Defs = [EFLAGS] in {
+ def VASTART_SAVE_XMM_REGS : I<0, Pseudo,
+ (outs),
+ (ins GR8:$al,
+@@ -81,7 +81,8 @@
+ "#VASTART_SAVE_XMM_REGS $al, $regsavefi, $offset",
+ [(X86vastart_save_xmm_regs GR8:$al,
+ imm:$regsavefi,
+- imm:$offset)]>;
++ imm:$offset),
++ (implicit EFLAGS)]>;
+
+ // The VAARG_64 pseudo-instruction takes the address of the va_list,
+ // and places the address of the next argument into a register.
+diff -Naur llvm-3.4.orig/test/CodeGen/X86/vaargs.ll llvm-3.4/test/CodeGen/X86/vaargs.ll
+--- llvm-3.4.orig/test/CodeGen/X86/vaargs.ll 1970-01-01 01:00:00.000000000 +0100
++++ llvm-3.4/test/CodeGen/X86/vaargs.ll 2014-01-08 11:23:53.451122402 +0100
+@@ -0,0 +1,67 @@
++; RUN: llc -mcpu=corei7-avx %s -o - | FileCheck %s --check-prefix=CHECK --check-prefix=NO-FLAGS
++target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
++target triple = "x86_64-apple-macosx10.9.0"
++
++%struct.__va_list_tag = type { i32, i32, i8*, i8* }
++
++; Check that vastart gets the right thing.
++define i32 @sum(i32 %count, ...) nounwind optsize ssp uwtable {
++; CHECK: testb %al, %al
++; CHECK-NEXT: je
++; CHECK-NEXT: ## BB#{{[0-9]+}}:
++; CHECK-NEXT: vmovaps %xmm0, 48(%rsp)
++; CHECK-NEXT: vmovaps %xmm1, 64(%rsp)
++; CHECK-NEXT: vmovaps %xmm2, 80(%rsp)
++; CHECK-NEXT: vmovaps %xmm3, 96(%rsp)
++; CHECK-NEXT: vmovaps %xmm4, 112(%rsp)
++; CHECK-NEXT: vmovaps %xmm5, 128(%rsp)
++; CHECK-NEXT: vmovaps %xmm6, 144(%rsp)
++; CHECK-NEXT: vmovaps %xmm7, 160(%rsp)
++
++; Check that [EFLAGS] hasn't been pulled in.
++; NO-FLAGS-NOT: %flags
++
++ %ap = alloca [1 x %struct.__va_list_tag], align 16
++ %1 = bitcast [1 x %struct.__va_list_tag]* %ap to i8*
++ call void @llvm.va_start(i8* %1)
++ %2 = icmp sgt i32 %count, 0
++ br i1 %2, label %.lr.ph, label %._crit_edge
++
++.lr.ph: ; preds = %0
++ %3 = getelementptr inbounds [1 x %struct.__va_list_tag]* %ap, i64 0, i64 0, i32 0
++ %4 = getelementptr inbounds [1 x %struct.__va_list_tag]* %ap, i64 0, i64 0, i32 2
++ %.pre = load i32* %3, align 16
++ br label %5
++
++; <label>:5 ; preds = %.lr.ph, %13
++ %6 = phi i32 [ %.pre, %.lr.ph ], [ %14, %13 ]
++ %.01 = phi i32 [ %count, %.lr.ph ], [ %15, %13 ]
++ %7 = icmp ult i32 %6, 41
++ br i1 %7, label %8, label %10
++
++; <label>:8 ; preds = %5
++ %9 = add i32 %6, 8
++ store i32 %9, i32* %3, align 16
++ br label %13
++
++; <label>:10 ; preds = %5
++ %11 = load i8** %4, align 8
++ %12 = getelementptr i8* %11, i64 8
++ store i8* %12, i8** %4, align 8
++ br label %13
++
++; <label>:13 ; preds = %10, %8
++ %14 = phi i32 [ %6, %10 ], [ %9, %8 ]
++ %15 = add nsw i32 %.01, 1
++ %16 = icmp sgt i32 %15, 0
++ br i1 %16, label %5, label %._crit_edge
++
++._crit_edge: ; preds = %13, %0
++ %.0.lcssa = phi i32 [ %count, %0 ], [ %15, %13 ]
++ call void @llvm.va_end(i8* %1)
++ ret i32 %.0.lcssa
++}
++
++declare void @llvm.va_start(i8*) nounwind
++
++declare void @llvm.va_end(i8*) nounwind
+diff -Naur llvm-3.4.orig/test/CodeGen/X86/vastart-defs-eflags.ll llvm-3.4/test/CodeGen/X86/vastart-defs-eflags.ll
+--- llvm-3.4.orig/test/CodeGen/X86/vastart-defs-eflags.ll 1970-01-01 01:00:00.000000000 +0100
++++ llvm-3.4/test/CodeGen/X86/vastart-defs-eflags.ll 2014-01-08 11:23:39.654112857 +0100
+@@ -0,0 +1,23 @@
++; RUN: llc %s -o - | FileCheck %s
++
++target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
++target triple = "x86_64-apple-macosx10.10.0"
++
++; Check that vastart handling doesn't get between testb and je for the branch.
++define i32 @check_flag(i32 %flags, ...) nounwind {
++entry:
++; CHECK: {{^}} testb $2, %bh
++; CHECK-NOT: test
++; CHECK: {{^}} je
++ %and = and i32 %flags, 512
++ %tobool = icmp eq i32 %and, 0
++ br i1 %tobool, label %if.end, label %if.then
++
++if.then: ; preds = %entry
++ br label %if.end
++
++if.end: ; preds = %entry, %if.then
++ %hasflag = phi i32 [ 1, %if.then ], [ 0, %entry ]
++ ret i32 %hasflag
++}
++
diff --git a/sys-devel/llvm/files/llvm-3.4-gentoo-install.patch b/sys-devel/llvm/files/llvm-3.4-gentoo-install.patch
new file mode 100644
index 0000000..a2ba7de
--- /dev/null
+++ b/sys-devel/llvm/files/llvm-3.4-gentoo-install.patch
@@ -0,0 +1,96 @@
+From b8846d389ff5e2b768a114f752cf39788accba26 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
+Date: Mon, 19 Aug 2013 13:22:46 +0200
+Subject: [PATCH] gentoo install fixes
+
+---
+ Makefile.config.in | 6 +++---
+ Makefile.rules | 6 +++---
+ tools/llvm-config/BuildVariables.inc.in | 2 ++
+ tools/llvm-config/Makefile | 4 ++++
+ tools/llvm-config/llvm-config.cpp | 5 +++--
+ utils/FileCheck/Makefile | 2 +-
+ 7 files changed, 17 insertions(+), 10 deletions(-)
+
+diff --git a/Makefile.config.in b/Makefile.config.in
+index dcca45f..e75ae2e 100644
+--- a/Makefile.config.in
++++ b/Makefile.config.in
+@@ -95,10 +95,10 @@ PROJ_internal_prefix := $(prefix)
+ endif
+
+ PROJ_bindir := $(PROJ_prefix)/bin
+-PROJ_libdir := $(PROJ_prefix)/lib
++PROJ_libdir := $(PROJ_prefix)/$(GENTOO_LIBDIR)
+ PROJ_datadir := $(PROJ_prefix)/share
+-PROJ_docsdir := $(PROJ_prefix)/docs/llvm
+-PROJ_etcdir := $(PROJ_prefix)/etc/llvm
++PROJ_docsdir := $(PROJ_prefix)/share/doc/@PF@
++PROJ_etcdir := @EPREFIX@/etc/llvm
+ PROJ_includedir := $(PROJ_prefix)/include
+ PROJ_infodir := $(PROJ_prefix)/info
+ PROJ_mandir := $(PROJ_prefix)/share/man
+diff --git a/Makefile.rules b/Makefile.rules
+index e53598b..217f754 100644
+--- a/Makefile.rules
++++ b/Makefile.rules
+@@ -275,7 +275,7 @@ ifeq ($(ENABLE_OPTIMIZED),1)
+ BuildMode := Release
+ # Don't use -fomit-frame-pointer on Darwin or FreeBSD.
+ ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin Darwin DragonFly FreeBSD GNU/kFreeBSD))
+- OmitFramePointer := -fomit-frame-pointer
++ OmitFramePointer :=
+ endif
+
+ CXX.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
+diff --git a/tools/llvm-config/BuildVariables.inc.in b/tools/llvm-config/BuildVariables.inc.in
+index fe87afb..fd9f2c6 100644
+--- a/tools/llvm-config/BuildVariables.inc.in
++++ b/tools/llvm-config/BuildVariables.inc.in
+@@ -25,3 +25,4 @@
+ #define LLVM_BUILDMODE "@LLVM_BUILDMODE@"
+ #define LLVM_TARGETS_BUILT "@LLVM_TARGETS_BUILT@"
+ #define LLVM_SYSTEM_LIBS "@LLVM_SYSTEM_LIBS@"
++#define LLVM_LIBDIR "@LLVM_LIBDIR@"
+diff --git a/tools/llvm-config/Makefile b/tools/llvm-config/Makefile
+index b20b6bf..fc56781 100644
+--- a/tools/llvm-config/Makefile
++++ b/tools/llvm-config/Makefile
+@@ -55,6 +55,8 @@ $(ObjDir)/BuildVariables.inc: $(BUILDVARIABLES_SRCPATH) Makefile $(ObjDir)/.dir
+ >> temp.sed
+ $(Verb) $(ECHO) 's/@LLVM_TARGETS_BUILT@/$(subst /,\/,$(TARGETS_TO_BUILD))/' \
+ >> temp.sed
++ $(Verb) $(ECHO) 's/@LLVM_LIBDIR@/$(subst /,\/,$(GENTOO_LIBDIR))/' \
++ >> temp.sed
+ $(Verb) $(SED) -f temp.sed < $< > $@
+ $(Verb) $(RM) temp.sed
+
+diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp
+index 3924e2e..f439c60 100644
+--- a/tools/llvm-config/llvm-config.cpp
++++ b/tools/llvm-config/llvm-config.cpp
+@@ -250,7 +250,7 @@ int main(int argc, char **argv) {
+ ActivePrefix = CurrentExecPrefix;
+ ActiveIncludeDir = ActivePrefix + "/include";
+ ActiveBinDir = ActivePrefix + "/bin";
+- ActiveLibDir = ActivePrefix + "/lib";
++ ActiveLibDir = ActivePrefix + "/" LLVM_LIBDIR;
+ ActiveIncludeOption = "-I" + ActiveIncludeDir;
+ }
+
+diff --git a/utils/FileCheck/Makefile b/utils/FileCheck/Makefile
+index 268b7bc..e7674f9 100644
+--- a/utils/FileCheck/Makefile
++++ b/utils/FileCheck/Makefile
+@@ -15,7 +15,7 @@ USEDLIBS = LLVMSupport.a
+ TOOL_NO_EXPORTS = 1
+
+ # Don't install this utility
+-NO_INSTALL = 1
++#NO_INSTALL = 1
+
+ include $(LEVEL)/Makefile.common
+
+--
+1.8.4.2
+
diff --git a/sys-devel/llvm/files/llvm-3.5-gcc-4.9.patch b/sys-devel/llvm/files/llvm-3.5-gcc-4.9.patch
new file mode 100644
index 0000000..7da657f
--- /dev/null
+++ b/sys-devel/llvm/files/llvm-3.5-gcc-4.9.patch
@@ -0,0 +1,43 @@
+commit 080fb498017d17af2e4d7563608c7d8a848f20da
+Author: Sanjoy Das <sanjoy at azulsystems.com>
+Date: Thu Jun 19 15:38:02 2014 -0700
+
+ Fix the --enable-shared build.
+
+ Currently a build configured with ./configure --enable-shared breaks
+ with an undefined "llvm::cl::parser<llvm::PassInfo
+ const*>::getOption(unsigned int) const" symbol when linking opt. This
+ body for this symbol gets emitted into Pass.o (along with the destructor
+ for PassNameParser), but gets linked into libLLVM-3.5svn.so with local
+ visibility, causing the link error.
+
+ This fix uses the existing EXTERN_TEMPLATE machinery to force a globally
+ visible definition for the functions in parser<const PassInfo *> into
+ Pass.o.
+
+diff --git a/include/llvm/IR/LegacyPassNameParser.h b/include/llvm/IR/LegacyPassNameParser.h
+index e2e4912..a07e3fd 100644
+--- a/include/llvm/IR/LegacyPassNameParser.h
++++ b/include/llvm/IR/LegacyPassNameParser.h
+@@ -95,6 +95,8 @@ private:
+ }
+ };
+
++EXTERN_TEMPLATE_INSTANTIATION(class cl::parser<const PassInfo *>);
++
+ ///===----------------------------------------------------------------------===//
+ /// FilteredPassNameParser class - Make use of the pass registration
+ /// mechanism to automatically add a command line argument to opt for
+diff --git a/lib/IR/Pass.cpp b/lib/IR/Pass.cpp
+index 91d86ae..00ce223 100644
+--- a/lib/IR/Pass.cpp
++++ b/lib/IR/Pass.cpp
+@@ -234,6 +234,8 @@ PassNameParser::~PassNameParser() {
+ // attempting to remove the registration listener is an error.
+ }
+
++TEMPLATE_INSTANTIATION(class cl::parser<const PassInfo *>);
++
+ //===----------------------------------------------------------------------===//
+ // AnalysisUsage Class Implementation
+ //
diff --git a/sys-devel/llvm/files/llvm-3.5-gentoo-install.patch b/sys-devel/llvm/files/llvm-3.5-gentoo-install.patch
new file mode 100644
index 0000000..7a8c9f7
--- /dev/null
+++ b/sys-devel/llvm/files/llvm-3.5-gentoo-install.patch
@@ -0,0 +1,83 @@
+From b8846d389ff5e2b768a114f752cf39788accba26 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
+Date: Mon, 19 Aug 2013 13:22:46 +0200
+Subject: [PATCH] gentoo install fixes
+
+---
+ Makefile.config.in | 6 +++---
+ Makefile.rules | 6 +++---
+ tools/llvm-config/BuildVariables.inc.in | 2 ++
+ tools/llvm-config/Makefile | 4 ++++
+ tools/llvm-config/llvm-config.cpp | 5 +++--
+ utils/FileCheck/Makefile | 2 +-
+ 7 files changed, 17 insertions(+), 10 deletions(-)
+
+diff --git a/Makefile.config.in b/Makefile.config.in
+index dcca45f..e75ae2e 100644
+--- a/Makefile.config.in
++++ b/Makefile.config.in
+@@ -95,10 +95,10 @@ PROJ_internal_prefix := $(prefix)
+ endif
+
+ PROJ_bindir := $(PROJ_prefix)/bin
+-PROJ_libdir := $(PROJ_prefix)/lib
++PROJ_libdir := $(PROJ_prefix)/$(GENTOO_LIBDIR)
+ PROJ_datadir := $(PROJ_prefix)/share
+-PROJ_docsdir := $(PROJ_prefix)/docs/llvm
+-PROJ_etcdir := $(PROJ_prefix)/etc/llvm
++PROJ_docsdir := $(PROJ_prefix)/share/doc/@PF@
++PROJ_etcdir := @EPREFIX@/etc/llvm
+ PROJ_includedir := $(PROJ_prefix)/include
+ PROJ_infodir := $(PROJ_prefix)/info
+ PROJ_mandir := $(PROJ_prefix)/share/man
+diff --git a/Makefile.rules b/Makefile.rules
+index e53598b..217f754 100644
+--- a/Makefile.rules
++++ b/Makefile.rules
+@@ -275,7 +275,7 @@ ifeq ($(ENABLE_OPTIMIZED),1)
+ BuildMode := Release
+ # Don't use -fomit-frame-pointer on Darwin or FreeBSD.
+ ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin Darwin DragonFly FreeBSD GNU/kFreeBSD))
+- OmitFramePointer := -fomit-frame-pointer
++ OmitFramePointer :=
+ endif
+
+ CXX.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
+diff --git a/tools/llvm-config/BuildVariables.inc.in b/tools/llvm-config/BuildVariables.inc.in
+index fe87afb..fd9f2c6 100644
+--- a/tools/llvm-config/BuildVariables.inc.in
++++ b/tools/llvm-config/BuildVariables.inc.in
+@@ -25,3 +25,4 @@
+ #define LLVM_BUILDMODE "@LLVM_BUILDMODE@"
+ #define LLVM_TARGETS_BUILT "@LLVM_TARGETS_BUILT@"
+ #define LLVM_SYSTEM_LIBS "@LLVM_SYSTEM_LIBS@"
++#define LLVM_LIBDIR "@LLVM_LIBDIR@"
+diff --git a/tools/llvm-config/Makefile b/tools/llvm-config/Makefile
+index b20b6bf..fc56781 100644
+--- a/tools/llvm-config/Makefile
++++ b/tools/llvm-config/Makefile
+@@ -55,6 +55,8 @@ $(ObjDir)/BuildVariables.inc: $(BUILDVARIABLES_SRCPATH) Makefile $(ObjDir)/.dir
+ >> temp.sed
+ $(Verb) $(ECHO) 's/@LLVM_TARGETS_BUILT@/$(subst /,\/,$(TARGETS_TO_BUILD))/' \
+ >> temp.sed
++ $(Verb) $(ECHO) 's/@LLVM_LIBDIR@/$(subst /,\/,$(GENTOO_LIBDIR))/' \
++ >> temp.sed
+ $(Verb) $(SED) -f temp.sed < $< > $@
+ $(Verb) $(RM) temp.sed
+
+diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp
+index 3924e2e..f439c60 100644
+--- a/tools/llvm-config/llvm-config.cpp
++++ b/tools/llvm-config/llvm-config.cpp
+@@ -250,7 +250,7 @@ int main(int argc, char **argv) {
+ ActivePrefix = CurrentExecPrefix;
+ ActiveIncludeDir = ActivePrefix + "/include";
+ ActiveBinDir = ActivePrefix + "/bin";
+- ActiveLibDir = ActivePrefix + "/lib";
++ ActiveLibDir = ActivePrefix + "/" LLVM_LIBDIR;
+ ActiveIncludeOption = "-I" + ActiveIncludeDir;
+ }
+
+--
+1.8.4.2
+
diff --git a/sys-devel/llvm/files/llvm-3.5.0-fix_LLVMExports_cmake.patch b/sys-devel/llvm/files/llvm-3.5.0-fix_LLVMExports_cmake.patch
new file mode 100644
index 0000000..9fbd7b7
--- /dev/null
+++ b/sys-devel/llvm/files/llvm-3.5.0-fix_LLVMExports_cmake.patch
@@ -0,0 +1,39 @@
+Index: cmake/modules/Makefile
+===================================================================
+--- cmake/modules/Makefile (revision 217451)
++++ cmake/modules/Makefile (working copy)
+@@ -33,6 +33,16 @@
+ LLVM_ENABLE_RTTI := 0
+ endif
+
++LLVM_LIBS_TO_EXPORT := $(subst -l,,$(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS) || echo Error))
++
++ifeq ($(LLVM_LIBS_TO_EXPORT),Error)
++$(error llvm-config --libs failed)
++endif
++
++ifndef LLVM_LIBS_TO_EXPORT
++$(error LLVM_LIBS_TO_EXPORT cannot be empty)
++endif
++
+ OBJMODS := LLVMConfig.cmake LLVMConfigVersion.cmake LLVMExports.cmake
+
+ $(PROJ_OBJ_DIR)/LLVMConfig.cmake: LLVMConfig.cmake.in $(LLVMBuildCMakeFrag)
+@@ -45,7 +55,7 @@
+ -e 's/@LLVM_VERSION_PATCH@/'"$(LLVM_VERSION_PATCH)"'/' \
+ -e 's/@PACKAGE_VERSION@/'"$(LLVMVersion)"'/' \
+ -e 's/@LLVM_COMMON_DEPENDS@//' \
+- -e 's/@LLVM_AVAILABLE_LIBS@/'"$(subst -l,,$(LLVMConfigLibs))"'/' \
++ -e 's/@LLVM_AVAILABLE_LIBS@/'"$(LLVM_LIBS_TO_EXPORT)"'/' \
+ -e 's/@LLVM_ALL_TARGETS@/'"$(ALL_TARGETS)"'/' \
+ -e 's/@LLVM_TARGETS_TO_BUILD@/'"$(TARGETS_TO_BUILD)"'/' \
+ -e 's/@LLVM_TARGETS_WITH_JIT@/'"$(TARGETS_WITH_JIT)"'/' \
+@@ -83,7 +93,7 @@
+ $(Echo) 'Generating LLVM CMake target exports file'
+ $(Verb) ( \
+ echo '# LLVM CMake target exports. Do not include directly.' && \
+- for lib in $(subst -l,,$(LLVMConfigLibs)); do \
++ for lib in $(LLVM_LIBS_TO_EXPORT); do \
+ echo 'add_library('"$$lib"' STATIC IMPORTED)' && \
+ echo 'set_property(TARGET '"$$lib"' PROPERTY IMPORTED_LOCATION "'"$(PROJ_libdir)/lib$$lib.a"'")' ; \
+ done && \
diff --git a/sys-devel/llvm/files/llvm-3.5.2-gcc-5.1.patch b/sys-devel/llvm/files/llvm-3.5.2-gcc-5.1.patch
new file mode 100644
index 0000000..7cb2817
--- /dev/null
+++ b/sys-devel/llvm/files/llvm-3.5.2-gcc-5.1.patch
@@ -0,0 +1,14 @@
+Index: include/llvm/ADT/IntrusiveRefCntPtr.h
+===================================================================
+--- include/llvm/ADT/IntrusiveRefCntPtr.h (revision 218294)
++++ include/llvm/ADT/IntrusiveRefCntPtr.h (revision 218295)
+@@ -197,6 +197,9 @@
+ private:
+ void retain() { if (Obj) IntrusiveRefCntPtrInfo<T>::retain(Obj); }
+ void release() { if (Obj) IntrusiveRefCntPtrInfo<T>::release(Obj); }
++
++ template <typename X>
++ friend class IntrusiveRefCntPtr;
+ };
+
+ template<class T, class U>
diff --git a/sys-devel/llvm/files/llvm-3.6-gentoo-install.patch b/sys-devel/llvm/files/llvm-3.6-gentoo-install.patch
new file mode 100644
index 0000000..c4d0db2
--- /dev/null
+++ b/sys-devel/llvm/files/llvm-3.6-gentoo-install.patch
@@ -0,0 +1,82 @@
+From bb016afeba4d9e886e776565a508634a261111a2 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
+Date: Wed, 31 Dec 2014 11:26:12 +0100
+Subject: [PATCH] gentoo build fixes
+
+---
+ Makefile.config.in | 6 +++---
+ Makefile.rules | 2 +-
+ tools/llvm-config/BuildVariables.inc.in | 1 +
+ tools/llvm-config/Makefile | 2 ++
+ tools/llvm-config/llvm-config.cpp | 2 +-
+ 5 files changed, 8 insertions(+), 5 deletions(-)
+
+diff --git a/Makefile.config.in b/Makefile.config.in
+index d34a2d5..a26cd08 100644
+--- a/Makefile.config.in
++++ b/Makefile.config.in
+@@ -99,10 +99,10 @@ PROJ_internal_prefix := $(prefix)
+ endif
+
+ PROJ_bindir := $(PROJ_prefix)/bin
+-PROJ_libdir := $(PROJ_prefix)/lib
++PROJ_libdir := $(PROJ_prefix)/$(GENTOO_LIBDIR)
+ PROJ_datadir := $(PROJ_prefix)/share
+-PROJ_docsdir := $(PROJ_prefix)/docs/llvm
+-PROJ_etcdir := $(PROJ_prefix)/etc/llvm
++PROJ_docsdir := $(PROJ_prefix)/share/doc/@PF@
++PROJ_etcdir := @EPREFIX@/etc/llvm
+ PROJ_includedir := $(PROJ_prefix)/include
+ PROJ_infodir := $(PROJ_prefix)/info
+ PROJ_mandir := $(PROJ_prefix)/share/man
+diff --git a/Makefile.rules b/Makefile.rules
+index c8c971f..d1258b1 100644
+--- a/Makefile.rules
++++ b/Makefile.rules
+@@ -283,7 +283,7 @@ ifeq ($(ENABLE_OPTIMIZED),1)
+ BuildMode := Release
+ # Don't use -fomit-frame-pointer on Darwin or FreeBSD.
+ ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin Darwin DragonFly FreeBSD GNU/kFreeBSD))
+- OmitFramePointer := -fomit-frame-pointer
++ OmitFramePointer :=
+ endif
+
+ CXX.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
+diff --git a/tools/llvm-config/BuildVariables.inc.in b/tools/llvm-config/BuildVariables.inc.in
+index 3f51f49..513ea89 100644
+--- a/tools/llvm-config/BuildVariables.inc.in
++++ b/tools/llvm-config/BuildVariables.inc.in
+@@ -26,3 +26,4 @@
+ #define LLVM_LIBDIR_SUFFIX "@LLVM_LIBDIR_SUFFIX@"
+ #define LLVM_TARGETS_BUILT "@LLVM_TARGETS_BUILT@"
+ #define LLVM_SYSTEM_LIBS "@LLVM_SYSTEM_LIBS@"
++#define LLVM_LIBDIR "@LLVM_LIBDIR@"
+diff --git a/tools/llvm-config/Makefile b/tools/llvm-config/Makefile
+index 1ff8b6f..5d73c6e 100644
+--- a/tools/llvm-config/Makefile
++++ b/tools/llvm-config/Makefile
+@@ -65,6 +65,8 @@ $(ObjDir)/BuildVariables.inc: $(BUILDVARIABLES_SRCPATH) Makefile $(ObjDir)/.dir
+ >> temp.sed
+ $(Verb) $(ECHO) 's/@LLVM_TARGETS_BUILT@/$(subst /,\/,$(TARGETS_TO_BUILD))/' \
+ >> temp.sed
++ $(Verb) $(ECHO) 's/@LLVM_LIBDIR@/$(subst /,\/,$(GENTOO_LIBDIR))/' \
++ >> temp.sed
+ $(Verb) $(SED) -f temp.sed < $< > $@
+ $(Verb) $(RM) temp.sed
+
+diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp
+index 224035a..57180ac 100644
+--- a/tools/llvm-config/llvm-config.cpp
++++ b/tools/llvm-config/llvm-config.cpp
+@@ -265,7 +265,7 @@ int main(int argc, char **argv) {
+ ActivePrefix = CurrentExecPrefix;
+ ActiveIncludeDir = ActivePrefix + "/include";
+ ActiveBinDir = ActivePrefix + "/bin";
+- ActiveLibDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX;
++ ActiveLibDir = ActivePrefix + "/" LLVM_LIBDIR;
+ ActiveIncludeOption = "-I" + ActiveIncludeDir;
+ }
+
+--
+2.2.1
+
diff --git a/sys-devel/llvm/files/llvm-3.6.0-ocaml-ctypes-0.4.0.patch b/sys-devel/llvm/files/llvm-3.6.0-ocaml-ctypes-0.4.0.patch
new file mode 100644
index 0000000..154c9cc
--- /dev/null
+++ b/sys-devel/llvm/files/llvm-3.6.0-ocaml-ctypes-0.4.0.patch
@@ -0,0 +1,35 @@
+diff -Naur llvm-3.6.0.src.orig/bindings/ocaml/executionengine/llvm_executionengine.ml llvm-3.6.0.src/bindings/ocaml/executionengine/llvm_executionengine.ml
+--- llvm-3.6.0.src.orig/bindings/ocaml/executionengine/llvm_executionengine.ml 2015-03-17 11:49:27.274824345 +0100
++++ llvm-3.6.0.src/bindings/ocaml/executionengine/llvm_executionengine.ml 2015-03-17 11:49:40.333829421 +0100
+@@ -43,11 +43,11 @@
+ = "llvm_ee_run_static_dtors"
+ external data_layout : llexecutionengine -> Llvm_target.DataLayout.t
+ = "llvm_ee_get_data_layout"
+-external add_global_mapping_ : Llvm.llvalue -> int64 -> llexecutionengine -> unit
++external add_global_mapping_ : Llvm.llvalue -> nativeint -> llexecutionengine -> unit
+ = "llvm_ee_add_global_mapping"
+-external get_global_value_address_ : string -> llexecutionengine -> int64
++external get_global_value_address_ : string -> llexecutionengine -> nativeint
+ = "llvm_ee_get_global_value_address"
+-external get_function_address_ : string -> llexecutionengine -> int64
++external get_function_address_ : string -> llexecutionengine -> nativeint
+ = "llvm_ee_get_function_address"
+
+ let add_global_mapping llval ptr ee =
+@@ -55,14 +55,14 @@
+
+ let get_global_value_address name typ ee =
+ let vptr = get_global_value_address_ name ee in
+- if Int64.to_int vptr <> 0 then
++ if Nativeint.to_int vptr <> 0 then
+ let open Ctypes in !@ (coerce (ptr void) (ptr typ) (ptr_of_raw_address vptr))
+ else
+ raise (Error ("Value " ^ name ^ " not found"))
+
+ let get_function_address name typ ee =
+ let fptr = get_function_address_ name ee in
+- if Int64.to_int fptr <> 0 then
++ if Nativeint.to_int fptr <> 0 then
+ let open Ctypes in coerce (ptr void) typ (ptr_of_raw_address fptr)
+ else
+ raise (Error ("Function " ^ name ^ " not found"))
diff --git a/sys-devel/llvm/files/llvm-3.7-nodoctargz.patch b/sys-devel/llvm/files/llvm-3.7-nodoctargz.patch
new file mode 100644
index 0000000..8690523
--- /dev/null
+++ b/sys-devel/llvm/files/llvm-3.7-nodoctargz.patch
@@ -0,0 +1,49 @@
+--- docs/Makefile.orig 2012-04-30 17:00:01.000000000 +0200
++++ docs/Makefile 2012-04-30 17:15:52.000000000 +0200
+@@ -52,11 +52,10 @@
+ # 'make generated BUILD_FOR_WEBSITE=1'
+ generated:: $(generated_targets)
+
+-install-html: $(PROJ_OBJ_DIR)/html.tar.gz
++install-html:
+ $(Echo) Installing HTML documentation
+ $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_docsdir)/html
+ $(Verb) $(DataInstall) $(HTML) $(DESTDIR)$(PROJ_docsdir)/html
+- $(Verb) $(DataInstall) $(PROJ_OBJ_DIR)/html.tar.gz $(DESTDIR)$(PROJ_docsdir)
+
+ $(PROJ_OBJ_DIR)/html.tar.gz: $(HTML)
+ $(Echo) Packaging HTML documentation
+@@ -68,12 +67,11 @@
+
+ install-doxygen: doxygen
+ $(Echo) Installing doxygen documentation
+- $(Verb) $(DataInstall) $(PROJ_OBJ_DIR)/doxygen.tar.gz $(DESTDIR)$(PROJ_docsdir)
+ $(Verb) cd $(PROJ_OBJ_DIR)/doxygen/html && \
+ for DIR in $$($(FIND) . -type d); do \
+ DESTSUB="$(DESTDIR)$(PROJ_docsdir)/html/doxygen/$$(echo $$DIR | cut -c 3-)"; \
+ $(MKDIR) $$DESTSUB && \
+ $(FIND) $$DIR -maxdepth 1 -type f -exec $(DataInstall) {} $$DESTSUB \; ; \
+ if [ $$? != 0 ]; then exit 1; fi \
+ done
+
+-doxygen: regendoc $(PROJ_OBJ_DIR)/doxygen.tar.gz
++doxygen: regendoc
+
+ regendoc:
+ $(Echo) Building doxygen documentation
+@@ -99,7 +97,6 @@
+ install-ocamldoc: ocamldoc
+ $(Echo) Installing ocamldoc documentation
+ $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_docsdir)/ocamldoc/html
+- $(Verb) $(DataInstall) $(PROJ_OBJ_DIR)/ocamldoc.tar.gz $(DESTDIR)$(PROJ_docsdir)
+ $(Verb) cd $(PROJ_OBJ_DIR)/ocamldoc && \
+ $(FIND) . -type f -exec \
+ $(DataInstall) {} $(DESTDIR)$(PROJ_docsdir)/ocamldoc/html \;
+@@ -109,7 +106,6 @@
+ $(Verb) $(RM) -rf $(PROJ_OBJ_DIR)/ocamldoc.tar*
+ $(Verb) $(TAR) cf $(PROJ_OBJ_DIR)/ocamldoc.tar ocamldoc
+ $(Verb) $(GZIPBIN) $(PROJ_OBJ_DIR)/ocamldoc.tar
+- $(Verb) $(CP) $(PROJ_OBJ_DIR)/ocamldoc.tar.gz $(PROJ_OBJ_DIR)/ocamldoc/html/
+
+ regen-ocamldoc:
+ $(Echo) Building ocamldoc documentation