summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2016-12-21 17:03:17 +0100
committerMichał Górny <mgorny@gentoo.org>2016-12-21 22:01:05 +0100
commite38485f5bf6e92cdc7c0109a07f3955821baa951 (patch)
tree4a9be4c587ea4459dd24bdbe2ab092c6f382f14b /sys-devel
parentsys-devel/llvm: Move patches around for 3.9.1 (diff)
downloadgentoo-e38485f5bf6e92cdc7c0109a07f3955821baa951.tar.gz
gentoo-e38485f5bf6e92cdc7c0109a07f3955821baa951.tar.bz2
gentoo-e38485f5bf6e92cdc7c0109a07f3955821baa951.zip
sys-devel/llvm: Bump to 3.9.1, backport gcc-config fixes
Bump to 3.9.1 bugfix release, and backport full set of gcc-config fixes from trunk. The latter includes fixing cross-compilation support, proper multilib gcc support and appropriate Gentoo tests.
Diffstat (limited to 'sys-devel')
-rw-r--r--sys-devel/llvm/Manifest5
-rw-r--r--sys-devel/llvm/files/3.9.1/clang/gcc-config.patch422
-rw-r--r--sys-devel/llvm/llvm-3.9.1.ebuild547
3 files changed, 974 insertions, 0 deletions
diff --git a/sys-devel/llvm/Manifest b/sys-devel/llvm/Manifest
index cebff1db1753..57252b5524fb 100644
--- a/sys-devel/llvm/Manifest
+++ b/sys-devel/llvm/Manifest
@@ -4,20 +4,24 @@ DIST cfe-3.6.2.src.tar.xz 8617576 SHA256 ae9180466a23acb426d12444d866b266ff2289b
DIST cfe-3.7.1.src.tar.xz 9110616 SHA256 56e2164c7c2a1772d5ed2a3e57485ff73ff06c97dff12edbeea1acc4412b0674 SHA512 8e3285a32ad0fd4721fa77c4fb9709f31bb4e4f7cb5245357aaf57b0767b6ef18a30d902b59d1437a6febffb6c2128214f9ce5aa913bb298743221a28c4f9de5 WHIRLPOOL ce300f5023bddda59ee055e4dccdca8bf459fae5d4e91c44262d2830c406b798d697d1bf3c6326ff41b969a8439f94a3c83570f1d0151a7f0223eb0d8f324f7b
DIST cfe-3.8.1.src.tar.xz 9605548 SHA256 4cd3836dfb4b88b597e075341cae86d61c63ce3963e45c7fe6a8bf59bb382cdf SHA512 72d23a410271b50f97371b13dd7a6c6c5c0a993e35df436ab716ece8521d83406aa3d4bf8fdecd8154139f39fd5e011e480d405225d8c3ff152d0a2ac4573e04 WHIRLPOOL 7bcc9e6fed871b7490e2a280f2ad36008150a0af3605357fbe529aea8a7acbbed41c7da273dd150f8f50869cd321f114e909236261c4dd05ed7f644c75f208c4
DIST cfe-3.9.0.src.tar.xz 10390440 SHA256 7596a7c7d9376d0c89e60028fe1ceb4d3e535e8ea8b89e0eb094e0dcb3183d28 SHA512 f405b5819fd19276b2de4da80a51171a3b1c5c00df810e1f284184c693e410775fe2933576f942b881664dd3b75e78f0f15b7e5a3eca7819ffbcfe528d9a578e WHIRLPOOL cb4ff4eaababa3017b4a96548b7fe1dc5f4926bd27dc6de56c3ae1fc450c8af1faf1edea2e909e40289477ebaf79860fca3a9695b22402dc9385031d7b8ad5bf
+DIST cfe-3.9.1.src.tar.xz 10363080 SHA256 e6c4cebb96dee827fa0470af313dff265af391cb6da8d429842ef208c8f25e63 SHA512 3f0eea194597e438bbe49ce9ef5fdced81459c21cbdd2653750b2fe02c55a0154d6a33a8cfd02e607b83314a8e35b2c300f944462120ab6de1d4139d85db56b8 WHIRLPOOL 9f70688c7c2857426bf5fbf039b9723ec73ec57e8d3b36da37589bcbdbdb090aa36cd1800f0521ef0c30065bf03083eade0ac81ef0939412919423db7779a6f8
DIST clang-tools-extra-3.5.2.src.tar.xz 215804 SHA256 f21a374d74b194d8c984546266491b518859b5f12ed9abd49337b8060d3fc004 SHA512 6a8e662d2704147296c13626fbc5885911c646c67404f12eacc67ee2995221445bf4f6122b271b9cb3a56b716f550a651024822f72358d400b9052bf50423669 WHIRLPOOL 088d2725a88a439a1a2c4048e0eaf540587078078bd1c9823a4804200265cab4d32606abf5e72be76da45ea4aa6e7a7201a2bdbddc78d5f9e0024b0d7b59e222
DIST clang-tools-extra-3.6.2.src.tar.xz 248624 SHA256 6a0ec627d398f501ddf347060f7a2ccea4802b2494f1d4fd7bda3e0442d04feb SHA512 1b7710a7deee30cefb6a3b4edb026a96d8935a0c6f3056ccdb7a45564d10baf01a4f6722ae853ad9a3bad17e8de32a3c0ec99c5cf6144647a5e182809d403f7a WHIRLPOOL 3dc8888c302bac84f53b673784dec092a2c59ea2985d9983e87f057b9aa7b5d3e34cf13d2b0f1f60ea44f342b8167377204a510036872a087037cf02335c19cd
DIST clang-tools-extra-3.7.1.src.tar.xz 277476 SHA256 4a91edaccad1ce984c7c49a4a87db186b7f7b21267b2b03bcf4bd7820715bc6b SHA512 06e2db8af75f1e6ee82da6ee723b5256b9e3f6ba196428f18944ec02d07df26d04329ca8824a083c5f25274ce7e3469aa75e3a29ccfbdb6375524841d65e3ad7 WHIRLPOOL 2c1a459d6aff6bc24d5c8d38120ab665adbef61394050781a9707d50e83dae1b4997ed19459086e9bd7f6dd38a09c295d135e33515c947d64a7f1ab714ad8beb
DIST clang-tools-extra-3.8.1.src.tar.xz 334768 SHA256 664a5c60220de9c290bf2a5b03d902ab731a4f95fe73a00856175ead494ec396 SHA512 ec8c4a6ac4fd1a0e24fc15e56ba00828e0d718c2f7bd477ea134ab094c67f4f4b2f603f128ec11a03b7f25f3e9b8fe75181e40730c56b7b683f54e3f37573137 WHIRLPOOL b05213cbe21b778e718233cecbf4d01b92c1f133eced6fdd3fa5059c4b10e5f0407549634f65032af177ba1614250f5c02e283c2b03563db3e227b1afcae424b
DIST clang-tools-extra-3.9.0.src.tar.xz 455144 SHA256 5b7aec46ec8e999ec683c87ad744082e1133781ee4b01905b4bdae5d20785f14 SHA512 7d5f8d3b44e45022db65434f4d141f23706edf6aa9f3c28ded43e84e85c7c4878ffe98bf15f71e4c71fd176dfc49ce5180892d710bc5eccf95de1ed12f3c8074 WHIRLPOOL 44863889eaa33face00b9644f5c1465446bec39f88bc5ea32835dfa091a83161e292c2b3bcdcccb7cb34cdc3f1970bb3bbfbf6918c425b11a1465bedc3e0611f
+DIST clang-tools-extra-3.9.1.src.tar.xz 456464 SHA256 29a5b65bdeff7767782d4427c7c64d54c3a8684bc6b217b74a70e575e4813635 SHA512 5691fb09f80b519876cdd2e82ad23a20bba32a0bc356e15e6db631b2936763911f15ff55f8bf5f073100b9e4cf217f08fdce90ae98ef0e084274259d3cfe9634 WHIRLPOOL 1b1d877da04a2d8f93e3181b9b32caad23874a052c1e29bc66fddf29efb8edd69979400fcff40de00831d041383356fe7c37ddd63de8a206498baa65f7b79872
DIST compiler-rt-3.4.src.tar.gz 1858593 SHA256 f37c89b1383ce462d47537a0245ac798600887a9be9f63073e16b79ed536ab5c SHA512 70efffaf12ff7c15befa87ce808489c6f6b6eb421d0ab5d8ecd525239efc8aab850c7ed34b31a993ff5e499657b72598619945cc4461fe3e5359e9a94aaac0c8 WHIRLPOOL ad558b5877a01e476d30d2757959ab04be0c385b2fe3442bcc578bf36c6f3214cd78b4adda24fcb1f3b2b84353db213b82e8d7d4c40e66c3f57aed3a49322dbc
DIST compiler-rt-3.5.2.src.tar.xz 1093000 SHA256 542d7aadd21e7fe35bea0a7912bc965f08a1a566746cebcca76f96dcfeb74dc3 SHA512 319a8a1dbe07eb4f1fcccfe79a1fa445f348fb854a441500e89fa0a128e45716b65d06347f19a63de32e9294cd2331e914ae0d5fe8224f0b2452c39b79ac96ff WHIRLPOOL 6e9286c56a60a515006c8232ca01622ae844185a5f31fb49bce632868862c5e560619f1c45da66878b5322a764f91a284cd296e9f13105d6f74e055a17321d93
DIST compiler-rt-3.6.2.src.tar.xz 1128080 SHA256 0f2ff37d80a64575fecd8cf0d5c50f7ac1f837ddf700d1855412bb7547431d87 SHA512 7dafcc5bd4822475de649d8a84ae51af3c4ed4d0958f76b1b55ba79219638f3e78eb94a1986c6e9ba0e7f1ccf3ec834d546b5ca60e8b08083fea5880ecdf17a3 WHIRLPOOL dd77e7df43c9028a6873ed903da67560fdb04968013016a7f0ad2d2e9a81b3a3d890b95e4f49a6bdef349806d6507defcd80a0a9fb50c1c9f778e7eff42dbc5d
DIST compiler-rt-3.7.1.src.tar.xz 1181772 SHA256 9d4769e4a927d3824bcb7a9c82b01e307c68588e6de4e7f04ab82d82c5af8181 SHA512 bf434519ea0838264c30de1e1e8681320aa868df0ecc825a45c659077b963a4120c18216946558cbf8aea24a8ac8ec39af2066dab906bc7cabc0894d51d61325 WHIRLPOOL 0bea047e48622884a6fc6bb3826046e9de5b3192006cc41c0ccd9d6c611674869c3c15988b531a0f7d9fea2cf951b90ecef385b85db765c6f99a48692fdcf223
DIST compiler-rt-3.8.1.src.tar.xz 1263312 SHA256 0df011dae14d8700499dfc961602ee0a9572fef926202ade5dcdfe7858411e5c SHA512 bed3da5f8594c4bf71af406419fbeaf7ed5d8bf46adb305233a298271d34a9af1072bcb47d474ac19bb862cc7c7bc9e1d89bc1567133553f29480030cad1cf75 WHIRLPOOL 950de96c57461c51ee9857dd56a858876f6bdb09f44ea1ec96c6f113d3499f5f3ddb90e86a8a6b50460577e1b4857da3dd6024eb3427d837630a2c4c678c360a
DIST compiler-rt-3.9.0.src.tar.xz 1379960 SHA256 e0e5224fcd5740b61e416c549dd3dcda92f10c524216c1edb5e979e42078a59a SHA512 8d15c0315d7a89d9336e0ae4b72775d0815a8e7d962056645e1d0c6a23759bb2d8133c9ad2164e181f017641e8a184a062fbc876a371b81d5b1c2626405f6616 WHIRLPOOL 7279962a7dfaf7bb733b9f361ade776678d5b8bafc520d6fc086c043154f1b9299b8c18d1721112982b52158eccdb549542327122a174ce9b86d39cfb2d39837
+DIST compiler-rt-3.9.1.src.tar.xz 1376372 SHA256 d30967b1a5fa51a2503474aacc913e69fd05ae862d37bf310088955bdb13ec99 SHA512 91a4c78a5e8c1cdd2d6bbcb27d2c34f49ea30a952733444ef4f4a7cc7503c880d4b6924595e87745ef6278851178f49f98d38d2068975d4fb6577fb9e9cdcdbe WHIRLPOOL 06c55bbd9f79f1b3ee0adf058e6c540c3df5542337840d35e43e149d10605a95ba1363b360de25ebad41b048dd4e8f2aac25604b4f55f6a282fe01b014104d56
DIST lldb-3.7.1.src.tar.xz 10650524 SHA256 9a0bc315ef55f44c98cdf92d064df0847f453ed156dd0ef6a87e04f5fd6a0e01 SHA512 d2d3e1052026edd6ef9113ff5362acb4a32cef598098b4031c35e389301130ef2e1bda594f30de4d65c9fdc0beaecdd35afcf36676eb540baad34015aca294d1 WHIRLPOOL bba9c700788f0cf86ac1de51383a223e1c92f724719cdd327d83189cb77714c1e10fb78569aeed3b3c639062a3410bb114f646a271fd0d9e8c9a8e45d090330a
DIST lldb-3.8.1.src.tar.xz 10928220 SHA256 349148116a47e39dcb5d5042f10d8a6357d2c865034563283ca512f81cdce8a3 SHA512 d73c55daed6ef5e5ca784c7010f2d75be26024b14fa61a2861a8a6cbe129e417fb7be2a3b532e17e9d7de98ae38ce6a689d8166049eff365fb04f4bd772758f3 WHIRLPOOL 78dd8161cd1411bd62cb3ffe1196fe95ccb73d78f2e141a58c63776eb6d91065fe1348b1b8e241630cdf954ab659b333ebbcdcaeba3e6df36af62aaf3a7c6634
DIST lldb-3.9.0.src.tar.xz 13754516 SHA256 61280e07411e3f2b4cca0067412b39c16b0a9edd19d304d3fc90249899d12384 SHA512 b2d7f36b4462dba8e478022da19981e2d029bc4728efeed50600f0d03e3dd4573e7fb3cee773ec19b11ad3d8ba53b1aef9de1b21612e77d2888d0f6de433b24a WHIRLPOOL 6df1ea72ae76826e318a8602105203e6456a3dd7277a3080f3d5a32958c539e34922a178e0ea32440744a5b76029eb50032eb0de2288762490b67709da89dbf1
+DIST lldb-3.9.1.src.tar.xz 13750816 SHA256 7e3311b2a1f80f4d3426e09f9459d079cab4d698258667e50a46dccbaaa460fc SHA512 e2957a1da60284595b21c205b07fa3db5c474bfad1935ab8e1bc832f30af497e9eb709efeb703591ef62e7dd73a28d22fc21398097a232c8a729946d72eb5df7 WHIRLPOOL ef4903cca78c6509602c72f37738326f0f0544275f068571d9bcfd1e26eb5fb4f78f5f41790a2696e045ac9d6f45adfdb7edd532ac41fd82565b50a6db93725e
DIST llvm-3.4-manpages.tar.bz2 33753 SHA256 dc2616104cf333dd9ef56b2d31f9a36e81303e2c5756ff8bc221e05b46f7e1cb SHA512 8e438a9392c9b896ccb2b1460a8f57ffa01633e3a6bba61e2bf2f718d970ff96c17d63b0bc0d4da1162e1d1dc4cb9b2a9e9a14a722e8a5b5d2f205f037ae665d WHIRLPOOL 1c037a9972442937f84bc3147d77d4bbc6d6c0812c3025f3107c2ee5f6259afab990f6e1bca564237fdca8089e2372df4b7ca45cbdea686fbf891f92d1bfbbe6
DIST llvm-3.4.2.src.tar.gz 15938155 SHA256 17038d47069ad0700c063caed76f0c7259628b0e79651ce2b540d506f2f1efd7 SHA512 6c1453f7d9d9110257db3574cc4f6227fed8938705cbb09851ac09a868089b48f1556a1b6e758aff6d97520b08b5605d3ed20411ad9dd22cdc573d62176905f0 WHIRLPOOL f8b4d5167469e6f350ec41aede04e7b756e18f3d8e78b3270beb5791310a7b9b13c69e57c8bcfefbd0a78efc0c40e3b75a9a158eac72c025b7c77146e8dfaf7c
DIST llvm-3.5.0-manpages.tar.bz2 35314 SHA256 724e752a60016dce8cc536658906d3646c600e977374e0ea692a5d0fe2d4a021 SHA512 d99d6096d7f21a81923297584fe5eeb23e0d83d4538fe376615c92fffc8aff3189999f7ab3c537b5aa5d6bc2c22c53eb05717d48c7ab99c42315b8665bac62c3 WHIRLPOOL 68ced06ee6678c5333c662eb1cc0da744c5a184b12dd059c1b77ec200b1d3cc231f270b9d9b6e177d728776894277b3f9061338aa55620c90474eb97915b7819
@@ -30,3 +34,4 @@ DIST llvm-3.8.0-manpages.tar.bz2 37889 SHA256 4dda7f69f9412e0fb50d32631df34d6ea7
DIST llvm-3.8.1.src.tar.xz 16551472 SHA256 6e82ce4adb54ff3afc18053d6981b6aed1406751b8742582ed50f04b5ab475f9 SHA512 99bbb2cc5f337fd5edf1621f8028c8cb74011aa4af2531018dc05409b27f7b8d0c2f76a00115f677f7c013029d5d9f55d085a5b40433409aac4e9161d53bd366 WHIRLPOOL a99cef164a0e05e5237b840bee776d48fe0bde460cb4536f03a5e4eb0cc630deeb96f76bdd42f912a4b2dab08133bd9137ea16be1b9582d375f0f5841dd40234
DIST llvm-3.9.0.src.tar.xz 18235716 SHA256 66c73179da42cee1386371641241f79ded250e117a79f571bbd69e56daa48948 SHA512 f18ae32531218ab156c3e56c11826be0fd05f0799c82eaf2e6a043b38e1277560b4d921987513b88b11d97ea2619feaf277eec72181dd2ae4f4108c2836bf7b2 WHIRLPOOL a36c1bcee6e7995067a9a7a51e3fdb0f10d51d0239250eefab92ed2e46b024a203fa10a17a25a5aca69046bcb413628e288427f1a6690d0862e07cd95694c8a8
DIST llvm-3.9.0_rc3-manpages.tar.bz2 80007 SHA256 991f5238d23c0aee2fd303d1adecd6045c42ed066f42f0d58f62c3a25c197140 SHA512 f96c340021de3f096ec3ad7d51a6af2c7a84974122d1df15729a39d4f9d65452f063a85ab38adb064288dc14220d9cc679b31ee19b48424d3d7cde621ff37597 WHIRLPOOL d3f24a2faaa5aa909519373532262c342acf517048ac543f303b6ddb539f5ece876a338c8efc445f4ada6f723a4e65e35bd5f2f9b4f52ef96ef832000259ab20
+DIST llvm-3.9.1.src.tar.xz 18130436 SHA256 1fd90354b9cf19232e8f168faf2220e79be555df3aa743242700879e8fd329ee SHA512 50cbe8ee911080f586e77861c442348701bd02e2de0c090c54c34f82ac275ecfcd712af0f41e387c33b4a6057778a4258a27554292fe68ab4af3fd9dd6d90683 WHIRLPOOL 1cd1a25befcb178bec4a4aace4367167f3838d32edbe9db9de8c6e558c01c1fcf123f6d6f80b7ec9ff32b3d6dcf2de2f4eb4201d417c3d17a5c8a69934832903
diff --git a/sys-devel/llvm/files/3.9.1/clang/gcc-config.patch b/sys-devel/llvm/files/3.9.1/clang/gcc-config.patch
new file mode 100644
index 000000000000..42d5d0405992
--- /dev/null
+++ b/sys-devel/llvm/files/3.9.1/clang/gcc-config.patch
@@ -0,0 +1,422 @@
+From a0b8bc9ef667ed7158400f7cbf772e470661d203 Mon Sep 17 00:00:00 2001
+From: Michal Gorny <mgorny@gentoo.org>
+Date: Tue, 25 Oct 2016 15:07:41 +0000
+Subject: [PATCH] (squashed gcc-config patch, from commits:)
+
+[Driver] Support obtaining active toolchain from gcc-config on Gentoo
+
+Support using gcc-config to determine the correct GCC toolchain location
+on Gentoo. In order to do that, attempt to read gcc-config configuration
+form [[sysroot]]/etc/env.d/gcc, if no custom toolchain location is
+provided.
+
+Differential Revision: https://reviews.llvm.org/D25661
+
+git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@285074 91177308-0d34-0410-b5e6-96231b3b80d8
+
+[Driver] Fix finding multilib gcc install on Gentoo (with gcc-config)
+
+Fix the gcc-config code to support multilib gcc installs properly. This
+solves two problems: -mx32 using the 64-bit gcc directory (due to matching
+installation triple), and -m32 not respecting gcc-config at all (due to
+mismatched installation triple).
+
+In order to fix the former issue, split the multilib scan out of
+Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple() (the code
+is otherwise unchanged), and call it for each installation found via
+gcc-config.
+
+In order to fix the latter issue, split the gcc-config processing out of
+Generic_GCC::GCCInstallationDetector::init() and repeat it for all
+triples, including extra and biarch triples. The only change
+in the gcc-config code itself is adding the call to multilib scan.
+
+Convert the gentoo_linux_gcc_multi_version_tree test input to multilib
+x86_64+32+x32 install, and add appropriate tests to linux-header-search
+and linux-ld.
+
+Differential Revision: https://reviews.llvm.org/D26887
+
+git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@289436 91177308-0d34-0410-b5e6-96231b3b80d8
+
+[Driver] Attempt to fix new linux-ld tests on Windows
+
+(broken by r289436)
+
+git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@289440 91177308-0d34-0410-b5e6-96231b3b80d8
+---
+ lib/Driver/ToolChains.cpp | 104 +++++++++++++++++----
+ lib/Driver/ToolChains.h | 10 ++
+ .../etc/env.d/gcc/config-x86_64-pc-linux-gnu | 1 +
+ .../etc/env.d/gcc/x86_64-pc-linux-gnu-4.9.3 | 10 ++
+ .../etc/gentoo-release | 1 +
+ .../usr/include/.keep | 0
+ .../gcc/x86_64-pc-linux-gnu/4.9.3/32/crtbegin.o | 0
+ .../lib/gcc/x86_64-pc-linux-gnu/4.9.3/crtbegin.o | 0
+ .../4.9.3/include/g++-v4.9.3/.keep | 0
+ .../gcc/x86_64-pc-linux-gnu/4.9.3/x32/crtbegin.o | 0
+ .../gcc/x86_64-pc-linux-gnu/5.4.0/32/crtbegin.o | 0
+ .../lib/gcc/x86_64-pc-linux-gnu/5.4.0/crtbegin.o | 0
+ .../5.4.0/include/g++-v5.4.0/.keep | 0
+ .../gcc/x86_64-pc-linux-gnu/5.4.0/x32/crtbegin.o | 0
+ .../usr/x86_64-pc-linux-gnu/lib/.keep | 0
+ test/Driver/linux-header-search.cpp | 42 +++++++++
+ test/Driver/linux-ld.c | 53 +++++++++++
+ 17 files changed, 204 insertions(+), 17 deletions(-)
+ create mode 100644 test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/config-x86_64-pc-linux-gnu
+ create mode 100644 test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/x86_64-pc-linux-gnu-4.9.3
+ create mode 100644 test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/gentoo-release
+ create mode 100644 test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/include/.keep
+ create mode 100644 test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/32/crtbegin.o
+ create mode 100644 test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/crtbegin.o
+ create mode 100644 test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3/.keep
+ create mode 100644 test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/x32/crtbegin.o
+ create mode 100644 test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/32/crtbegin.o
+ create mode 100644 test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/crtbegin.o
+ create mode 100644 test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/g++-v5.4.0/.keep
+ create mode 100644 test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/x32/crtbegin.o
+ create mode 100644 test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/x86_64-pc-linux-gnu/lib/.keep
+
+diff --git a/tools/clang/lib/Driver/ToolChains.cpp b/tools/clang/lib/Driver/ToolChains.cpp
+index 1b02f467c1..84123ea132 100644
+--- a/tools/clang/lib/Driver/ToolChains.cpp
++++ b/tools/clang/lib/Driver/ToolChains.cpp
+@@ -1420,6 +1420,25 @@ void Generic_GCC::GCCInstallationDetector::init(
+ }
+ }
+
++ // Try to respect gcc-config on Gentoo. However, do that only
++ // if --gcc-toolchain is not provided or equal to the Gentoo install
++ // in /usr. This avoids accidentally enforcing the system GCC version
++ // when using a custom toolchain.
++ if (GCCToolchainDir == "" || GCCToolchainDir == D.SysRoot + "/usr") {
++ for (StringRef CandidateTriple : ExtraTripleAliases) {
++ if (ScanGentooGccConfig(TargetTriple, Args, CandidateTriple))
++ return;
++ }
++ for (StringRef CandidateTriple : CandidateTripleAliases) {
++ if (ScanGentooGccConfig(TargetTriple, Args, CandidateTriple))
++ return;
++ }
++ for (StringRef CandidateTriple : CandidateBiarchTripleAliases) {
++ if (ScanGentooGccConfig(TargetTriple, Args, CandidateTriple, 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");
+@@ -2546,6 +2565,33 @@ void Generic_GCC::GCCInstallationDetector::scanLibDirForGCCTripleSolaris(
+ }
+ }
+
++bool Generic_GCC::GCCInstallationDetector::ScanGCCForMultilibs(
++ const llvm::Triple &TargetTriple, const ArgList &Args,
++ StringRef Path, bool NeedsBiarchSuffix) {
++ llvm::Triple::ArchType TargetArch = TargetTriple.getArch();
++ DetectedMultilibs Detected;
++
++ // Android standalone toolchain could have multilibs for ARM and Thumb.
++ // Debian mips multilibs behave more like the rest of the biarch ones,
++ // so handle them there
++ if (isArmOrThumbArch(TargetArch) && TargetTriple.isAndroid()) {
++ // It should also work without multilibs in a simplified toolchain.
++ findAndroidArmMultilibs(D, TargetTriple, Path, Args, Detected);
++ } else if (isMipsArch(TargetArch)) {
++ if (!findMIPSMultilibs(D, TargetTriple, Path, Args, Detected))
++ return false;
++ } else if (!findBiarchMultilibs(D, TargetTriple, Path, Args,
++ NeedsBiarchSuffix, Detected)) {
++ return false;
++ }
++
++ Multilibs = Detected.Multilibs;
++ SelectedMultilib = Detected.SelectedMultilib;
++ BiarchSibling = Detected.BiarchSibling;
++
++ return true;
++}
++
+ void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple(
+ const llvm::Triple &TargetTriple, const ArgList &Args,
+ const std::string &LibDir, StringRef CandidateTriple,
+@@ -2601,25 +2647,10 @@ void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple(
+ if (CandidateVersion <= Version)
+ continue;
+
+- DetectedMultilibs Detected;
+-
+- // Android standalone toolchain could have multilibs for ARM and Thumb.
+- // Debian mips multilibs behave more like the rest of the biarch ones,
+- // so handle them there
+- if (isArmOrThumbArch(TargetArch) && TargetTriple.isAndroid()) {
+- // It should also work without multilibs in a simplified toolchain.
+- findAndroidArmMultilibs(D, TargetTriple, LI->getName(), Args, Detected);
+- } else if (isMipsArch(TargetArch)) {
+- if (!findMIPSMultilibs(D, TargetTriple, LI->getName(), Args, Detected))
+- continue;
+- } else if (!findBiarchMultilibs(D, TargetTriple, LI->getName(), Args,
+- NeedsBiarchSuffix, Detected)) {
++ if (!ScanGCCForMultilibs(TargetTriple, Args, LI->getName(),
++ NeedsBiarchSuffix))
+ continue;
+- }
+
+- Multilibs = Detected.Multilibs;
+- SelectedMultilib = Detected.SelectedMultilib;
+- BiarchSibling = Detected.BiarchSibling;
+ Version = CandidateVersion;
+ GCCTriple.setTriple(CandidateTriple);
+ // FIXME: We hack together the directory name here instead of
+@@ -2633,6 +2664,45 @@ void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple(
+ }
+ }
+
++bool Generic_GCC::GCCInstallationDetector::ScanGentooGccConfig(
++ const llvm::Triple &TargetTriple, const ArgList &Args,
++ StringRef CandidateTriple, bool NeedsBiarchSuffix) {
++ llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> File =
++ D.getVFS().getBufferForFile(D.SysRoot + "/etc/env.d/gcc/config-" +
++ CandidateTriple.str());
++ if (File) {
++ SmallVector<StringRef, 2> Lines;
++ File.get()->getBuffer().split(Lines, "\n");
++ for (StringRef Line : Lines) {
++ // CURRENT=triple-version
++ if (Line.startswith("CURRENT=")) {
++ const std::pair<StringRef, StringRef> ActiveVersion =
++ Line.substr(8).rsplit('-');
++ // Note: Strictly speaking, we should be reading
++ // /etc/env.d/gcc/${CURRENT} now. However, the file doesn't
++ // contain anything new or especially useful to us.
++ const std::string GentooPath = D.SysRoot + "/usr/lib/gcc/" +
++ ActiveVersion.first.str() + "/" +
++ ActiveVersion.second.str();
++ if (D.getVFS().exists(GentooPath + "/crtbegin.o")) {
++ if (!ScanGCCForMultilibs(TargetTriple, Args, GentooPath,
++ NeedsBiarchSuffix))
++ return false;
++
++ Version = GCCVersion::Parse(ActiveVersion.second);
++ GCCInstallPath = GentooPath;
++ GCCParentLibPath = GentooPath + "/../../..";
++ GCCTriple.setTriple(ActiveVersion.first);
++ IsValid = true;
++ return true;
++ }
++ }
++ }
++ }
++
++ return false;
++}
++
+ Generic_GCC::Generic_GCC(const Driver &D, const llvm::Triple &Triple,
+ const ArgList &Args)
+ : ToolChain(D, Triple, Args), GCCInstallation(D), CudaInstallation(D) {
+diff --git a/tools/clang/lib/Driver/ToolChains.h b/tools/clang/lib/Driver/ToolChains.h
+index 369712fa93..6c2d0cb201 100644
+--- a/tools/clang/lib/Driver/ToolChains.h
++++ b/tools/clang/lib/Driver/ToolChains.h
+@@ -143,6 +143,11 @@ public:
+ SmallVectorImpl<StringRef> &BiarchLibDirs,
+ SmallVectorImpl<StringRef> &BiarchTripleAliases);
+
++ bool ScanGCCForMultilibs(const llvm::Triple &TargetTriple,
++ const llvm::opt::ArgList &Args,
++ StringRef Path,
++ bool NeedsBiarchSuffix = false);
++
+ void ScanLibDirForGCCTriple(const llvm::Triple &TargetArch,
+ const llvm::opt::ArgList &Args,
+ const std::string &LibDir,
+@@ -154,6 +159,11 @@ public:
+ const std::string &LibDir,
+ StringRef CandidateTriple,
+ bool NeedsBiarchSuffix = false);
++
++ bool ScanGentooGccConfig(const llvm::Triple &TargetTriple,
++ const llvm::opt::ArgList &Args,
++ StringRef CandidateTriple,
++ bool NeedsBiarchSuffix = false);
+ };
+
+ protected:
+diff --git a/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/config-x86_64-pc-linux-gnu b/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/config-x86_64-pc-linux-gnu
+new file mode 100644
+index 0000000000..5ef56a33a6
+--- /dev/null
++++ b/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/config-x86_64-pc-linux-gnu
+@@ -0,0 +1 @@
++CURRENT=x86_64-pc-linux-gnu-4.9.3
+diff --git a/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/x86_64-pc-linux-gnu-4.9.3 b/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/x86_64-pc-linux-gnu-4.9.3
+new file mode 100644
+index 0000000000..9ff406284f
+--- /dev/null
++++ b/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/x86_64-pc-linux-gnu-4.9.3
+@@ -0,0 +1,10 @@
++PATH="/usr/x86_64-pc-linux-gnu/gcc-bin/4.9.3"
++ROOTPATH="/usr/x86_64-pc-linux-gnu/gcc-bin/4.9.3"
++GCC_PATH="/usr/x86_64-pc-linux-gnu/gcc-bin/4.9.3"
++LDPATH="/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3:/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/32"
++MANPATH="/usr/share/gcc-data/x86_64-pc-linux-gnu/4.9.3/man"
++INFOPATH="/usr/share/gcc-data/x86_64-pc-linux-gnu/4.9.3/info"
++STDCXX_INCDIR="g++-v4"
++CTARGET="x86_64-pc-linux-gnu"
++GCC_SPECS=""
++MULTIOSDIRS="../lib64:../lib32"
+diff --git a/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/gentoo-release b/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/gentoo-release
+new file mode 100644
+index 0000000000..5f0944f7d9
+--- /dev/null
++++ b/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/gentoo-release
+@@ -0,0 +1 @@
++Gentoo Base System release 2.3
+diff --git a/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/include/.keep b/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/include/.keep
+new file mode 100644
+index 0000000000..e69de29bb2
+diff --git a/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/32/crtbegin.o b/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/32/crtbegin.o
+new file mode 100644
+index 0000000000..e69de29bb2
+diff --git a/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/crtbegin.o b/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/crtbegin.o
+new file mode 100644
+index 0000000000..e69de29bb2
+diff --git a/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3/.keep b/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3/.keep
+new file mode 100644
+index 0000000000..e69de29bb2
+diff --git a/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/x32/crtbegin.o b/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/x32/crtbegin.o
+new file mode 100644
+index 0000000000..e69de29bb2
+diff --git a/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/32/crtbegin.o b/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/32/crtbegin.o
+new file mode 100644
+index 0000000000..e69de29bb2
+diff --git a/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/crtbegin.o b/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/crtbegin.o
+new file mode 100644
+index 0000000000..e69de29bb2
+diff --git a/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/g++-v5.4.0/.keep b/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/g++-v5.4.0/.keep
+new file mode 100644
+index 0000000000..e69de29bb2
+diff --git a/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/x32/crtbegin.o b/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/x32/crtbegin.o
+new file mode 100644
+index 0000000000..e69de29bb2
+diff --git a/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/x86_64-pc-linux-gnu/lib/.keep b/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/x86_64-pc-linux-gnu/lib/.keep
+new file mode 100644
+index 0000000000..e69de29bb2
+diff --git a/tools/clang/test/Driver/linux-header-search.cpp b/tools/clang/test/Driver/linux-header-search.cpp
+index 5f6ac504a0..274895fb4f 100644
+--- a/tools/clang/test/Driver/linux-header-search.cpp
++++ b/tools/clang/test/Driver/linux-header-search.cpp
+@@ -301,6 +301,48 @@
+ // CHECK-GENTOO-4-9-3: "-internal-externc-isystem" "[[SYSROOT]]/include"
+ // CHECK-GENTOO-4-9-3: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+ //
++// Test support for Gentoo's gcc-config -- clang should prefer the older
++// (4.9.3) version over the newer (5.4.0) due to preference specified
++// in /etc/env.d/gcc/x86_64-pc-linux-gnu.
++// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
++// RUN: -target x86_64-unknown-linux-gnu -stdlib=libstdc++ \
++// RUN: --sysroot=%S/Inputs/gentoo_linux_gcc_multi_version_tree \
++// RUN: --gcc-toolchain="" \
++// RUN: | FileCheck --check-prefix=CHECK-GENTOO-4-9-3 %s
++//
++// Test that gcc-config support does not break multilib.
++// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
++// RUN: -target x86_64-unknown-linux-gnux32 -stdlib=libstdc++ \
++// RUN: --sysroot=%S/Inputs/gentoo_linux_gcc_multi_version_tree \
++// RUN: --gcc-toolchain="" \
++// RUN: | FileCheck --check-prefix=CHECK-GENTOO-4-9-3-X32 %s
++// CHECK-GENTOO-4-9-3-X32: "{{.*}}clang{{.*}}" "-cc1"
++// CHECK-GENTOO-4-9-3-X32: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
++// CHECK-GENTOO-4-9-3-X32: "-isysroot" "[[SYSROOT:[^"]+]]"
++// CHECK-GENTOO-4-9-3-X32: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3"
++// CHECK-GENTOO-4-9-3-X32: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3/x86_64-pc-linux-gnu/x32"
++// CHECK-GENTOO-4-9-3-X32: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3/backward"
++// CHECK-GENTOO-4-9-3-X32: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
++// CHECK-GENTOO-4-9-3-X32: "-internal-isystem" "[[RESOURCE_DIR]]{{/|\\\\}}include"
++// CHECK-GENTOO-4-9-3-X32: "-internal-externc-isystem" "[[SYSROOT]]/include"
++// CHECK-GENTOO-4-9-3-X32: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
++//
++// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
++// RUN: -target i386-unknown-linux-gnu -stdlib=libstdc++ \
++// RUN: --sysroot=%S/Inputs/gentoo_linux_gcc_multi_version_tree \
++// RUN: --gcc-toolchain="" \
++// RUN: | FileCheck --check-prefix=CHECK-GENTOO-4-9-3-32 %s
++// CHECK-GENTOO-4-9-3-32: "{{.*}}clang{{.*}}" "-cc1"
++// CHECK-GENTOO-4-9-3-32: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
++// CHECK-GENTOO-4-9-3-32: "-isysroot" "[[SYSROOT:[^"]+]]"
++// CHECK-GENTOO-4-9-3-32: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3"
++// CHECK-GENTOO-4-9-3-32: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3/x86_64-pc-linux-gnu/32"
++// CHECK-GENTOO-4-9-3-32: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3/backward"
++// CHECK-GENTOO-4-9-3-32: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
++// CHECK-GENTOO-4-9-3-32: "-internal-isystem" "[[RESOURCE_DIR]]{{/|\\\\}}include"
++// CHECK-GENTOO-4-9-3-32: "-internal-externc-isystem" "[[SYSROOT]]/include"
++// CHECK-GENTOO-4-9-3-32: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
++//
+ // Check header search on Debian 6 / MIPS64
+ // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+ // RUN: -target mips64-unknown-linux-gnuabi64 -stdlib=libstdc++ \
+diff --git a/tools/clang/test/Driver/linux-ld.c b/tools/clang/test/Driver/linux-ld.c
+index f9f4b482c9..ee995ac2d6 100644
+--- a/tools/clang/test/Driver/linux-ld.c
++++ b/tools/clang/test/Driver/linux-ld.c
+@@ -1650,3 +1650,56 @@
+ // CHECK-MUSL-ARMEBHF: "-dynamic-linker" "/lib/ld-musl-armebhf.so.1"
+ // CHECK-MUSL-AARCH64: "-dynamic-linker" "/lib/ld-musl-aarch64.so.1"
+ // CHECK-MUSL-AARCH64_BE: "-dynamic-linker" "/lib/ld-musl-aarch64_be.so.1"
++
++// Check whether multilib gcc install works fine on Gentoo with gcc-config
++// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
++// RUN: --target=x86_64-unknown-linux-gnu -rtlib=platform \
++// RUN: --sysroot=%S/Inputs/gentoo_linux_gcc_multi_version_tree \
++// RUN: --gcc-toolchain="" \
++// RUN: | FileCheck --check-prefix=CHECK-LD-GENTOO %s
++// CHECK-LD-GENTOO-NOT: warning:
++// CHECK-LD-GENTOO: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
++// CHECK-LD-GENTOO: "--eh-frame-hdr"
++// CHECK-LD-GENTOO: "-m" "elf_x86_64"
++// CHECK-LD-GENTOO: "-dynamic-linker"
++// CHECK-LD-GENTOO: "{{.*}}/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3{{/|\\\\}}crtbegin.o"
++// CHECK-LD-GENTOO: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3"
++// CHECK-LD-GENTOO: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/../../../../x86_64-pc-linux-gnu/lib"
++// CHECK-LD-GENTOO: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/../../.."
++// CHECK-LD-GENTOO: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
++// CHECK-LD-GENTOO: "-lc"
++// CHECK-LD-GENTOO: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
++// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
++// RUN: --target=i686-unknown-linux-gnu -rtlib=platform \
++// RUN: --sysroot=%S/Inputs/gentoo_linux_gcc_multi_version_tree \
++// RUN: --gcc-toolchain="" \
++// RUN: | FileCheck --check-prefix=CHECK-LD-GENTOO-32 %s
++// CHECK-LD-GENTOO-32-NOT: warning:
++// CHECK-LD-GENTOO-32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
++// CHECK-LD-GENTOO-32: "--eh-frame-hdr"
++// CHECK-LD-GENTOO-32: "-m" "elf_i386"
++// CHECK-LD-GENTOO-32: "-dynamic-linker"
++// CHECK-LD-GENTOO-32: "{{.*}}/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/32{{/|\\\\}}crtbegin.o"
++// CHECK-LD-GENTOO-32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/32"
++// CHECK-LD-GENTOO-32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/../../../../x86_64-pc-linux-gnu/lib"
++// CHECK-LD-GENTOO-32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/../../.."
++// CHECK-LD-GENTOO-32: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
++// CHECK-LD-GENTOO-32: "-lc"
++// CHECK-LD-GENTOO-32: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
++// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
++// RUN: --target=x86_64-unknown-linux-gnux32 -rtlib=platform \
++// RUN: --sysroot=%S/Inputs/gentoo_linux_gcc_multi_version_tree \
++// RUN: --gcc-toolchain="" \
++// RUN: | FileCheck --check-prefix=CHECK-LD-GENTOO-X32 %s
++// CHECK-LD-GENTOO-X32-NOT: warning:
++// CHECK-LD-GENTOO-X32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
++// CHECK-LD-GENTOO-X32: "--eh-frame-hdr"
++// CHECK-LD-GENTOO-X32: "-m" "elf32_x86_64"
++// CHECK-LD-GENTOO-X32: "-dynamic-linker"
++// CHECK-LD-GENTOO-X32: "{{.*}}/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/x32{{/|\\\\}}crtbegin.o"
++// CHECK-LD-GENTOO-X32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/x32"
++// CHECK-LD-GENTOO-X32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/../../../../x86_64-pc-linux-gnu/lib"
++// CHECK-LD-GENTOO-X32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/../../.."
++// CHECK-LD-GENTOO-X32: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
++// CHECK-LD-GENTOO-X32: "-lc"
++// CHECK-LD-GENTOO-X32: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
+--
+2.11.0
+
diff --git a/sys-devel/llvm/llvm-3.9.1.ebuild b/sys-devel/llvm/llvm-3.9.1.ebuild
new file mode 100644
index 000000000000..72baa968b1e2
--- /dev/null
+++ b/sys-devel/llvm/llvm-3.9.1.ebuild
@@ -0,0 +1,547 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=6
+
+: ${CMAKE_MAKEFILE_GENERATOR:=ninja}
+# (needed due to lib32 find_library fix)
+CMAKE_MIN_VERSION=3.6.1-r1
+PYTHON_COMPAT=( python2_7 )
+
+inherit check-reqs cmake-utils eutils flag-o-matic multilib \
+ multilib-minimal python-single-r1 toolchain-funcs pax-utils prefix
+
+DESCRIPTION="Low Level Virtual Machine"
+HOMEPAGE="http://llvm.org/"
+SRC_URI="http://llvm.org/releases/${PV}/${P}.src.tar.xz
+ clang? ( http://llvm.org/releases/${PV}/compiler-rt-${PV}.src.tar.xz
+ http://llvm.org/releases/${PV}/cfe-${PV}.src.tar.xz
+ http://llvm.org/releases/${PV}/clang-tools-extra-${PV}.src.tar.xz )
+ lldb? ( http://llvm.org/releases/${PV}/lldb-${PV}.src.tar.xz )
+ !doc? ( http://dev.gentoo.org/~mgorny/dist/${PN}-3.9.0_rc3-manpages.tar.bz2 )"
+
+# Keep in sync with CMakeLists.txt
+ALL_LLVM_TARGETS=( AArch64 AMDGPU ARM BPF Hexagon Mips MSP430
+ NVPTX PowerPC Sparc SystemZ X86 XCore )
+ALL_LLVM_TARGETS=( "${ALL_LLVM_TARGETS[@]/#/llvm_targets_}" )
+
+# Additional licenses:
+# 1. OpenBSD regex: Henry Spencer's license ('rc' in Gentoo) + BSD.
+# 2. ARM backend: LLVM Software Grant by ARM.
+# 3. MD5 code: public-domain.
+# 4. Tests (not installed):
+# a. gtest: BSD.
+# b. YAML tests: MIT.
+
+LICENSE="UoI-NCSA rc BSD public-domain
+ llvm_targets_ARM? ( LLVM-Grant )"
+SLOT="0/${PV}"
+KEYWORDS="~amd64 ~x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos"
+IUSE="clang debug default-compiler-rt default-libcxx doc gold libedit +libffi
+ lldb multitarget ncurses ocaml python +sanitize +static-analyzer test xml
+ elibc_musl kernel_Darwin kernel_FreeBSD ${ALL_LLVM_TARGETS[*]}"
+
+COMMON_DEPEND="
+ sys-libs/zlib:0=
+ clang? (
+ python? ( ${PYTHON_DEPS} )
+ static-analyzer? (
+ dev-lang/perl:*
+ ${PYTHON_DEPS}
+ )
+ xml? ( dev-libs/libxml2:2=[${MULTILIB_USEDEP}] )
+ )
+ gold? ( >=sys-devel/binutils-2.22:*[cxx] )
+ libedit? ( dev-libs/libedit:0=[${MULTILIB_USEDEP}] )
+ libffi? ( >=virtual/libffi-3.0.13-r1:0=[${MULTILIB_USEDEP}] )
+ lldb? ( dev-python/six[${PYTHON_USEDEP}] )
+ ncurses? ( >=sys-libs/ncurses-5.9-r3:0=[${MULTILIB_USEDEP}] )
+ ocaml? (
+ >=dev-lang/ocaml-4.00.0:0=
+ dev-ml/ocaml-ctypes:=
+ !!<=sys-devel/llvm-3.7.0-r1[ocaml] )"
+# configparser-3.2 breaks the build (3.3 or none at all are fine)
+DEPEND="${COMMON_DEPEND}
+ dev-lang/perl
+ >=sys-devel/make-3.81
+ >=sys-devel/flex-2.5.4
+ >=sys-devel/bison-1.875d
+ || ( >=sys-devel/gcc-3.0 >=sys-devel/llvm-3.5
+ ( >=sys-freebsd/freebsd-lib-9.1-r10 sys-libs/libcxx )
+ )
+ || ( >=sys-devel/binutils-2.18 >=sys-devel/binutils-apple-5.1 )
+ kernel_Darwin? ( <sys-libs/libcxx-${PV%_rc*}.9999 )
+ clang? ( xml? ( virtual/pkgconfig ) )
+ doc? ( dev-python/sphinx )
+ gold? ( sys-libs/binutils-libs )
+ libffi? ( virtual/pkgconfig )
+ lldb? ( dev-lang/swig )
+ !!<dev-python/configparser-3.3.0.2
+ ocaml? ( dev-ml/findlib
+ test? ( dev-ml/ounit ) )
+ ${PYTHON_DEPS}"
+RDEPEND="${COMMON_DEPEND}
+ clang? ( !<=sys-devel/clang-${PV}-r99 )
+ abi_x86_32? ( !<=app-emulation/emul-linux-x86-baselibs-20130224-r2
+ !app-emulation/emul-linux-x86-baselibs[-abi_x86_32(-)] )"
+PDEPEND="
+ clang? (
+ =sys-devel/clang-${PV}-r100
+ ~sys-devel/clang-runtime-${PV}
+ )
+ default-libcxx? ( sys-libs/libcxx )
+ kernel_Darwin? ( =sys-libs/libcxx-${PV%.*}* )"
+
+# pypy gives me around 1700 unresolved tests due to open file limit
+# being exceeded. probably GC does not close them fast enough.
+REQUIRED_USE="${PYTHON_REQUIRED_USE}
+ lldb? ( clang xml )
+ || ( ${ALL_LLVM_TARGETS[*]} )
+ multitarget? ( ${ALL_LLVM_TARGETS[*]} )"
+
+S=${WORKDIR}/${P/_}.src
+
+check_space() {
+ # in megs
+ # !clang !debug !multitarget -O2 400
+ # !clang !debug multitarget -O2 550
+ # clang !debug !multitarget -O2 950
+ # clang !debug multitarget -O2 1200
+ # !clang debug multitarget -O2 5G
+ # clang !debug multitarget -O0 -g 12G
+ # clang debug multitarget -O2 16G
+ # clang debug multitarget -O0 -g 14G
+
+ local build_size=550
+ use clang && build_size=1200
+
+ if use debug; then
+ ewarn "USE=debug is known to increase the size of package considerably"
+ ewarn "and cause the tests to fail."
+ ewarn
+
+ (( build_size *= 14 ))
+ elif is-flagq '-g?(gdb)?([1-9])'; then
+ ewarn "The C++ compiler -g option is known to increase the size of the package"
+ ewarn "considerably. If you run out of space, please consider removing it."
+ ewarn
+
+ (( build_size *= 10 ))
+ fi
+
+ # Multiply by number of ABIs :).
+ local abis=( $(multilib_get_enabled_abis) )
+ (( build_size *= ${#abis[@]} ))
+
+ local CHECKREQS_DISK_BUILD=${build_size}M
+ check-reqs_pkg_pretend
+}
+
+pkg_pretend() {
+ check_space
+}
+
+pkg_setup() {
+ check_space
+}
+
+src_unpack() {
+ default
+
+ if use clang; then
+ mv "${WORKDIR}"/cfe-${PV/_}.src "${S}"/tools/clang \
+ || die "clang source directory move failed"
+ mv "${WORKDIR}"/compiler-rt-${PV/_}.src "${S}"/projects/compiler-rt \
+ || die "compiler-rt source directory move failed"
+ mv "${WORKDIR}"/clang-tools-extra-${PV/_}.src "${S}"/tools/clang/tools/extra \
+ || die "clang-tools-extra source directory move failed"
+ fi
+
+ if use lldb; then
+ mv "${WORKDIR}"/lldb-${PV/_}.src "${S}"/tools/lldb \
+ || die "lldb source directory move failed"
+ fi
+}
+
+src_prepare() {
+ python_setup
+
+ # Fix libdir for ocaml bindings install, bug #559134
+ eapply "${FILESDIR}"/3.9.1/0001-cmake-Install-OCaml-modules-into-correct-package-loc.patch
+ # Do not build/install ocaml docs with USE=-doc, bug #562008
+ eapply "${FILESDIR}"/3.9.1/0002-cmake-Make-OCaml-docs-dependent-on-LLVM_BUILD_DOCS.patch
+
+ # Make it possible to override Sphinx HTML install dirs
+ # https://llvm.org/bugs/show_bug.cgi?id=23780
+ eapply "${FILESDIR}"/3.9.1/0003-cmake-Support-overriding-Sphinx-HTML-doc-install-dir.patch
+
+ # Prevent race conditions with parallel Sphinx runs
+ # https://llvm.org/bugs/show_bug.cgi?id=23781
+ eapply "${FILESDIR}"/3.9.1/0004-cmake-Add-an-ordering-dep-between-HTML-man-Sphinx-ta.patch
+
+ # Allow custom cmake build types (like 'Gentoo')
+ eapply "${FILESDIR}"/9999/0006-cmake-Remove-the-CMAKE_BUILD_TYPE-assertion.patch
+
+ # Fix llvm-config for shared linking and sane flags
+ # https://bugs.gentoo.org/show_bug.cgi?id=565358
+ eapply "${FILESDIR}"/3.9.1/llvm-config-r1.patch
+
+ # Restore SOVERSIONs for shared libraries
+ # https://bugs.gentoo.org/show_bug.cgi?id=578392
+ eapply "${FILESDIR}"/3.9.1/0008-cmake-Reintroduce-ldconfig-compatible-SOVERSIONs-on-.patch
+
+ # support building llvm against musl-libc
+ use elibc_musl && eapply "${FILESDIR}"/9999/musl-fixes.patch
+
+ # disable use of SDK on OSX, bug #568758
+ sed -i -e 's/xcrun/false/' utils/lit/lit/util.py || die
+
+ # Workaround, can be compiled with gcc on Gentoo/FreeBSD, bug #578064
+ use kernel_FreeBSD && tc-is-gcc && append-cppflags "-D_GLIBCXX_USE_C99"
+
+ if use clang; then
+ # Automatically select active system GCC's libraries, bugs #406163 and #417913
+ eapply "${FILESDIR}"/3.9.1/clang/gcc-config.patch
+
+ eapply "${FILESDIR}"/3.9.1/clang/darwin_prefix-include-paths.patch
+ eprefixify tools/clang/lib/Frontend/InitHeaderSearch.cpp
+
+ eapply "${FILESDIR}"/3.8.1/compiler-rt/darwin-default-sysroot.patch
+
+ pushd "${S}"/tools/clang >/dev/null || die
+ # be able to specify default values for -stdlib and -rtlib at build time
+ eapply "${FILESDIR}"/3.9.1/clang/default-libs.patch
+ popd >/dev/null || die
+
+ sed -i -e "s^@EPREFIX@^${EPREFIX}^" \
+ tools/clang/tools/scan-build/bin/scan-build || die
+
+ # Install clang runtime into /usr/lib/clang
+ # https://llvm.org/bugs/show_bug.cgi?id=23792
+ eapply "${FILESDIR}"/3.9.1/clang/0001-Install-clang-runtime-into-usr-lib-without-suffix.patch
+ eapply "${FILESDIR}"/3.9.1/compiler-rt/0001-cmake-Install-compiler-rt-into-usr-lib-without-suffi.patch
+
+ # Make it possible to override CLANG_LIBDIR_SUFFIX
+ # (that is used only to find LLVMgold.so)
+ # https://llvm.org/bugs/show_bug.cgi?id=23793
+ eapply "${FILESDIR}"/3.9.1/clang/0002-cmake-Make-CLANG_LIBDIR_SUFFIX-overridable.patch
+
+ # Fix git-clang-format shebang, bug #562688
+ python_fix_shebang tools/clang/tools/clang-format/git-clang-format
+
+ pushd projects/compiler-rt >/dev/null || die
+
+ # Fix WX sections, bug #421527
+ find lib/builtins -type f -name '*.S' -exec sed \
+ -e '$a\\n#if defined(__linux__) && defined(__ELF__)\n.section .note.GNU-stack,"",%progbits\n#endif' \
+ -i {} + || die
+
+ popd >/dev/null || die
+ fi
+
+ if use lldb; then
+ # Do not install dummy readline.so module from
+ # https://llvm.org/bugs/show_bug.cgi?id=18841
+ sed -e 's/add_subdirectory(readline)/#&/' \
+ -i tools/lldb/scripts/Python/modules/CMakeLists.txt || die
+ # Do not install bundled six module
+ eapply "${FILESDIR}"/3.9.1/lldb/six.patch
+ fi
+
+ # User patches
+ eapply_user
+
+ # Native libdir is used to hold LLVMgold.so
+ NATIVE_LIBDIR=$(get_libdir)
+}
+
+multilib_src_configure() {
+ local ffi_cflags ffi_ldflags
+ if use libffi; then
+ ffi_cflags=$($(tc-getPKG_CONFIG) --cflags-only-I libffi)
+ ffi_ldflags=$($(tc-getPKG_CONFIG) --libs-only-L libffi)
+ fi
+
+ local libdir=$(get_libdir)
+ local mycmakeargs=(
+ -DLLVM_LIBDIR_SUFFIX=${libdir#lib}
+
+ -DBUILD_SHARED_LIBS=ON
+ -DLLVM_TARGETS_TO_BUILD="${LLVM_TARGETS// /;}"
+ -DLLVM_BUILD_TESTS=$(usex test)
+
+ -DLLVM_ENABLE_FFI=$(usex libffi)
+ -DLLVM_ENABLE_TERMINFO=$(usex ncurses)
+ -DLLVM_ENABLE_ASSERTIONS=$(usex debug)
+ -DLLVM_ENABLE_EH=ON
+ -DLLVM_ENABLE_RTTI=ON
+
+ -DWITH_POLLY=OFF # TODO
+
+ -DLLVM_HOST_TRIPLE="${CHOST}"
+
+ -DFFI_INCLUDE_DIR="${ffi_cflags#-I}"
+ -DFFI_LIBRARY_DIR="${ffi_ldflags#-L}"
+
+ -DHAVE_HISTEDIT_H=$(usex libedit)
+ )
+
+ if use clang; then
+ mycmakeargs+=(
+ -DCMAKE_DISABLE_FIND_PACKAGE_LibXml2=$(usex !xml)
+ # libgomp support fails to find headers without explicit -I
+ # furthermore, it provides only syntax checking
+ -DCLANG_DEFAULT_OPENMP_RUNTIME=libomp
+
+ # override default stdlib and rtlib
+ -DCLANG_DEFAULT_CXX_STDLIB=$(usex default-libcxx libc++ "")
+ -DCLANG_DEFAULT_RTLIB=$(usex default-compiler-rt compiler-rt "")
+
+ # compiler-rt's test cases depend on sanitizer
+ -DCOMPILER_RT_BUILD_SANITIZERS=$(usex sanitize)
+ -DCOMPILER_RT_INCLUDE_TESTS=$(usex sanitize)
+ )
+ fi
+
+ if use lldb; then
+ mycmakeargs+=(
+ -DLLDB_DISABLE_LIBEDIT=$(usex !libedit)
+ -DLLDB_DISABLE_CURSES=$(usex !ncurses)
+ -DLLDB_ENABLE_TERMINFO=$(usex ncurses)
+ )
+ fi
+
+ if ! multilib_is_native_abi || ! use ocaml; then
+ mycmakeargs+=(
+ -DOCAMLFIND=NO
+ )
+ fi
+# Note: go bindings have no CMake rules at the moment
+# but let's kill the check in case they are introduced
+# if ! multilib_is_native_abi || ! use go; then
+ mycmakeargs+=(
+ -DGO_EXECUTABLE=GO_EXECUTABLE-NOTFOUND
+ )
+# fi
+
+ if multilib_is_native_abi; then
+ mycmakeargs+=(
+ -DLLVM_BUILD_DOCS=$(usex doc)
+ -DLLVM_ENABLE_SPHINX=$(usex doc)
+ -DLLVM_ENABLE_DOXYGEN=OFF
+ -DLLVM_INSTALL_HTML="${EPREFIX}/usr/share/doc/${PF}/html"
+ -DSPHINX_WARNINGS_AS_ERRORS=OFF
+ -DLLVM_INSTALL_UTILS=ON
+ )
+
+ if use clang; then
+ mycmakeargs+=(
+ -DCLANG_INSTALL_HTML="${EPREFIX}/usr/share/doc/${PF}/clang"
+ )
+ fi
+
+ if use gold; then
+ mycmakeargs+=(
+ -DLLVM_BINUTILS_INCDIR="${EPREFIX}"/usr/include
+ )
+ fi
+
+ if use lldb; then
+ mycmakeargs+=(
+ -DLLDB_DISABLE_PYTHON=$(usex !python)
+ )
+ fi
+
+ else
+ if use clang; then
+ mycmakeargs+=(
+ # disable compiler-rt on non-native ABI because:
+ # 1. it fails to configure because of -m32
+ # 2. it is shared between ABIs so no point building
+ # it multiple times
+ -DLLVM_EXTERNAL_COMPILER_RT_BUILD=OFF
+ -DLLVM_EXTERNAL_CLANG_TOOLS_EXTRA_BUILD=OFF
+ )
+ fi
+ if use lldb; then
+ mycmakeargs+=(
+ # only run swig on native abi
+ -DLLDB_DISABLE_PYTHON=ON
+ )
+ fi
+ fi
+
+ if use clang; then
+ mycmakeargs+=(
+ -DCLANG_ENABLE_ARCMT=$(usex static-analyzer)
+ -DCLANG_ENABLE_STATIC_ANALYZER=$(usex static-analyzer)
+ -DCLANG_LIBDIR_SUFFIX="${NATIVE_LIBDIR#lib}"
+ )
+
+ # -- not needed when compiler-rt is built with host compiler --
+ # cmake passes host C*FLAGS to compiler-rt build
+ # which is performed using clang, so we need to filter out
+ # some flags clang does not support
+ # (if you know some more flags that don't work, let us know)
+ #filter-flags -msahf -frecord-gcc-switches
+ fi
+
+ if tc-is-cross-compiler; then
+ [[ -x "/usr/bin/llvm-tblgen" ]] \
+ || die "/usr/bin/llvm-tblgen not found or usable"
+ mycmakeargs+=(
+ -DCMAKE_CROSSCOMPILING=ON
+ -DLLVM_TABLEGEN=/usr/bin/llvm-tblgen
+ )
+
+ if use clang; then
+ [[ -x "/usr/bin/clang-tblgen" ]] \
+ || die "/usr/bin/clang-tblgen not found or usable"
+ mycmakeargs+=(
+ -DCLANG_TABLEGEN=/usr/bin/clang-tblgen
+ )
+ fi
+ fi
+
+ cmake-utils_src_configure
+}
+
+multilib_src_compile() {
+ cmake-utils_src_compile
+ # TODO: not sure why this target is not correctly called
+ multilib_is_native_abi && use doc && use ocaml && cmake-utils_src_make docs/ocaml_doc
+
+ pax-mark m "${BUILD_DIR}"/bin/llvm-rtdyld
+ pax-mark m "${BUILD_DIR}"/bin/lli
+ pax-mark m "${BUILD_DIR}"/bin/lli-child-target
+
+ if use test; then
+ pax-mark m "${BUILD_DIR}"/unittests/ExecutionEngine/Orc/OrcJITTests
+ pax-mark m "${BUILD_DIR}"/unittests/ExecutionEngine/MCJIT/MCJITTests
+ pax-mark m "${BUILD_DIR}"/unittests/Support/SupportTests
+ fi
+
+ # provide a symlink for tests
+ if [[ $(get_libdir) != lib ]]; then
+ ln -s "../$(get_libdir)/clang" lib/clang || die
+ fi
+}
+
+multilib_src_test() {
+ # respect TMPDIR!
+ local -x LIT_PRESERVES_TMP=1
+ local test_targets=( check )
+ # clang tests won't work on non-native ABI because we skip compiler-rt
+ multilib_is_native_abi && use clang && test_targets+=( check-clang )
+ cmake-utils_src_make "${test_targets[@]}"
+}
+
+src_install() {
+ local MULTILIB_CHOST_TOOLS=(
+ /usr/bin/llvm-config
+ )
+
+ local MULTILIB_WRAPPED_HEADERS=(
+ /usr/include/llvm/Config/config.h
+ /usr/include/llvm/Config/llvm-config.h
+ )
+
+ if use clang; then
+ MULTILIB_WRAPPED_HEADERS+=(
+ /usr/include/clang/Config/config.h
+ )
+ fi
+
+ multilib-minimal_src_install
+
+ if use clang; then
+ # Apply CHOST and version suffix to clang tools
+ local clang_version=${PV%.*}
+ local clang_tools=( clang clang++ clang-cl clang-cpp )
+ local abi i
+
+ # cmake gives us:
+ # - clang-X.Y
+ # - clang -> clang-X.Y
+ # - clang++, clang-cl, clang-cpp -> clang
+ # we want to have:
+ # - clang-X.Y
+ # - clang++-X.Y, clang-cl-X.Y, clang-cpp-X.Y -> clang-X.Y
+ # - clang, clang++, clang-cl, clang-cpp -> clang*-X.Y
+ # also in CHOST variant
+ for i in "${clang_tools[@]:1}"; do
+ rm -f "${ED%/}/usr/bin/${i}" || die
+ dosym "clang-${clang_version}" "/usr/bin/${i}-${clang_version}"
+ dosym "${i}-${clang_version}" "/usr/bin/${i}"
+ done
+
+ # now create target symlinks for all supported ABIs
+ for abi in $(get_all_abis); do
+ local abi_chost=$(get_abi_CHOST "${abi}")
+ for i in "${clang_tools[@]}"; do
+ dosym "${i}-${clang_version}" \
+ "/usr/bin/${abi_chost}-${i}-${clang_version}"
+ dosym "${abi_chost}-${i}-${clang_version}" \
+ "/usr/bin/${abi_chost}-${i}"
+ done
+ done
+ fi
+
+ # Remove unnecessary headers on FreeBSD, bug #417171
+ if use kernel_FreeBSD && use clang; then
+ rm "${ED}"usr/lib/clang/${PV}/include/{std,float,iso,limits,tgmath,varargs}*.h || die
+ fi
+}
+
+multilib_src_install() {
+ cmake-utils_src_install
+
+ if multilib_is_native_abi; then
+ # Symlink the gold plugin.
+ if use gold; then
+ dodir "/usr/${CHOST}/binutils-bin/lib/bfd-plugins"
+ dosym "../../../../$(get_libdir)/LLVMgold.so" \
+ "/usr/${CHOST}/binutils-bin/lib/bfd-plugins/LLVMgold.so"
+ fi
+ fi
+}
+
+multilib_src_install_all() {
+ insinto /usr/share/vim/vimfiles
+ doins -r utils/vim/*/.
+ # some users may find it useful
+ dodoc utils/vim/vimrc
+
+ # Install man pages from the prebuilt package
+ if ! use doc; then
+ if ! use clang; then
+ rm "${WORKDIR}"/${PN}-3.9.0_rc3-manpages/{clang,extraclangtools,scan-build}.1 || die
+ fi
+
+ doman "${WORKDIR}"/${PN}-3.9.0_rc3-manpages/*.1
+ fi
+
+ if use clang; then
+ pushd tools/clang >/dev/null || die
+
+ if use python ; then
+ pushd bindings/python/clang >/dev/null || die
+
+ python_moduleinto clang
+ python_domodule *.py
+
+ popd >/dev/null || die
+ fi
+
+ # AddressSanitizer symbolizer (currently separate)
+ dobin "${S}"/projects/compiler-rt/lib/asan/scripts/asan_symbolize.py
+
+ popd >/dev/null || die
+
+ python_fix_shebang "${ED}"
+ if use static-analyzer; then
+ python_optimize "${ED}"usr/share/scan-view
+ fi
+ fi
+}