summaryrefslogtreecommitdiff
path: root/sys-devel/llvm
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2017-12-03 16:17:22 +0000
committerV3n3RiX <venerix@redcorelinux.org>2017-12-03 16:17:22 +0000
commit4cd2370bed609c118b6edfde5d3f116e5c35b897 (patch)
treeec58f2c41f49754e41521d5ebc9dce4597ddd0a5 /sys-devel/llvm
parentf443475c824b4b5c086e6d040961cb35ad81bc60 (diff)
gentoo resync : 03.12.2017
Diffstat (limited to 'sys-devel/llvm')
-rw-r--r--sys-devel/llvm/Manifest8
-rw-r--r--sys-devel/llvm/files/4.0.1/0001-cmake-Pass-Wl-z-nodelete-on-Linux-to-prevent-unloadi.patch56
-rw-r--r--sys-devel/llvm/files/5.0.1/0001-cmake-Pass-Wl-z-nodelete-on-Linux-to-prevent-unloadi.patch71
-rw-r--r--sys-devel/llvm/llvm-4.0.1-r1.ebuild (renamed from sys-devel/llvm/llvm-4.0.1.ebuild)4
-rw-r--r--sys-devel/llvm/llvm-5.0.1_rc2.ebuild236
-rw-r--r--sys-devel/llvm/llvm-5.0.9999.ebuild4
6 files changed, 377 insertions, 2 deletions
diff --git a/sys-devel/llvm/Manifest b/sys-devel/llvm/Manifest
index 17594eb4f580..f89417208f5b 100644
--- a/sys-devel/llvm/Manifest
+++ b/sys-devel/llvm/Manifest
@@ -1,3 +1,5 @@
+AUX 4.0.1/0001-cmake-Pass-Wl-z-nodelete-on-Linux-to-prevent-unloadi.patch 2408 BLAKE2B 92f396663629d0f1bc65833d4050f8e28044c25dec961981edac768b374c543d9084eb70ac51435554acfc5430c45035e4acae6e02f453bc679a3458979b53f3 SHA512 0424f35f12054a7e3e20d948c714979cfcf01200e8aac1cfab1b9fdd08718b4f4143a635eca9500e7ac77993ff390358cb630b8d97029cd9ec1e14c9cfaedfd2
+AUX 5.0.1/0001-cmake-Pass-Wl-z-nodelete-on-Linux-to-prevent-unloadi.patch 3055 BLAKE2B 4087d3b68bfb2023ef0dc43aaa696ed12b02c776e702e1aaa6a32b6c44f9194df7e8bb78068f03cd23165ba5ad8f9b2451a228a9b77c0b2c08757fc660eb2e00 SHA512 2493369dfc8bee58c8f92215aba9b91fb718562f9fa040c1132269e538040e9baa3c0a50e888033c3805a1aa7ce40443c6e7ff52ecc791b8c86140cd34b3f751
AUX 9999/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch 2626 BLAKE2B 6c3afe6941568119b6bbce1c66be913a29a2ac7853a881804c1c22e981075f1677ca7e4744738ad858f58a58c1a7295aeb5f1d87b3a2b2adfb971a54d76c04fb SHA512 34a84427c34fa8886f55e05cf0ffce258cdee8e98190e070eb40dc555a30784c49ebe4f946f7ea51b7d00fceb8071fc745007250dc5b5a61c4d2bb9910672ec5
AUX 9999/musl-fixes.patch 1258 BLAKE2B fe275412bc908884239ea71de9a9ddf1d2f64debaa1a9ada18170195a7775c41571600ed3666343bf967aff5f9117900f73155f60de5077bc4584cfc2f782f53 SHA512 314dcbe846a66312c9f1634f4ff3f4670b3db1d3210bb550f1d3877a423333ba042da2e90c8736918a36be4d4faf58dab8d3236d4f26df5af7f7f019b0e0ec8f
DIST cfe-3.4.2.src.tar.gz 10612313 SHA256 5ba6f5772f8d00f445209356a7daf83c5bca2da5acd10de517ad2359ae95bc10 SHA512 e01fa8e312e9b3b7b3cb572ac21349161aaa50078ecfe7bded273b75db4a0c44acde524f8fdfcbeec54c61eeeb8339e9917d1f205a8fda18e34fe7ccbe89c36d WHIRLPOOL 153208b1a60bb5fbe92a7162cb26bbe70d591e7db9dcf06fcd54efc539bbff0403ec88e64236969c9f256e5586bc333840bd6178fd158577d6fe228d9edd4dcd
@@ -31,6 +33,7 @@ DIST llvm-3.9.1-patchset.tar.xz 16404 SHA256 a4b3e5887b53af47984ea39ff8640f11e8a
DIST llvm-3.9.1.src.tar.xz 18130436 SHA256 1fd90354b9cf19232e8f168faf2220e79be555df3aa743242700879e8fd329ee SHA512 50cbe8ee911080f586e77861c442348701bd02e2de0c090c54c34f82ac275ecfcd712af0f41e387c33b4a6057778a4258a27554292fe68ab4af3fd9dd6d90683 WHIRLPOOL 1cd1a25befcb178bec4a4aace4367167f3838d32edbe9db9de8c6e558c01c1fcf123f6d6f80b7ec9ff32b3d6dcf2de2f4eb4201d417c3d17a5c8a69934832903
DIST llvm-4.0.1.src.tar.xz 21065652 BLAKE2B 6327eed2d1feb108440f22d2581d1ff86c10a10c29793538d8d899c7e2dc83d3f7b147d3fd4bcce2bd2bf57c071b08c624aeafe40a3e7a3914506e7751727e6c SHA512 16adc39b34ddb628f81b171119a8e2a0e9138b25011e803ef0b688e2fbea116fc4953d3a1b61b90a98a75e33619f81566b7cb06a9a2ea4d04ac5e0eb303a2d1d
DIST llvm-5.0.0.src.tar.xz 23411980 BLAKE2B bc3d8b75b766c83912252b51d6b57c8151c9d83415eff7bc771923d35138ed253a788d6c8e0a384c5e78ce1a1065f10d66ef5004df163b4c3b0c6274bb3aa6b7 SHA512 e6d8fdcb5bf27bded814d02f39f69c6171bc3a512d5957c03e5ac2e231f903b7de87634b059bd5c5da670f7c3a8f7a538f6299225799f15f921857f1452f6b3a
+DIST llvm-5.0.1rc2.src.tar.xz 23508164 BLAKE2B 3594d1658310a99787b4ff6f85aa8dd12a0405464bcb095ba4f205ce5b4ed3240a8ae1bef726ff98aba61ae5c8f8c10eeb8e415320d210af60f9e74bff7a8d5c SHA512 0a156e3949d22304b5e173dc9a3628161dff2798ad67924341c11494544350ef3a35a3ebb6ec8e7223b2407ce47cf12dafa6de8c006c5799a620e35a86c30b1b
DIST llvm-manpages-4.0.1.tar.bz2 87981 SHA256 28fa1dcd4774156247ba253d2d79c81796ef0f0763b4f37c9c5ae27af93f4320 SHA512 d5b3213567c25db58ef364d272314a79c311a80fc21d98c09a5540af45a8190a38f489228663fe9a9b63bf0f2b952c460c4196a8fc8d6f221619f6e7ed2fc415 WHIRLPOOL da897ea8d3713a5c4c10a6320f0e7dd13e0125e942e3444b0e8a2a062b83a8e86e3754be025b89ae00f63f557ec0518ab62d8cd21237962e93c708ca72c8e3f5
DIST llvm-manpages-5.0.0.tar.bz2 94240 SHA256 5082c316cf09e6c15d76f0b184745bf3392d3fd42a56cf0a5119b45918a67cb9 SHA512 0bccfb00caa0796bed8ea4e591616e025e43d304f05589180820c17f8567fa3a1f1f76c323098ed0d0e4590765415b1c1c272a94c6e2e7544788f4088ef0ffea WHIRLPOOL 410fe9eda01519c7ded00b2ca61dd323bafb3418a0a81fdc5c3b60d64ee80b75a6372ea29eb66a1b1ce6bb020c011cff7d9e896469dd6f9534fc19fb5b5a4696
EBUILD llvm-3.4.2-r100.ebuild 7025 BLAKE2B b494ca2548a0d759e0eb3eac8c609406010da506e707ba98fed7e53858612d51ffbc87344c240b77eb82b2bb67bd5b8f4a4dd99d2925065a6b3293839297188a SHA512 9829abe6dbd09d786236ed4b05edbdbdd96c82af22dee5e4d4eb33fa28c80102024eeed057bc15140cf4bb646e84e8ed86e152a10df99b59f9ce84790af53593
@@ -38,8 +41,9 @@ EBUILD llvm-3.5.2-r100.ebuild 7837 BLAKE2B 224f7bf982e0f65a512a873e6eca951d05d4e
EBUILD llvm-3.6.2-r100.ebuild 7982 BLAKE2B fd247bb8877a421ec4f00ed499cddaa982ab7662cc31ef145bbc6e49c177df32f2d3e55090b4d63b12d8a83103b17cf9179edb0504df22e88a8861ea5124e80e SHA512 4a1673e289d67385d2971f367251e1e301e30be59d8931f2c73ed9ce6708fee0c993a11a243f134101f5e2fffb662cad09173791ad80a11e052c073ee6f48419
EBUILD llvm-3.7.1-r3.ebuild 16958 BLAKE2B fd7a7890b0041c216fe4b21937a578b2a00da2f25baf648ad4847becdd49757c551f9fe9708c4c1757ab9991ca2468133746816372f26116c98788da5d059df6 SHA512 5e1824bb8e24faa592cdade50282c96a77bdc8574c0afee3984ab536d6a1c575babcc458c22acdc526c50838d20ce7fe7c4dff3d4cd7fcb2bcb11b2e7a2a3033
EBUILD llvm-3.9.1-r1.ebuild 16507 BLAKE2B 83692ac24d5df082c1eab87ef85353a44a485332fa5720414a5965d379939e82aa6bfccb2fb513bc8c18872184d4ef99a02dc4766dad5bd555f887b2a9122589 SHA512 1234349f89c1d2b07e1918075b52f2866e56cc742d3f3da233dd8465c559c765c7cb256f1d6eb77ee61fede9be2c84bd6236c42e5672d5130f0e7730ee24de96
-EBUILD llvm-4.0.1.ebuild 6570 BLAKE2B 9380f2906640c861c8314532cf9b879c645bb44b24196bfc1edf72e67a5887f165e35bd0c03e4a950da373ca172b3fb433fac5825bebcb2c7bc1753798be0a54 SHA512 0a37cd4437977fb0c6721f83d4527409aaad93c3639bed99d891ac7406f12f2cff506bd8500db3017a01d8bb6e3ba9419f678061e62f36689a6d79932071238e
+EBUILD llvm-4.0.1-r1.ebuild 6763 BLAKE2B b9f44823d48af23ffc19a66c14a20f21155a431c5fe406d838ceda9c1b178758803a67f10fe9f21e06e845a5bf168b4337f22cc8aa7e31ac471173b388f8afd9 SHA512 848cfe5724015e60abb955e5d9e50cb9f9d672005746dbd5ed4bebcd3b256f90f39b35ff36229b902ed0571bfde626afe9e0fefd26212fc1613fd00416b8b5b2
EBUILD llvm-5.0.0.ebuild 6803 BLAKE2B 0f8c567f7a18a6b8ba6cf122e51d1ac7e1a3ca31b6ed6558118642f5293fb1541323ffb02dea6f52bc80f9e3f934e1f92e886cee75ae6369530ff24118828d9a SHA512 0dd78bdc302f0c5132f66d36dce91f0562a2c0284e5b7bc6e3cdebc6c632378ecf7ea23ee348b39b8bcdc074c502a2824094c4b9ac754e379c7a51e3c14623ee
-EBUILD llvm-5.0.9999.ebuild 6448 BLAKE2B cc3973b43db453e5053faf02f89ca9acf8f4d02290e41ab566ba840ea2e2732da0c50c73c1e2e071a880f41e51ac96045c728faa0179fe7a11b3a5448430ac81 SHA512 b936ee8e3d3609f982341ad326d484264763520685a47a7faccc01f2f82042d4b77d864c9de1bcc3e3377e5482e5fdeeddffd6b290726b8d822d1ae2caf2eb5e
+EBUILD llvm-5.0.1_rc2.ebuild 6882 BLAKE2B 9d1238233e5459bb885229a1e7d4ba4a9ba1ab3d4149774cebee74abf0ae82764096f0472b8e3b71e1087c898a361129f61eefd6d68794036709e22d1be49867 SHA512 b2810405de24c4b9ffb0b02291351a00f75b756a3f96e7d1818efffa0bfed63d9af81f96717db215469ce461b6b5ccc8fe73352a2582171c0dbe9693b290293b
+EBUILD llvm-5.0.9999.ebuild 6641 BLAKE2B 1c7e375af64e7999b7429dd2fe3e4d108b034f6f46f8821069367e16eb509d07f2916ccb7cd87cd24cce93ac61ac9e3d7a1f2dfe67c91e94b82310e37a8b200c SHA512 42703947cf1258a238ade131b5a6b6fcb2490c619c1be6e5901ab1ccf846c4778e33675be8fe10265c04e02c39bc183ae3eb42a92a3278fb9dd4a7574d21f125
EBUILD llvm-9999.ebuild 6636 BLAKE2B ddcdf06967b51c76f0744cd8007013fd01b7948317090c743f2799db60e384a4b0483f24dc9fa8a20d34ff9ae6fe70b8e823efa07924af044d8161e41d561342 SHA512 161358697a161cb4f6bacd0511d9ecf6bcc89d3d4d58ba215c49225f8471d35f2bc8f1ad552e7f41b65497cbb52699cfeee8fc5a05d365c8eccf34a080b15938
MISC metadata.xml 2747 BLAKE2B 0684b3ae235b762c8c365ac0da29d285781cb7aae25250664704385c3326c07097a6061907b1bc2417b90db39745745bfbbab887d53a7fa1024e62bcded2d0be SHA512 cbb82ddab3a19f9103ed1f72bdae2b50dd3bd906b377ff6004dc7b85e9ec8852fd9d03f7f9e7015363454b86680ec5fdb756b08bc6a7c2743669ee4ff3b4aa08
diff --git a/sys-devel/llvm/files/4.0.1/0001-cmake-Pass-Wl-z-nodelete-on-Linux-to-prevent-unloadi.patch b/sys-devel/llvm/files/4.0.1/0001-cmake-Pass-Wl-z-nodelete-on-Linux-to-prevent-unloadi.patch
new file mode 100644
index 000000000000..b857136498b0
--- /dev/null
+++ b/sys-devel/llvm/files/4.0.1/0001-cmake-Pass-Wl-z-nodelete-on-Linux-to-prevent-unloadi.patch
@@ -0,0 +1,56 @@
+From 937b23b5fffa59deb1dc342cc5602d387d84a762 Mon Sep 17 00:00:00 2001
+From: Michal Gorny <mgorny@gentoo.org>
+Date: Mon, 27 Nov 2017 22:23:09 +0000
+Subject: [PATCH] [cmake] Pass -Wl,-z,nodelete on Linux to prevent unloading
+
+Prevent unloading shared libraries on Linux when dlclose() is called.
+This is necessary since command-line option parsing API relies on
+registering the global option instances in the option parser instance
+which can be loaded in a different shared library.
+
+Given that we can't reliably remove those options when a library is
+unloaded, the parser ends up containing dangling references. Since glibc
+has relatively complex library unloading rules, some of the LLVM
+libraries can be unloaded while others (including the Support library)
+stay loaded causing quite a mayhem. To reliably prevent that, just
+forbid unloading all libraries -- it's a very bad idea anyway.
+
+While the issue arguably happens only with BUILD_SHARED_LIBS, it may
+affect any library reusing llvm::cl interface.
+
+Based on patch provided Ross Hayward on https://bugs.gentoo.org/617154.
+Previously hit by Fedora back in Feb 2016:
+https://lists.freedesktop.org/archives/mesa-dev/2016-February/107242.html
+
+Differential Revision: https://reviews.llvm.org/D40459
+
+git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319105 91177308-0d34-0410-b5e6-96231b3b80d8
+---
+ cmake/modules/HandleLLVMOptions.cmake | 8 ++++++++
+ unittests/Support/DynamicLibrary/CMakeLists.txt | 7 +++++++
+ 2 files changed, 15 insertions(+)
+
+ 4.0.1 backport: removed the unittest part
+
+diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake
+index c5390371845..b5059a8a60e 100644
+--- a/cmake/modules/HandleLLVMOptions.cmake
++++ b/cmake/modules/HandleLLVMOptions.cmake
+@@ -151,6 +151,14 @@ if(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" OR WIN32 OR CYGWIN OR
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,defs")
+ endif()
+
++# Pass -Wl,-z,nodelete. This makes sure our shared libraries are not unloaded
++# by dlclose(). We need that since the CLI API relies on cross-references
++# between global objects which became horribly broken when one of the libraries
++# is unloaded.
++if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
++ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,nodelete")
++endif()
++
+
+ function(append value)
+ foreach(variable ${ARGN})
+--
+2.15.1
+
diff --git a/sys-devel/llvm/files/5.0.1/0001-cmake-Pass-Wl-z-nodelete-on-Linux-to-prevent-unloadi.patch b/sys-devel/llvm/files/5.0.1/0001-cmake-Pass-Wl-z-nodelete-on-Linux-to-prevent-unloadi.patch
new file mode 100644
index 000000000000..21702748893c
--- /dev/null
+++ b/sys-devel/llvm/files/5.0.1/0001-cmake-Pass-Wl-z-nodelete-on-Linux-to-prevent-unloadi.patch
@@ -0,0 +1,71 @@
+From 937b23b5fffa59deb1dc342cc5602d387d84a762 Mon Sep 17 00:00:00 2001
+From: Michal Gorny <mgorny@gentoo.org>
+Date: Mon, 27 Nov 2017 22:23:09 +0000
+Subject: [PATCH] [cmake] Pass -Wl,-z,nodelete on Linux to prevent unloading
+
+Prevent unloading shared libraries on Linux when dlclose() is called.
+This is necessary since command-line option parsing API relies on
+registering the global option instances in the option parser instance
+which can be loaded in a different shared library.
+
+Given that we can't reliably remove those options when a library is
+unloaded, the parser ends up containing dangling references. Since glibc
+has relatively complex library unloading rules, some of the LLVM
+libraries can be unloaded while others (including the Support library)
+stay loaded causing quite a mayhem. To reliably prevent that, just
+forbid unloading all libraries -- it's a very bad idea anyway.
+
+While the issue arguably happens only with BUILD_SHARED_LIBS, it may
+affect any library reusing llvm::cl interface.
+
+Based on patch provided Ross Hayward on https://bugs.gentoo.org/617154.
+Previously hit by Fedora back in Feb 2016:
+https://lists.freedesktop.org/archives/mesa-dev/2016-February/107242.html
+
+Differential Revision: https://reviews.llvm.org/D40459
+
+git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319105 91177308-0d34-0410-b5e6-96231b3b80d8
+---
+ cmake/modules/HandleLLVMOptions.cmake | 8 ++++++++
+ unittests/Support/DynamicLibrary/CMakeLists.txt | 7 +++++++
+ 2 files changed, 15 insertions(+)
+
+diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake
+index c5390371845..b5059a8a60e 100644
+--- a/cmake/modules/HandleLLVMOptions.cmake
++++ b/cmake/modules/HandleLLVMOptions.cmake
+@@ -151,6 +151,14 @@ if(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" OR WIN32 OR CYGWIN OR
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,defs")
+ endif()
+
++# Pass -Wl,-z,nodelete. This makes sure our shared libraries are not unloaded
++# by dlclose(). We need that since the CLI API relies on cross-references
++# between global objects which became horribly broken when one of the libraries
++# is unloaded.
++if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
++ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,nodelete")
++endif()
++
+
+ function(append value)
+ foreach(variable ${ARGN})
+diff --git a/unittests/Support/DynamicLibrary/CMakeLists.txt b/unittests/Support/DynamicLibrary/CMakeLists.txt
+index 9355979221a..c6201b1ad31 100644
+--- a/unittests/Support/DynamicLibrary/CMakeLists.txt
++++ b/unittests/Support/DynamicLibrary/CMakeLists.txt
+@@ -24,5 +24,12 @@ function(dynlib_add_module NAME)
+ add_dependencies(DynamicLibraryTests ${NAME})
+ endfunction(dynlib_add_module)
+
++# Revert -Wl,-z,nodelete on this test since it relies on the file
++# being unloaded.
++if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
++ string(REPLACE "-Wl,-z,nodelete" "" CMAKE_SHARED_LINKER_FLAGS
++ ${CMAKE_SHARED_LINKER_FLAGS})
++endif()
++
+ dynlib_add_module(PipSqueak)
+ dynlib_add_module(SecondLib)
+--
+2.15.1
+
diff --git a/sys-devel/llvm/llvm-4.0.1.ebuild b/sys-devel/llvm/llvm-4.0.1-r1.ebuild
index 6ee123541ac5..1931365e8a7e 100644
--- a/sys-devel/llvm/llvm-4.0.1.ebuild
+++ b/sys-devel/llvm/llvm-4.0.1-r1.ebuild
@@ -75,6 +75,10 @@ src_prepare() {
# https://bugs.gentoo.org/show_bug.cgi?id=565358
eapply "${FILESDIR}"/9999/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch
+ # Backport the fix for dlclose() causing option parser mess
+ # e.g. https://bugs.gentoo.org/617154
+ eapply "${FILESDIR}"/4.0.1/0001-cmake-Pass-Wl-z-nodelete-on-Linux-to-prevent-unloadi.patch
+
# support building llvm against musl-libc
use elibc_musl && eapply "${FILESDIR}"/9999/musl-fixes.patch
diff --git a/sys-devel/llvm/llvm-5.0.1_rc2.ebuild b/sys-devel/llvm/llvm-5.0.1_rc2.ebuild
new file mode 100644
index 000000000000..42978ec5cce1
--- /dev/null
+++ b/sys-devel/llvm/llvm-5.0.1_rc2.ebuild
@@ -0,0 +1,236 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+: ${CMAKE_MAKEFILE_GENERATOR:=ninja}
+# (needed due to CMAKE_BUILD_TYPE != Gentoo)
+CMAKE_MIN_VERSION=3.7.0-r1
+PYTHON_COMPAT=( python2_7 )
+
+inherit cmake-utils eapi7-ver flag-o-matic multilib-minimal \
+ pax-utils python-any-r1 toolchain-funcs
+
+DESCRIPTION="Low Level Virtual Machine"
+HOMEPAGE="https://llvm.org/"
+SRC_URI="http://prereleases.llvm.org/${PV/_//}/${P/_/}.src.tar.xz"
+# !doc? ( https://dev.gentoo.org/~mgorny/dist/llvm/llvm-manpages-${PV}.tar.bz2 )"
+
+# Keep in sync with CMakeLists.txt
+ALL_LLVM_TARGETS=( AArch64 AMDGPU ARM BPF Hexagon Lanai 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="$(ver_cut 1)"
+KEYWORDS=""
+IUSE="debug +doc gold libedit +libffi ncurses test
+ kernel_Darwin ${ALL_LLVM_TARGETS[*]}"
+
+RDEPEND="
+ sys-libs/zlib:0=
+ gold? ( >=sys-devel/binutils-2.22:*[cxx] )
+ libedit? ( dev-libs/libedit:0=[${MULTILIB_USEDEP}] )
+ libffi? ( >=virtual/libffi-3.0.13-r1:0=[${MULTILIB_USEDEP}] )
+ ncurses? ( >=sys-libs/ncurses-5.9-r3:0=[${MULTILIB_USEDEP}] )"
+# configparser-3.2 breaks the build (3.3 or none at all are fine)
+DEPEND="${RDEPEND}
+ dev-lang/perl
+ || ( >=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-$(ver_cut 1-3).9999 )
+ doc? ( dev-python/sphinx )
+ gold? ( sys-libs/binutils-libs )
+ libffi? ( virtual/pkgconfig )
+ !!<dev-python/configparser-3.3.0.2
+ ${PYTHON_DEPS}"
+# There are no file collisions between these versions but having :0
+# installed means llvm-config there will take precedence.
+RDEPEND="${RDEPEND}
+ !sys-devel/llvm:0"
+PDEPEND="sys-devel/llvm-common
+ gold? ( sys-devel/llvmgold )"
+
+REQUIRED_USE="${PYTHON_REQUIRED_USE}
+ || ( ${ALL_LLVM_TARGETS[*]} )"
+
+S=${WORKDIR}/${P/_/}.src
+
+# least intrusive of all
+CMAKE_BUILD_TYPE=RelWithDebInfo
+
+src_prepare() {
+ # Fix llvm-config for shared linking and sane flags
+ # https://bugs.gentoo.org/show_bug.cgi?id=565358
+ eapply "${FILESDIR}"/9999/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch
+
+ # Backport the fix for dlclose() causing option parser mess
+ # e.g. https://bugs.gentoo.org/617154
+ eapply "${FILESDIR}"/5.0.1/0001-cmake-Pass-Wl-z-nodelete-on-Linux-to-prevent-unloadi.patch
+
+ # disable use of SDK on OSX, bug #568758
+ sed -i -e 's/xcrun/false/' utils/lit/lit/util.py || die
+
+ # User patches + QA
+ cmake-utils_src_prepare
+}
+
+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=(
+ # disable appending VCS revision to the version to improve
+ # direct cache hit ratio
+ -DLLVM_APPEND_VC_REV=OFF
+ -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr/lib/llvm/${SLOT}"
+ -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_LIBEDIT=$(usex libedit)
+ -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}"
+
+ # disable OCaml bindings (now in dev-ml/llvm-ocaml)
+ -DOCAMLFIND=NO
+ )
+
+# 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_OCAMLDOC=OFF
+ -DLLVM_ENABLE_SPHINX=$(usex doc)
+ -DLLVM_ENABLE_DOXYGEN=OFF
+ -DLLVM_INSTALL_UTILS=ON
+ )
+ use doc && mycmakeargs+=(
+ -DLLVM_INSTALL_SPHINX_HTML_DIR="${EPREFIX}/usr/share/doc/${PF}/html"
+ -DSPHINX_WARNINGS_AS_ERRORS=OFF
+ )
+ use gold && mycmakeargs+=(
+ -DLLVM_BINUTILS_INCDIR="${EPREFIX}"/usr/include
+ )
+ fi
+
+ if tc-is-cross-compiler; then
+ local tblgen="${EPREFIX}/usr/lib/llvm/${SLOT}/bin/llvm-tblgen"
+ [[ -x "${tblgen}" ]] \
+ || die "${tblgen} not found or usable"
+ mycmakeargs+=(
+ -DCMAKE_CROSSCOMPILING=ON
+ -DLLVM_TABLEGEN="${tblgen}"
+ )
+ fi
+
+ # LLVM_ENABLE_ASSERTIONS=NO does not guarantee this for us, #614844
+ use debug || local -x CPPFLAGS="${CPPFLAGS} -DNDEBUG"
+ cmake-utils_src_configure
+}
+
+multilib_src_compile() {
+ cmake-utils_src_compile
+
+ 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
+}
+
+multilib_src_test() {
+ # respect TMPDIR!
+ local -x LIT_PRESERVES_TMP=1
+ cmake-utils_src_make check
+}
+
+src_install() {
+ local MULTILIB_CHOST_TOOLS=(
+ /usr/lib/llvm/${SLOT}/bin/llvm-config
+ )
+
+ local MULTILIB_WRAPPED_HEADERS=(
+ /usr/include/llvm/Config/llvm-config.h
+ )
+
+ local LLVM_LDPATHS=()
+ multilib-minimal_src_install
+
+ # move wrapped headers back
+ mv "${ED%/}"/usr/include "${ED%/}"/usr/lib/llvm/${SLOT}/include || die
+}
+
+multilib_src_install() {
+ cmake-utils_src_install
+
+ # move headers to /usr/include for wrapping
+ rm -rf "${ED%/}"/usr/include || die
+ mv "${ED%/}"/usr/lib/llvm/${SLOT}/include "${ED%/}"/usr/include || die
+
+ # install fuzzer libraries for clang (cmake rules were added in 6)
+ # https://bugs.gentoo.org/636840
+ into "/usr/lib/llvm/${SLOT}"
+ dolib.a "$(get_libdir)"/libLLVMFuzzer*.a
+
+ LLVM_LDPATHS+=( "${EPREFIX}/usr/lib/llvm/${SLOT}/$(get_libdir)" )
+}
+
+multilib_src_install_all() {
+ local revord=$(( 9999 - ${SLOT} ))
+ cat <<-_EOF_ > "${T}/10llvm-${revord}" || die
+ PATH="${EPREFIX}/usr/lib/llvm/${SLOT}/bin"
+ # we need to duplicate it in ROOTPATH for Portage to respect...
+ ROOTPATH="${EPREFIX}/usr/lib/llvm/${SLOT}/bin"
+ MANPATH="${EPREFIX}/usr/lib/llvm/${SLOT}/share/man"
+ LDPATH="$( IFS=:; echo "${LLVM_LDPATHS[*]}" )"
+_EOF_
+ doenvd "${T}/10llvm-${revord}"
+
+ # install pre-generated manpages
+ if ! use doc; then
+ # (doman does not support custom paths)
+ insinto "/usr/lib/llvm/${SLOT}/share/man/man1"
+ doins "${WORKDIR}/llvm-manpages-${PV}/llvm"/*.1
+ fi
+
+ docompress "/usr/lib/llvm/${SLOT}/share/man"
+}
diff --git a/sys-devel/llvm/llvm-5.0.9999.ebuild b/sys-devel/llvm/llvm-5.0.9999.ebuild
index 3bf676e43609..2c8a9d8ecf07 100644
--- a/sys-devel/llvm/llvm-5.0.9999.ebuild
+++ b/sys-devel/llvm/llvm-5.0.9999.ebuild
@@ -75,6 +75,10 @@ src_prepare() {
# https://bugs.gentoo.org/show_bug.cgi?id=565358
eapply "${FILESDIR}"/9999/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch
+ # Backport the fix for dlclose() causing option parser mess
+ # e.g. https://bugs.gentoo.org/617154
+ eapply "${FILESDIR}"/5.0.1/0001-cmake-Pass-Wl-z-nodelete-on-Linux-to-prevent-unloadi.patch
+
# disable use of SDK on OSX, bug #568758
sed -i -e 's/xcrun/false/' utils/lit/lit/util.py || die