1 |
commit: e98887feeae412d2eb590c7e875fc681a8506ab4 |
2 |
Author: Milkey Mouse <milkeymouse <AT> meme <DOT> institute> |
3 |
AuthorDate: Sat Apr 28 23:06:43 2018 +0000 |
4 |
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Apr 29 14:53:06 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/musl.git/commit/?id=e98887fe |
7 |
|
8 |
sys-devel/clang: add new package |
9 |
|
10 |
Add clang with some musl fixes & hardened patches for a hardened/musl/clang |
11 |
profile (hardened USE flag not upstreamed to main ebuild repository yet). |
12 |
|
13 |
Package-Manager: Portage-2.3.31, Repoman-2.3.9 |
14 |
Manifest-Sign-Key: C6EF5A02F5647987 |
15 |
|
16 |
sys-devel/clang/Manifest | 31 ++ |
17 |
sys-devel/clang/clang-4.0.1.ebuild | 309 +++++++++++++++++++ |
18 |
sys-devel/clang/clang-5.0.1.ebuild | 333 ++++++++++++++++++++ |
19 |
sys-devel/clang/clang-6.0.0-r1.ebuild | 337 +++++++++++++++++++++ |
20 |
...rrect-values-of-ATOMIC_-_LOCK_FREE-to-mat.patch | 87 ++++++ |
21 |
...port-stand-alone-Sphinx-doxygen-doc-build.patch | 64 ++++ |
22 |
.../files/4.0.1/0003-Add-Gentoo-Linux-distro.patch | 32 ++ |
23 |
...st-dependencies-when-using-installed-tool.patch | 48 +++ |
24 |
...ang-library-dir-in-LD_LIBRARY_PATH-For-st.patch | 83 +++++ |
25 |
.../hardened/0001-Use-z-relro-on-Gentoo.patch | 11 + |
26 |
.../0002-Enable-Stack-Protector-by-default.patch | 23 ++ |
27 |
.../hardened/0003-Enable-PIE-by-default.patch | 26 ++ |
28 |
...004-Link-with-z-now-by-default-for-Gentoo.patch | 14 + |
29 |
...arch-type-to-find-compiler-rt-libraries-o.patch | 136 +++++++++ |
30 |
...est-Fix-clang-test-for-FreeBSD-and-NetBSD.patch | 76 +++++ |
31 |
.../files/5.0.1/0003-Add-Gentoo-Linux-distro.patch | 33 ++ |
32 |
.../files/5.0.1/darwin_prefix-include-paths.patch | 18 ++ |
33 |
...shared-library-path-variable-is-LD_LIBRAR.patch | 37 +++ |
34 |
.../hardened/0001-Use-z-relro-on-Gentoo.patch | 11 + |
35 |
.../0002-Enable-Stack-Protector-by-default.patch | 25 ++ |
36 |
.../hardened/0003-Enable-PIE-by-default.patch | 24 ++ |
37 |
...04-Enable-FORTIFY_SOURCE-macro-by-default.patch | 35 +++ |
38 |
...005-Link-with-z-now-by-default-for-Gentoo.patch | 14 + |
39 |
...d-invalidated-iterator-in-insertTargetAnd.patch | 55 ++++ |
40 |
...oss-DSO-CFI-Android-sanitizer-test-for-rt.patch | 30 ++ |
41 |
.../files/6.0.0/0003-Add-Gentoo-Linux-distro.patch | 33 ++ |
42 |
.../hardened/0001-Use-z-relro-on-Gentoo.patch | 11 + |
43 |
.../0002-Enable-Stack-Protector-by-default.patch | 25 ++ |
44 |
.../hardened/0003-Enable-PIE-by-default.patch | 12 + |
45 |
...04-Enable-FORTIFY_SOURCE-macro-by-default.patch | 35 +++ |
46 |
...005-Link-with-z-now-by-default-for-Gentoo.patch | 11 + |
47 |
sys-devel/clang/metadata.xml | 35 +++ |
48 |
32 files changed, 2054 insertions(+) |
49 |
|
50 |
diff --git a/sys-devel/clang/Manifest b/sys-devel/clang/Manifest |
51 |
new file mode 100644 |
52 |
index 0000000..b6392eb |
53 |
--- /dev/null |
54 |
+++ b/sys-devel/clang/Manifest |
55 |
@@ -0,0 +1,31 @@ |
56 |
+-----BEGIN PGP SIGNED MESSAGE----- |
57 |
+Hash: SHA256 |
58 |
+ |
59 |
+DIST cfe-4.0.1.src.tar.xz 10933628 BLAKE2B bc1bb8875e83ccecd446a48cfa41f5c98a09d6ad24ff439a983f629711b4513b9c4bee4070f8df13b6b2a52d673b0706733a4c151ce5021a0233147debff14ac SHA512 936c9e1626b27e63a4fb11f3c0cb998eeaf9a520ad6e2bcd67cb4352e59e7781ecc700df79794f3fd70473d90b7e2ba418a39038eb0146b68e843f0705c1f964 |
60 |
+DIST cfe-5.0.1.src.tar.xz 11483036 BLAKE2B c4eb54cd8271b62cf7a2219db0b599b68c00b6e574d1946220efbd1633e841796e6717d6eeb35e84a6db32a731a3285b59cedeb3b1a8f3c3c502b799fdd0a720 SHA512 6619177a2ff9934fe8b15d6aa229abb8e34d0b1a75228d9efba9393daf71d6419a7256de57b31e2f9f829f71f842118556f996e86ee076f1e0a7cd394dfd31a2 |
61 |
+DIST cfe-6.0.0.src.tar.xz 11959224 BLAKE2B 257edbaedf72bd941b67b4aa2f152a96a37bbea72d21d22d4445152685efe40d75b9a7a39955545643e841ad6693ef12e52b207b9119098774f39e858b64bc09 SHA512 e886dd27448503bbfc7fd4f68eb089c19b2f2be4f0e5b26d3df253833f60b91d70b472a6b530063386e2252075b110ce9f5942800feddf6c34b94a75cf7bd5c6 |
62 |
+DIST clang-tools-extra-4.0.1.src.tar.xz 581788 BLAKE2B 52ca89eda6fe1e0fbbdc46e17f4067f03a9a9440dcdcc98811651087d0c9ab24dfe3eefb0b80a32ec41abe0766cb3e47031de61c4cff02b7d0e08c8fd03e3faa SHA512 ea26d926f428e62e76cf8a073e63ffe05645f6592e05d7717d5c257908870ae9217727d3e1578227b14eda5937085872463f1a8e99970256179c68b8a92e69e0 |
63 |
+DIST clang-tools-extra-5.0.1.src.tar.xz 646328 BLAKE2B 472eb1e73a17564790919ec392dddcd91f131c1cbf2a5f3cab09a9f7126d4d18ec6785ffcb3c3230eec6edc90acbe2bf859367c37f62ba77d7542f4c18b925f3 SHA512 2e6a811cccd22281f7567f5626ff0484ed1fefee4a9244a717e3ccb9516dce9e7ff315044fb10e505e91c3f1c6d2774558debb9559915d053886599bcb153d7b |
64 |
+DIST clang-tools-extra-6.0.0.src.tar.xz 757680 BLAKE2B 708e21055a702c41a94f6b8673bab405f8b1339a75ec66f14c31565ef802245900bafc25e636c6e82f01e74060a6429a19442317f948011cae59af6825808343 SHA512 9c5720b8694c235ca988ef45da1d564ac06e31c0a40600b32c0b9df399693e4eba296ca43b077ed97adba085362ddb0fb94e0d28232afc3e7351820b1285061f |
65 |
+DIST llvm-4.0.1.src.tar.xz 21065652 BLAKE2B 6327eed2d1feb108440f22d2581d1ff86c10a10c29793538d8d899c7e2dc83d3f7b147d3fd4bcce2bd2bf57c071b08c624aeafe40a3e7a3914506e7751727e6c SHA512 16adc39b34ddb628f81b171119a8e2a0e9138b25011e803ef0b688e2fbea116fc4953d3a1b61b90a98a75e33619f81566b7cb06a9a2ea4d04ac5e0eb303a2d1d |
66 |
+DIST llvm-5.0.1-manpages.tar.bz2 94004 BLAKE2B 34eb29361ad7aa881e64d1dd2992fd89ce44adafd2521284c27b6ffe7082bc7e70458204e6f34d582b704bf7c5dad93c6a6dc41fc7abc41862aab8f5ec53ed07 SHA512 3444cc8e06009f5dd2669b92af662a1049d9294c8ca0dcf45486e1dc1aaf10160860b7856d30ad70bbe5864b21d1539316e89f5237549f5653954e23baf64334 |
67 |
+DIST llvm-5.0.1.src.tar.xz 23428720 BLAKE2B 3db4d33df21018d17eef0042c0d8d82a8412bd5daa99cfb5405a6ec83c5774178fa76b220e8731c2a9a64dabf898aa90fe29c685327bd63a4f078e8e94a9a77e SHA512 bee1d45fca15ce725b1f2b1339b13eb6f750a3a321cfd099075477ec25835a8ca55b5366172c4aad46592dfd8afe372349ecf264f581463d017f9cee2d63c1cb |
68 |
+DIST llvm-6.0.0-manpages.tar.bz2 102668 BLAKE2B f458cbfcfdd6600f90f9bbe8cd9681de3dc11c62dbfcaa5ba7a281ad30d6367c33bebd5090c255e85a10b00b7bcb9c988d340b67f1db51982f55956acba109e9 SHA512 a7ed3e246e6488254f19dbb8484c079be39bc52f9b2fab3f736dd013683b7f46e8e036ee571dec5066c86ee7c25713608a2426555e8ad04b81891912314ee48e |
69 |
+DIST llvm-6.0.0.src.tar.xz 25296048 BLAKE2B 7ea90bb63d6f26cfbc1c1ed2f243b0fcd8ad2ceb7963cf768d262cd55e9a0c71a9cfdea0333fb220faacf4540d924d2512532774dcfb52b52490ad74e38c09e0 SHA512 a71fdd5ddc46f01327ad891cfcc198febdbe10769c57f14d8a4fb7d514621ee4080e1a641200d3353c16a16731d390270499ec6cd3dc98fadc570f3eb6b52b8c |
70 |
+DIST llvm-manpages-4.0.1.tar.bz2 87981 BLAKE2B 79ffd254ee5c6e09159c954913ef820f74107d4fcea5e3ed82592dc36af8fdfbf1e850547ba8bfc20aa9a5ecdd26c50329e6a6d558ae3aa5475a930789ce3e01 SHA512 d5b3213567c25db58ef364d272314a79c311a80fc21d98c09a5540af45a8190a38f489228663fe9a9b63bf0f2b952c460c4196a8fc8d6f221619f6e7ed2fc415 |
71 |
+-----BEGIN PGP SIGNATURE----- |
72 |
+ |
73 |
+iQIzBAEBCAAdFiEE8JaD5QHaZGPThRiKxu9aAvVkeYcFAlrk/n0ACgkQxu9aAvVk |
74 |
+eYfnng//Z+/QCuSsxtshLJLN8MkTvt64ONvg32NcKrg6Z/lfwCt6ckb30dMgsAQM |
75 |
+yxBfGjWa/YhCx80ln35ic780ei4cBGebxVSxrzXvv1EgrI2MrtAw/wZJCTXf0JP2 |
76 |
+xMlJ+QNno6GloDjm+HTuOVt9H7PF4AUsSJPf4eIGJrzwn53JcYfGmF3p1+9xQW3z |
77 |
+nPDFqApSnc9xhDeHCLqSAX0vXyQrkvWeY9AZ0hmdyM30andDS6ErdDk0wHjmq2au |
78 |
+v76dh4rU2HgKqKwA0MPe9ZZsOl2KAw3QWAEHzaNrdQ8o6lopDW5TvEBBD76qhED8 |
79 |
+caW3bCnA318KU8el7P+Pv2+ZSTp/MdE0+wFzCCJqlHUZLFJLWVqRWMzRPVHtIUSm |
80 |
+kPaW+XXz9JviD7E3dtUAtUBoTySlaSsarANpuV5Iy2hdNt4eyfTEtLUl79hTxmxw |
81 |
+SUr6M1x7eRXfJiyKHOzUYrh153H2ViyaSuFpbI+99PdGN0tnYHUkJfLdw7uCkXUA |
82 |
+gN+613b4xqIOHeienWbGg3Nh+qpStE+HWrwhlliYTquT4kag3eAcrBJO+Ww2ayg9 |
83 |
+oiRXgajWt3tRQpf8msASP8euGPwgj1kteZaUVcQ2MS+Fq9tGz4w+Vbzn2n/kU4u6 |
84 |
+VmArCo6oO8kudNaWcG5HisH/hRLb2U9rS7/geE2w63Z/m2ZypdU= |
85 |
+=sz4o |
86 |
+-----END PGP SIGNATURE----- |
87 |
|
88 |
diff --git a/sys-devel/clang/clang-4.0.1.ebuild b/sys-devel/clang/clang-4.0.1.ebuild |
89 |
new file mode 100644 |
90 |
index 0000000..edb31a7 |
91 |
--- /dev/null |
92 |
+++ b/sys-devel/clang/clang-4.0.1.ebuild |
93 |
@@ -0,0 +1,309 @@ |
94 |
+# Copyright 1999-2018 Gentoo Foundation |
95 |
+# Distributed under the terms of the GNU General Public License v2 |
96 |
+ |
97 |
+EAPI=6 |
98 |
+ |
99 |
+: ${CMAKE_MAKEFILE_GENERATOR:=ninja} |
100 |
+# (needed due to CMAKE_BUILD_TYPE != Gentoo) |
101 |
+CMAKE_MIN_VERSION=3.7.0-r1 |
102 |
+PYTHON_COMPAT=( python2_7 ) |
103 |
+ |
104 |
+inherit cmake-utils flag-o-matic llvm multilib-minimal \ |
105 |
+ python-single-r1 toolchain-funcs pax-utils versionator |
106 |
+ |
107 |
+DESCRIPTION="C language family frontend for LLVM" |
108 |
+HOMEPAGE="https://llvm.org/" |
109 |
+SRC_URI="https://releases.llvm.org/${PV/_//}/cfe-${PV/_/}.src.tar.xz |
110 |
+ https://releases.llvm.org/${PV/_//}/clang-tools-extra-${PV/_/}.src.tar.xz |
111 |
+ !doc? ( https://dev.gentoo.org/~mgorny/dist/llvm/llvm-manpages-${PV}.tar.bz2 ) |
112 |
+ test? ( https://releases.llvm.org/${PV/_//}/llvm-${PV/_/}.src.tar.xz )" |
113 |
+ |
114 |
+# Keep in sync with sys-devel/llvm |
115 |
+ALL_LLVM_TARGETS=( AArch64 AMDGPU ARM BPF Hexagon Lanai Mips MSP430 |
116 |
+ NVPTX PowerPC RISCV Sparc SystemZ X86 XCore ) |
117 |
+ALL_LLVM_TARGETS=( "${ALL_LLVM_TARGETS[@]/#/llvm_targets_}" ) |
118 |
+LLVM_TARGET_USEDEPS=${ALL_LLVM_TARGETS[@]/%/?} |
119 |
+ |
120 |
+LICENSE="UoI-NCSA" |
121 |
+SLOT="$(get_major_version)" |
122 |
+KEYWORDS="amd64 ~arm64 x86" |
123 |
+IUSE="debug default-compiler-rt default-libcxx doc hardened +static-analyzer |
124 |
+ test xml elibc_musl kernel_FreeBSD ${ALL_LLVM_TARGETS[*]}" |
125 |
+ |
126 |
+RDEPEND=" |
127 |
+ ~sys-devel/llvm-${PV}:${SLOT}=[debug=,${LLVM_TARGET_USEDEPS// /,},${MULTILIB_USEDEP}] |
128 |
+ static-analyzer? ( dev-lang/perl:* ) |
129 |
+ xml? ( dev-libs/libxml2:2=[${MULTILIB_USEDEP}] ) |
130 |
+ ${PYTHON_DEPS}" |
131 |
+# configparser-3.2 breaks the build (3.3 or none at all are fine) |
132 |
+DEPEND="${RDEPEND} |
133 |
+ doc? ( dev-python/sphinx ) |
134 |
+ xml? ( virtual/pkgconfig ) |
135 |
+ !!<dev-python/configparser-3.3.0.2 |
136 |
+ ${PYTHON_DEPS}" |
137 |
+RDEPEND="${RDEPEND} |
138 |
+ !<sys-devel/llvm-4.0.0_rc:0 |
139 |
+ !sys-devel/clang:0" |
140 |
+PDEPEND=" |
141 |
+ ~sys-devel/clang-runtime-${PV} |
142 |
+ default-compiler-rt? ( =sys-libs/compiler-rt-${PV%_*}* ) |
143 |
+ default-libcxx? ( >=sys-libs/libcxx-${PV} )" |
144 |
+ |
145 |
+REQUIRED_USE="${PYTHON_REQUIRED_USE} |
146 |
+ || ( ${ALL_LLVM_TARGETS[*]} )" |
147 |
+ |
148 |
+# We need extra level of indirection for CLANG_RESOURCE_DIR |
149 |
+S=${WORKDIR}/x/y/cfe-${PV/_/}.src |
150 |
+ |
151 |
+# least intrusive of all |
152 |
+CMAKE_BUILD_TYPE=RelWithDebInfo |
153 |
+ |
154 |
+# Multilib notes: |
155 |
+# 1. ABI_* flags control ABIs libclang* is built for only. |
156 |
+# 2. clang is always capable of compiling code for all ABIs for enabled |
157 |
+# target. However, you will need appropriate crt* files (installed |
158 |
+# e.g. by sys-devel/gcc and sys-libs/glibc). |
159 |
+# 3. ${CHOST}-clang wrappers are always installed for all ABIs included |
160 |
+# in the current profile (i.e. alike supported by sys-devel/gcc). |
161 |
+# |
162 |
+# Therefore: use sys-devel/clang[${MULTILIB_USEDEP}] only if you need |
163 |
+# multilib clang* libraries (not runtime, not wrappers). |
164 |
+ |
165 |
+pkg_setup() { |
166 |
+ LLVM_MAX_SLOT=${SLOT} llvm_pkg_setup |
167 |
+ python-single-r1_pkg_setup |
168 |
+} |
169 |
+ |
170 |
+src_unpack() { |
171 |
+ # create extra parent dirs for CLANG_RESOURCE_DIR |
172 |
+ mkdir -p x/y || die |
173 |
+ cd x/y || die |
174 |
+ |
175 |
+ default |
176 |
+ |
177 |
+ mv clang-tools-extra-*.src "${S}"/tools/extra || die |
178 |
+ if use test; then |
179 |
+ mv llvm-*.src "${WORKDIR}"/llvm || die |
180 |
+ fi |
181 |
+} |
182 |
+ |
183 |
+src_prepare() { |
184 |
+ # fix finding compiler-rt libs |
185 |
+ eapply "${FILESDIR}"/5.0.1/0001-Driver-Use-arch-type-to-find-compiler-rt-libraries-o.patch |
186 |
+ |
187 |
+ # fix stand-alone doc build |
188 |
+ eapply "${FILESDIR}"/4.0.1/0002-cmake-Support-stand-alone-Sphinx-doxygen-doc-build.patch |
189 |
+ |
190 |
+ # fix value of ATOMIC_*_LOCK_FREE |
191 |
+ # (backport, temporary reverted upstream because of FreeBSD issues) |
192 |
+ eapply "${FILESDIR}"/4.0.1/0001-Frontend-Correct-values-of-ATOMIC_-_LOCK_FREE-to-mat.patch |
193 |
+ |
194 |
+ # only used in hardened patches at the moment |
195 |
+ eapply "${FILESDIR}"/4.0.1/0003-Add-Gentoo-Linux-distro.patch |
196 |
+ |
197 |
+ cd tools/extra || die |
198 |
+ # fix stand-alone test build for extra tools |
199 |
+ eapply "${FILESDIR}"/4.0.1/extra/0001-test-Fix-test-dependencies-when-using-installed-tool.patch |
200 |
+ eapply "${FILESDIR}"/4.0.1/extra/0002-test-Fix-clang-library-dir-in-LD_LIBRARY_PATH-For-st.patch |
201 |
+ cd - >/dev/null || die |
202 |
+ |
203 |
+ if use hardened; then |
204 |
+ eapply "${FILESDIR}"/4.0.1/hardened/0001-Use-z-relro-on-Gentoo.patch |
205 |
+ eapply "${FILESDIR}"/4.0.1/hardened/0002-Enable-Stack-Protector-by-default.patch |
206 |
+ eapply "${FILESDIR}"/4.0.1/hardened/0003-Enable-PIE-by-default.patch |
207 |
+ eapply "${FILESDIR}"/4.0.1/hardened/0004-Link-with-z-now-by-default-for-Gentoo.patch |
208 |
+ fi |
209 |
+ |
210 |
+ # User patches |
211 |
+ cmake-utils_src_prepare |
212 |
+} |
213 |
+ |
214 |
+multilib_src_configure() { |
215 |
+ local llvm_version=$(llvm-config --version) || die |
216 |
+ local clang_version=$(get_version_component_range 1-3 "${llvm_version}") |
217 |
+ |
218 |
+ local mycmakeargs=( |
219 |
+ # ensure that the correct llvm-config is used |
220 |
+ -DLLVM_CONFIG="$(type -P "${CHOST}-llvm-config")" |
221 |
+ -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr/lib/llvm/${SLOT}" |
222 |
+ -DCMAKE_INSTALL_MANDIR="${EPREFIX}/usr/lib/llvm/${SLOT}/share/man" |
223 |
+ # relative to bindir |
224 |
+ -DCLANG_RESOURCE_DIR="../../../../lib/clang/${clang_version}" |
225 |
+ |
226 |
+ -DBUILD_SHARED_LIBS=ON |
227 |
+ -DLLVM_TARGETS_TO_BUILD="${LLVM_TARGETS// /;}" |
228 |
+ -DLLVM_BUILD_TESTS=$(usex test) |
229 |
+ |
230 |
+ # these are not propagated reliably, so redefine them |
231 |
+ -DLLVM_ENABLE_EH=ON |
232 |
+ -DLLVM_ENABLE_RTTI=ON |
233 |
+ |
234 |
+ -DCMAKE_DISABLE_FIND_PACKAGE_LibXml2=$(usex !xml) |
235 |
+ # libgomp support fails to find headers without explicit -I |
236 |
+ # furthermore, it provides only syntax checking |
237 |
+ -DCLANG_DEFAULT_OPENMP_RUNTIME=libomp |
238 |
+ |
239 |
+ # override default stdlib and rtlib |
240 |
+ -DCLANG_DEFAULT_CXX_STDLIB=$(usex default-libcxx libc++ "") |
241 |
+ -DCLANG_DEFAULT_RTLIB=$(usex default-compiler-rt compiler-rt "") |
242 |
+ |
243 |
+ -DCLANG_ENABLE_ARCMT=$(usex static-analyzer) |
244 |
+ -DCLANG_ENABLE_STATIC_ANALYZER=$(usex static-analyzer) |
245 |
+ ) |
246 |
+ use test && mycmakeargs+=( |
247 |
+ -DLLVM_MAIN_SRC_DIR="${WORKDIR}/llvm" |
248 |
+ ) |
249 |
+ |
250 |
+ if multilib_is_native_abi; then |
251 |
+ mycmakeargs+=( |
252 |
+ -DLLVM_BUILD_DOCS=$(usex doc) |
253 |
+ -DLLVM_ENABLE_SPHINX=$(usex doc) |
254 |
+ -DLLVM_ENABLE_DOXYGEN=OFF |
255 |
+ |
256 |
+ # workaround pthread |
257 |
+ -DPTHREAD_LIB=-pthread |
258 |
+ ) |
259 |
+ use doc && mycmakeargs+=( |
260 |
+ -DCLANG_INSTALL_SPHINX_HTML_DIR="${EPREFIX}/usr/share/doc/${PF}/html" |
261 |
+ -DCLANG-TOOLS_INSTALL_SPHINX_HTML_DIR="${EPREFIX}/usr/share/doc/${PF}/tools-extra" |
262 |
+ -DSPHINX_WARNINGS_AS_ERRORS=OFF |
263 |
+ ) |
264 |
+ else |
265 |
+ mycmakeargs+=( |
266 |
+ -DLLVM_TOOL_CLANG_TOOLS_EXTRA_BUILD=OFF |
267 |
+ ) |
268 |
+ fi |
269 |
+ |
270 |
+ if [[ -n ${EPREFIX} ]]; then |
271 |
+ mycmakeargs+=( |
272 |
+ -DGCC_INSTALL_PREFIX="${EPREFIX}/usr" |
273 |
+ ) |
274 |
+ fi |
275 |
+ |
276 |
+ if tc-is-cross-compiler; then |
277 |
+ [[ -x "/usr/bin/clang-tblgen" ]] \ |
278 |
+ || die "/usr/bin/clang-tblgen not found or usable" |
279 |
+ mycmakeargs+=( |
280 |
+ -DCMAKE_CROSSCOMPILING=ON |
281 |
+ -DCLANG_TABLEGEN=/usr/bin/clang-tblgen |
282 |
+ ) |
283 |
+ fi |
284 |
+ |
285 |
+ # LLVM_ENABLE_ASSERTIONS=NO does not guarantee this for us, #614844 |
286 |
+ use debug || local -x CPPFLAGS="${CPPFLAGS} -DNDEBUG" |
287 |
+ cmake-utils_src_configure |
288 |
+} |
289 |
+ |
290 |
+multilib_src_compile() { |
291 |
+ cmake-utils_src_compile |
292 |
+ |
293 |
+ # provide a symlink for tests |
294 |
+ if [[ ! -L ${WORKDIR}/lib/clang ]]; then |
295 |
+ mkdir -p "${WORKDIR}"/lib || die |
296 |
+ ln -s "${BUILD_DIR}/$(get_libdir)/clang" "${WORKDIR}"/lib/clang || die |
297 |
+ fi |
298 |
+} |
299 |
+ |
300 |
+multilib_src_test() { |
301 |
+ # respect TMPDIR! |
302 |
+ local -x LIT_PRESERVES_TMP=1 |
303 |
+ cmake-utils_src_make check-clang |
304 |
+ # clang-tidy requires [static-analyzer] and tests are not split |
305 |
+ # correctly, so they are all disabled when static-analyzer is off |
306 |
+ if multilib_is_native_abi && use static-analyzer; then |
307 |
+ cmake-utils_src_make check-clang-tools |
308 |
+ fi |
309 |
+} |
310 |
+ |
311 |
+src_install() { |
312 |
+ MULTILIB_WRAPPED_HEADERS=( |
313 |
+ /usr/include/clang/Config/config.h |
314 |
+ ) |
315 |
+ |
316 |
+ multilib-minimal_src_install |
317 |
+ |
318 |
+ # Move runtime headers to /usr/lib/clang, where they belong |
319 |
+ mv "${ED%/}"/usr/include/clangrt "${ED%/}"/usr/lib/clang || die |
320 |
+ # move (remaining) wrapped headers back |
321 |
+ mv "${ED%/}"/usr/include "${ED%/}"/usr/lib/llvm/${SLOT}/include || die |
322 |
+ |
323 |
+ # Apply CHOST and version suffix to clang tools |
324 |
+ # note: we use two version components here (vs 3 in runtime path) |
325 |
+ local llvm_version=$(llvm-config --version) || die |
326 |
+ local clang_version=$(get_version_component_range 1-2 "${llvm_version}") |
327 |
+ local clang_full_version=$(get_version_component_range 1-3 "${llvm_version}") |
328 |
+ local clang_tools=( clang clang++ clang-cl clang-cpp ) |
329 |
+ local abi i |
330 |
+ |
331 |
+ # cmake gives us: |
332 |
+ # - clang-X.Y |
333 |
+ # - clang -> clang-X.Y |
334 |
+ # - clang++, clang-cl, clang-cpp -> clang |
335 |
+ # we want to have: |
336 |
+ # - clang-X.Y |
337 |
+ # - clang++-X.Y, clang-cl-X.Y, clang-cpp-X.Y -> clang-X.Y |
338 |
+ # - clang, clang++, clang-cl, clang-cpp -> clang*-X.Y |
339 |
+ # also in CHOST variant |
340 |
+ for i in "${clang_tools[@]:1}"; do |
341 |
+ rm "${ED%/}/usr/lib/llvm/${SLOT}/bin/${i}" || die |
342 |
+ dosym "clang-${clang_version}" "/usr/lib/llvm/${SLOT}/bin/${i}-${clang_version}" |
343 |
+ dosym "${i}-${clang_version}" "/usr/lib/llvm/${SLOT}/bin/${i}" |
344 |
+ done |
345 |
+ |
346 |
+ # now create target symlinks for all supported ABIs |
347 |
+ for abi in $(get_all_abis); do |
348 |
+ local abi_chost=$(get_abi_CHOST "${abi}") |
349 |
+ for i in "${clang_tools[@]}"; do |
350 |
+ dosym "${i}-${clang_version}" \ |
351 |
+ "/usr/lib/llvm/${SLOT}/bin/${abi_chost}-${i}-${clang_version}" |
352 |
+ dosym "${abi_chost}-${i}-${clang_version}" \ |
353 |
+ "/usr/lib/llvm/${SLOT}/bin/${abi_chost}-${i}" |
354 |
+ done |
355 |
+ done |
356 |
+ |
357 |
+ # Remove unnecessary headers on FreeBSD, bug #417171 |
358 |
+ if use kernel_FreeBSD; then |
359 |
+ rm "${ED}"usr/lib/clang/${clang_full_version}/include/{std,float,iso,limits,tgmath,varargs}*.h || die |
360 |
+ fi |
361 |
+} |
362 |
+ |
363 |
+multilib_src_install() { |
364 |
+ cmake-utils_src_install |
365 |
+ |
366 |
+ # move headers to /usr/include for wrapping & ABI mismatch checks |
367 |
+ # (also drop the version suffix from runtime headers) |
368 |
+ rm -rf "${ED%/}"/usr/include || die |
369 |
+ mv "${ED%/}"/usr/lib/llvm/${SLOT}/include "${ED%/}"/usr/include || die |
370 |
+ mv "${ED%/}"/usr/lib/llvm/${SLOT}/$(get_libdir)/clang "${ED%/}"/usr/include/clangrt || die |
371 |
+} |
372 |
+ |
373 |
+multilib_src_install_all() { |
374 |
+ python_fix_shebang "${ED}" |
375 |
+ if use static-analyzer; then |
376 |
+ python_optimize "${ED}"usr/lib/llvm/${SLOT}/share/scan-view |
377 |
+ fi |
378 |
+ |
379 |
+ # install pre-generated manpages |
380 |
+ if ! use doc; then |
381 |
+ insinto "/usr/lib/llvm/${SLOT}/share/man/man1" |
382 |
+ doins "${WORKDIR}/x/y/llvm-manpages-${PV}/clang"/*.1 |
383 |
+ fi |
384 |
+ |
385 |
+ docompress "/usr/lib/llvm/${SLOT}/share/man" |
386 |
+ # match 'html' non-compression |
387 |
+ use doc && docompress -x "/usr/share/doc/${PF}/tools-extra" |
388 |
+ # +x for some reason; TODO: investigate |
389 |
+ use static-analyzer && fperms a-x "/usr/lib/llvm/${SLOT}/share/man/man1/scan-build.1" |
390 |
+} |
391 |
+ |
392 |
+pkg_postinst() { |
393 |
+ if [[ ${ROOT} == / && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then |
394 |
+ eselect compiler-shadow update all |
395 |
+ fi |
396 |
+} |
397 |
+ |
398 |
+pkg_postrm() { |
399 |
+ if [[ ${ROOT} == / && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then |
400 |
+ eselect compiler-shadow clean all |
401 |
+ fi |
402 |
+} |
403 |
|
404 |
diff --git a/sys-devel/clang/clang-5.0.1.ebuild b/sys-devel/clang/clang-5.0.1.ebuild |
405 |
new file mode 100644 |
406 |
index 0000000..326b27e |
407 |
--- /dev/null |
408 |
+++ b/sys-devel/clang/clang-5.0.1.ebuild |
409 |
@@ -0,0 +1,333 @@ |
410 |
+# Copyright 1999-2018 Gentoo Foundation |
411 |
+# Distributed under the terms of the GNU General Public License v2 |
412 |
+ |
413 |
+EAPI=6 |
414 |
+ |
415 |
+: ${CMAKE_MAKEFILE_GENERATOR:=ninja} |
416 |
+# (needed due to CMAKE_BUILD_TYPE != Gentoo) |
417 |
+CMAKE_MIN_VERSION=3.7.0-r1 |
418 |
+PYTHON_COMPAT=( python2_7 ) |
419 |
+ |
420 |
+inherit cmake-utils eapi7-ver flag-o-matic llvm \ |
421 |
+ multilib-minimal pax-utils prefix python-single-r1 toolchain-funcs |
422 |
+ |
423 |
+MY_P=cfe-${PV/_/}.src |
424 |
+EXTRA_P=clang-tools-extra-${PV/_/}.src |
425 |
+LLVM_P=llvm-${PV/_/}.src |
426 |
+ |
427 |
+DESCRIPTION="C language family frontend for LLVM" |
428 |
+HOMEPAGE="https://llvm.org/" |
429 |
+SRC_URI="https://releases.llvm.org/${PV/_//}/${MY_P}.tar.xz |
430 |
+ https://releases.llvm.org/${PV/_//}/${EXTRA_P}.tar.xz |
431 |
+ test? ( https://releases.llvm.org/${PV/_//}/${LLVM_P}.tar.xz ) |
432 |
+ !doc? ( https://dev.gentoo.org/~mgorny/dist/llvm/llvm-${PV}-manpages.tar.bz2 )" |
433 |
+ |
434 |
+# Keep in sync with sys-devel/llvm |
435 |
+ALL_LLVM_TARGETS=( AArch64 AMDGPU ARM BPF Hexagon Lanai Mips MSP430 |
436 |
+ NVPTX PowerPC Sparc SystemZ X86 XCore ) |
437 |
+ALL_LLVM_TARGETS=( "${ALL_LLVM_TARGETS[@]/#/llvm_targets_}" ) |
438 |
+LLVM_TARGET_USEDEPS=${ALL_LLVM_TARGETS[@]/%/?} |
439 |
+ |
440 |
+LICENSE="UoI-NCSA" |
441 |
+SLOT="$(ver_cut 1)" |
442 |
+KEYWORDS="amd64 ~arm64 x86 ~amd64-fbsd ~amd64-linux ~ppc-macos ~x64-macos ~x86-macos" |
443 |
+IUSE="debug default-compiler-rt default-libcxx doc hardened +static-analyzer |
444 |
+ test xml z3 kernel_FreeBSD ${ALL_LLVM_TARGETS[*]}" |
445 |
+ |
446 |
+RDEPEND=" |
447 |
+ ~sys-devel/llvm-${PV}:${SLOT}=[debug=,${LLVM_TARGET_USEDEPS// /,},${MULTILIB_USEDEP}] |
448 |
+ static-analyzer? ( |
449 |
+ dev-lang/perl:* |
450 |
+ z3? ( sci-mathematics/z3:0= ) |
451 |
+ ) |
452 |
+ xml? ( dev-libs/libxml2:2=[${MULTILIB_USEDEP}] ) |
453 |
+ ${PYTHON_DEPS}" |
454 |
+# configparser-3.2 breaks the build (3.3 or none at all are fine) |
455 |
+DEPEND="${RDEPEND} |
456 |
+ doc? ( dev-python/sphinx ) |
457 |
+ xml? ( virtual/pkgconfig ) |
458 |
+ !!<dev-python/configparser-3.3.0.2 |
459 |
+ ${PYTHON_DEPS}" |
460 |
+RDEPEND="${RDEPEND} |
461 |
+ !<sys-devel/llvm-4.0.0_rc:0 |
462 |
+ !sys-devel/clang:0" |
463 |
+PDEPEND=" |
464 |
+ ~sys-devel/clang-runtime-${PV} |
465 |
+ default-compiler-rt? ( =sys-libs/compiler-rt-${PV%_*}* ) |
466 |
+ default-libcxx? ( >=sys-libs/libcxx-${PV} )" |
467 |
+ |
468 |
+REQUIRED_USE="${PYTHON_REQUIRED_USE} |
469 |
+ || ( ${ALL_LLVM_TARGETS[*]} )" |
470 |
+ |
471 |
+# We need extra level of indirection for CLANG_RESOURCE_DIR |
472 |
+S=${WORKDIR}/x/y/${MY_P} |
473 |
+ |
474 |
+# least intrusive of all |
475 |
+CMAKE_BUILD_TYPE=RelWithDebInfo |
476 |
+ |
477 |
+# Multilib notes: |
478 |
+# 1. ABI_* flags control ABIs libclang* is built for only. |
479 |
+# 2. clang is always capable of compiling code for all ABIs for enabled |
480 |
+# target. However, you will need appropriate crt* files (installed |
481 |
+# e.g. by sys-devel/gcc and sys-libs/glibc). |
482 |
+# 3. ${CHOST}-clang wrappers are always installed for all ABIs included |
483 |
+# in the current profile (i.e. alike supported by sys-devel/gcc). |
484 |
+# |
485 |
+# Therefore: use sys-devel/clang[${MULTILIB_USEDEP}] only if you need |
486 |
+# multilib clang* libraries (not runtime, not wrappers). |
487 |
+ |
488 |
+pkg_setup() { |
489 |
+ LLVM_MAX_SLOT=${SLOT} llvm_pkg_setup |
490 |
+ python-single-r1_pkg_setup |
491 |
+} |
492 |
+ |
493 |
+src_unpack() { |
494 |
+ # create extra parent dir for CLANG_RESOURCE_DIR |
495 |
+ mkdir -p x/y || die |
496 |
+ cd x/y || die |
497 |
+ |
498 |
+ einfo "Unpacking ${MY_P}.tar.xz ..." |
499 |
+ tar -xf "${DISTDIR}/${MY_P}.tar.xz" || die |
500 |
+ einfo "Unpacking ${EXTRA_P}.tar.xz ..." |
501 |
+ tar -xf "${DISTDIR}/${EXTRA_P}.tar.xz" || die |
502 |
+ |
503 |
+ mv "${EXTRA_P}" "${S}"/tools/extra || die |
504 |
+ if use test; then |
505 |
+ einfo "Unpacking parts of ${LLVM_P}.tar.xz ..." |
506 |
+ tar -xf "${DISTDIR}/${LLVM_P}.tar.xz" \ |
507 |
+ "${LLVM_P}"/utils/{lit,unittest} || die |
508 |
+ mv "${LLVM_P}" "${WORKDIR}"/llvm || die |
509 |
+ fi |
510 |
+ |
511 |
+ if ! use doc; then |
512 |
+ einfo "Unpacking llvm-${PV}-manpages.tar.bz2 ..." |
513 |
+ tar -xf "${DISTDIR}/llvm-${PV}-manpages.tar.bz2" || die |
514 |
+ fi |
515 |
+} |
516 |
+ |
517 |
+src_prepare() { |
518 |
+ # fix finding compiler-rt libs |
519 |
+ eapply "${FILESDIR}"/5.0.1/0001-Driver-Use-arch-type-to-find-compiler-rt-libraries-o.patch |
520 |
+ # fix setting LD_LIBRARY_PATH for tests on *BSD |
521 |
+ eapply "${FILESDIR}"/5.0.1/0002-test-Fix-clang-test-for-FreeBSD-and-NetBSD.patch |
522 |
+ # add Prefix include paths for Darwin |
523 |
+ eapply "${FILESDIR}"/5.0.1/darwin_prefix-include-paths.patch |
524 |
+ # only used in hardened patches at the moment |
525 |
+ eapply "${FILESDIR}"/5.0.1/0003-Add-Gentoo-Linux-distro.patch |
526 |
+ |
527 |
+ cd tools/extra || die |
528 |
+ # fix setting LD_LIBRARY_PATH for tests on *BSD (extra part) |
529 |
+ eapply "${FILESDIR}"/5.0.1/extra/0001-Assume-the-shared-library-path-variable-is-LD_LIBRAR.patch |
530 |
+ cd ../.. || die |
531 |
+ |
532 |
+ if use hardened; then |
533 |
+ eapply "${FILESDIR}"/5.0.1/hardened/0001-Use-z-relro-on-Gentoo.patch |
534 |
+ eapply "${FILESDIR}"/5.0.1/hardened/0002-Enable-Stack-Protector-by-default.patch |
535 |
+ eapply "${FILESDIR}"/5.0.1/hardened/0003-Enable-PIE-by-default.patch |
536 |
+ eapply "${FILESDIR}"/5.0.1/hardened/0004-Enable-FORTIFY_SOURCE-macro-by-default.patch |
537 |
+ eapply "${FILESDIR}"/5.0.1/hardened/0005-Link-with-z-now-by-default-for-Gentoo.patch |
538 |
+ fi |
539 |
+ |
540 |
+ cmake-utils_src_prepare |
541 |
+ eprefixify lib/Frontend/InitHeaderSearch.cpp |
542 |
+} |
543 |
+ |
544 |
+multilib_src_configure() { |
545 |
+ local llvm_version=$(llvm-config --version) || die |
546 |
+ local clang_version=$(ver_cut 1-3 "${llvm_version}") |
547 |
+ |
548 |
+ local mycmakeargs=( |
549 |
+ # ensure that the correct llvm-config is used |
550 |
+ -DLLVM_CONFIG="$(type -P "${CHOST}-llvm-config")" |
551 |
+ -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr/lib/llvm/${SLOT}" |
552 |
+ -DCMAKE_INSTALL_MANDIR="${EPREFIX}/usr/lib/llvm/${SLOT}/share/man" |
553 |
+ # relative to bindir |
554 |
+ -DCLANG_RESOURCE_DIR="../../../../lib/clang/${clang_version}" |
555 |
+ |
556 |
+ -DBUILD_SHARED_LIBS=ON |
557 |
+ -DLLVM_TARGETS_TO_BUILD="${LLVM_TARGETS// /;}" |
558 |
+ -DLLVM_BUILD_TESTS=$(usex test) |
559 |
+ |
560 |
+ # these are not propagated reliably, so redefine them |
561 |
+ -DLLVM_ENABLE_EH=ON |
562 |
+ -DLLVM_ENABLE_RTTI=ON |
563 |
+ |
564 |
+ -DCMAKE_DISABLE_FIND_PACKAGE_LibXml2=$(usex !xml) |
565 |
+ # libgomp support fails to find headers without explicit -I |
566 |
+ # furthermore, it provides only syntax checking |
567 |
+ -DCLANG_DEFAULT_OPENMP_RUNTIME=libomp |
568 |
+ |
569 |
+ # override default stdlib and rtlib |
570 |
+ -DCLANG_DEFAULT_CXX_STDLIB=$(usex default-libcxx libc++ "") |
571 |
+ -DCLANG_DEFAULT_RTLIB=$(usex default-compiler-rt compiler-rt "") |
572 |
+ |
573 |
+ -DCLANG_ENABLE_ARCMT=$(usex static-analyzer) |
574 |
+ -DCLANG_ENABLE_STATIC_ANALYZER=$(usex static-analyzer) |
575 |
+ # z3 is not multilib-friendly |
576 |
+ -DCLANG_ANALYZER_BUILD_Z3=$(multilib_native_usex z3) |
577 |
+ ) |
578 |
+ use test && mycmakeargs+=( |
579 |
+ -DLLVM_MAIN_SRC_DIR="${WORKDIR}/llvm" |
580 |
+ ) |
581 |
+ |
582 |
+ if multilib_is_native_abi; then |
583 |
+ mycmakeargs+=( |
584 |
+ # normally copied from LLVM_INCLUDE_DOCS but the latter |
585 |
+ # is lacking value in stand-alone builds |
586 |
+ -DCLANG_INCLUDE_DOCS=$(usex doc) |
587 |
+ -DCLANG_TOOLS_EXTRA_INCLUDE_DOCS=$(usex doc) |
588 |
+ ) |
589 |
+ use doc && mycmakeargs+=( |
590 |
+ -DLLVM_BUILD_DOCS=ON |
591 |
+ -DLLVM_ENABLE_SPHINX=ON |
592 |
+ -DCLANG_INSTALL_SPHINX_HTML_DIR="${EPREFIX}/usr/share/doc/${PF}/html" |
593 |
+ -DCLANG-TOOLS_INSTALL_SPHINX_HTML_DIR="${EPREFIX}/usr/share/doc/${PF}/tools-extra" |
594 |
+ -DSPHINX_WARNINGS_AS_ERRORS=OFF |
595 |
+ ) |
596 |
+ use z3 && mycmakeargs+=( |
597 |
+ -DZ3_INCLUDE_DIR="${EPREFIX}/usr/include/z3" |
598 |
+ ) |
599 |
+ else |
600 |
+ mycmakeargs+=( |
601 |
+ -DLLVM_TOOL_CLANG_TOOLS_EXTRA_BUILD=OFF |
602 |
+ ) |
603 |
+ fi |
604 |
+ |
605 |
+ if [[ -n ${EPREFIX} ]]; then |
606 |
+ mycmakeargs+=( |
607 |
+ -DGCC_INSTALL_PREFIX="${EPREFIX}/usr" |
608 |
+ ) |
609 |
+ fi |
610 |
+ |
611 |
+ if tc-is-cross-compiler; then |
612 |
+ [[ -x "/usr/bin/clang-tblgen" ]] \ |
613 |
+ || die "/usr/bin/clang-tblgen not found or usable" |
614 |
+ mycmakeargs+=( |
615 |
+ -DCMAKE_CROSSCOMPILING=ON |
616 |
+ -DCLANG_TABLEGEN=/usr/bin/clang-tblgen |
617 |
+ ) |
618 |
+ fi |
619 |
+ |
620 |
+ # LLVM_ENABLE_ASSERTIONS=NO does not guarantee this for us, #614844 |
621 |
+ use debug || local -x CPPFLAGS="${CPPFLAGS} -DNDEBUG" |
622 |
+ cmake-utils_src_configure |
623 |
+} |
624 |
+ |
625 |
+multilib_src_compile() { |
626 |
+ cmake-utils_src_compile |
627 |
+ |
628 |
+ # provide a symlink for tests |
629 |
+ if [[ ! -L ${WORKDIR}/lib/clang ]]; then |
630 |
+ mkdir -p "${WORKDIR}"/lib || die |
631 |
+ ln -s "${BUILD_DIR}/$(get_libdir)/clang" "${WORKDIR}"/lib/clang || die |
632 |
+ fi |
633 |
+} |
634 |
+ |
635 |
+multilib_src_test() { |
636 |
+ # respect TMPDIR! |
637 |
+ local -x LIT_PRESERVES_TMP=1 |
638 |
+ cmake-utils_src_make check-clang |
639 |
+ # clang-tidy requires [static-analyzer] and tests are not split |
640 |
+ # correctly, so they are all disabled when static-analyzer is off |
641 |
+ if multilib_is_native_abi && use static-analyzer; then |
642 |
+ cmake-utils_src_make check-clang-tools |
643 |
+ fi |
644 |
+} |
645 |
+ |
646 |
+src_install() { |
647 |
+ MULTILIB_WRAPPED_HEADERS=( |
648 |
+ /usr/include/clang/Config/config.h |
649 |
+ ) |
650 |
+ |
651 |
+ multilib-minimal_src_install |
652 |
+ |
653 |
+ # Move runtime headers to /usr/lib/clang, where they belong |
654 |
+ mv "${ED%/}"/usr/include/clangrt "${ED%/}"/usr/lib/clang || die |
655 |
+ # move (remaining) wrapped headers back |
656 |
+ mv "${ED%/}"/usr/include "${ED%/}"/usr/lib/llvm/${SLOT}/include || die |
657 |
+ |
658 |
+ # Apply CHOST and version suffix to clang tools |
659 |
+ # note: we use two version components here (vs 3 in runtime path) |
660 |
+ local llvm_version=$(llvm-config --version) || die |
661 |
+ local clang_version=$(ver_cut 1-2 "${llvm_version}") |
662 |
+ local clang_full_version=$(ver_cut 1-3 "${llvm_version}") |
663 |
+ local clang_tools=( clang clang++ clang-cl clang-cpp ) |
664 |
+ local abi i |
665 |
+ |
666 |
+ # cmake gives us: |
667 |
+ # - clang-X.Y |
668 |
+ # - clang -> clang-X.Y |
669 |
+ # - clang++, clang-cl, clang-cpp -> clang |
670 |
+ # we want to have: |
671 |
+ # - clang-X.Y |
672 |
+ # - clang++-X.Y, clang-cl-X.Y, clang-cpp-X.Y -> clang-X.Y |
673 |
+ # - clang, clang++, clang-cl, clang-cpp -> clang*-X.Y |
674 |
+ # also in CHOST variant |
675 |
+ for i in "${clang_tools[@]:1}"; do |
676 |
+ rm "${ED%/}/usr/lib/llvm/${SLOT}/bin/${i}" || die |
677 |
+ dosym "clang-${clang_version}" "/usr/lib/llvm/${SLOT}/bin/${i}-${clang_version}" |
678 |
+ dosym "${i}-${clang_version}" "/usr/lib/llvm/${SLOT}/bin/${i}" |
679 |
+ done |
680 |
+ |
681 |
+ # now create target symlinks for all supported ABIs |
682 |
+ for abi in $(get_all_abis); do |
683 |
+ local abi_chost=$(get_abi_CHOST "${abi}") |
684 |
+ for i in "${clang_tools[@]}"; do |
685 |
+ dosym "${i}-${clang_version}" \ |
686 |
+ "/usr/lib/llvm/${SLOT}/bin/${abi_chost}-${i}-${clang_version}" |
687 |
+ dosym "${abi_chost}-${i}-${clang_version}" \ |
688 |
+ "/usr/lib/llvm/${SLOT}/bin/${abi_chost}-${i}" |
689 |
+ done |
690 |
+ done |
691 |
+ |
692 |
+ # Remove unnecessary headers on FreeBSD, bug #417171 |
693 |
+ if use kernel_FreeBSD; then |
694 |
+ rm "${ED}"usr/lib/clang/${clang_full_version}/include/{std,float,iso,limits,tgmath,varargs}*.h || die |
695 |
+ fi |
696 |
+} |
697 |
+ |
698 |
+multilib_src_install() { |
699 |
+ cmake-utils_src_install |
700 |
+ |
701 |
+ # move headers to /usr/include for wrapping & ABI mismatch checks |
702 |
+ # (also drop the version suffix from runtime headers) |
703 |
+ rm -rf "${ED%/}"/usr/include || die |
704 |
+ mv "${ED%/}"/usr/lib/llvm/${SLOT}/include "${ED%/}"/usr/include || die |
705 |
+ mv "${ED%/}"/usr/lib/llvm/${SLOT}/$(get_libdir)/clang "${ED%/}"/usr/include/clangrt || die |
706 |
+} |
707 |
+ |
708 |
+multilib_src_install_all() { |
709 |
+ python_fix_shebang "${ED}" |
710 |
+ if use static-analyzer; then |
711 |
+ python_optimize "${ED}"usr/lib/llvm/${SLOT}/share/scan-view |
712 |
+ fi |
713 |
+ |
714 |
+ # install pre-generated manpages |
715 |
+ if ! use doc; then |
716 |
+ insinto "/usr/lib/llvm/${SLOT}/share/man/man1" |
717 |
+ doins "${WORKDIR}/x/y/llvm-${PV}-manpages/clang"/*.1 |
718 |
+ fi |
719 |
+ |
720 |
+ docompress "/usr/lib/llvm/${SLOT}/share/man" |
721 |
+ # match 'html' non-compression |
722 |
+ use doc && docompress -x "/usr/share/doc/${PF}/tools-extra" |
723 |
+ # +x for some reason; TODO: investigate |
724 |
+ use static-analyzer && fperms a-x "/usr/lib/llvm/${SLOT}/share/man/man1/scan-build.1" |
725 |
+} |
726 |
+ |
727 |
+pkg_postinst() { |
728 |
+ if [[ ${ROOT} == / && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then |
729 |
+ eselect compiler-shadow update all |
730 |
+ fi |
731 |
+ |
732 |
+ elog "You can find additional utility scripts in:" |
733 |
+ elog " ${EROOT}/usr/lib/llvm/${SLOT}/share/clang" |
734 |
+ elog "To use these scripts, you will need Python 2.7. Some of them are vim" |
735 |
+ elog "integration scripts (with instructions inside)." |
736 |
+} |
737 |
+ |
738 |
+pkg_postrm() { |
739 |
+ if [[ ${ROOT} == / && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then |
740 |
+ eselect compiler-shadow clean all |
741 |
+ fi |
742 |
+} |
743 |
|
744 |
diff --git a/sys-devel/clang/clang-6.0.0-r1.ebuild b/sys-devel/clang/clang-6.0.0-r1.ebuild |
745 |
new file mode 100644 |
746 |
index 0000000..fc14879 |
747 |
--- /dev/null |
748 |
+++ b/sys-devel/clang/clang-6.0.0-r1.ebuild |
749 |
@@ -0,0 +1,337 @@ |
750 |
+# Copyright 1999-2018 Gentoo Foundation |
751 |
+# Distributed under the terms of the GNU General Public License v2 |
752 |
+ |
753 |
+EAPI=6 |
754 |
+ |
755 |
+: ${CMAKE_MAKEFILE_GENERATOR:=ninja} |
756 |
+# (needed due to CMAKE_BUILD_TYPE != Gentoo) |
757 |
+CMAKE_MIN_VERSION=3.7.0-r1 |
758 |
+PYTHON_COMPAT=( python2_7 ) |
759 |
+ |
760 |
+inherit cmake-utils eapi7-ver flag-o-matic llvm \ |
761 |
+ multilib-minimal multiprocessing pax-utils prefix python-single-r1 \ |
762 |
+ toolchain-funcs |
763 |
+ |
764 |
+MY_P=cfe-${PV/_/}.src |
765 |
+EXTRA_P=clang-tools-extra-${PV/_/}.src |
766 |
+LLVM_P=llvm-${PV/_/}.src |
767 |
+ |
768 |
+DESCRIPTION="C language family frontend for LLVM" |
769 |
+HOMEPAGE="https://llvm.org/" |
770 |
+SRC_URI="https://releases.llvm.org/${PV/_//}/${MY_P}.tar.xz |
771 |
+ https://releases.llvm.org/${PV/_//}/${EXTRA_P}.tar.xz |
772 |
+ test? ( https://releases.llvm.org/${PV/_//}/${LLVM_P}.tar.xz ) |
773 |
+ !doc? ( https://dev.gentoo.org/~mgorny/dist/llvm/llvm-${PV}-manpages.tar.bz2 )" |
774 |
+ |
775 |
+# Keep in sync with sys-devel/llvm |
776 |
+ALL_LLVM_TARGETS=( AArch64 AMDGPU ARM BPF Hexagon Lanai Mips MSP430 |
777 |
+ NVPTX PowerPC Sparc SystemZ X86 XCore ) |
778 |
+ALL_LLVM_TARGETS=( "${ALL_LLVM_TARGETS[@]/#/llvm_targets_}" ) |
779 |
+LLVM_TARGET_USEDEPS=${ALL_LLVM_TARGETS[@]/%/?} |
780 |
+ |
781 |
+LICENSE="UoI-NCSA" |
782 |
+SLOT="$(ver_cut 1)" |
783 |
+KEYWORDS="~amd64 ~arm64 ~x86 ~amd64-fbsd ~amd64-linux ~ppc-macos ~x64-macos ~x86-macos" |
784 |
+IUSE="debug default-compiler-rt default-libcxx doc hardened +static-analyzer |
785 |
+ test xml z3 kernel_FreeBSD ${ALL_LLVM_TARGETS[*]}" |
786 |
+RESTRICT="!test? ( test )" |
787 |
+ |
788 |
+RDEPEND=" |
789 |
+ ~sys-devel/llvm-${PV}:${SLOT}=[debug=,${LLVM_TARGET_USEDEPS// /,},${MULTILIB_USEDEP}] |
790 |
+ static-analyzer? ( |
791 |
+ dev-lang/perl:* |
792 |
+ z3? ( sci-mathematics/z3:0= ) |
793 |
+ ) |
794 |
+ xml? ( dev-libs/libxml2:2=[${MULTILIB_USEDEP}] ) |
795 |
+ ${PYTHON_DEPS}" |
796 |
+# configparser-3.2 breaks the build (3.3 or none at all are fine) |
797 |
+DEPEND="${RDEPEND} |
798 |
+ doc? ( dev-python/sphinx ) |
799 |
+ xml? ( virtual/pkgconfig ) |
800 |
+ !!<dev-python/configparser-3.3.0.2 |
801 |
+ ${PYTHON_DEPS}" |
802 |
+RDEPEND="${RDEPEND} |
803 |
+ !<sys-devel/llvm-4.0.0_rc:0 |
804 |
+ !sys-devel/clang:0" |
805 |
+PDEPEND=" |
806 |
+ sys-devel/clang-common |
807 |
+ ~sys-devel/clang-runtime-${PV} |
808 |
+ default-compiler-rt? ( =sys-libs/compiler-rt-${PV%_*}* ) |
809 |
+ default-libcxx? ( >=sys-libs/libcxx-${PV} )" |
810 |
+ |
811 |
+REQUIRED_USE="${PYTHON_REQUIRED_USE} |
812 |
+ || ( ${ALL_LLVM_TARGETS[*]} )" |
813 |
+ |
814 |
+# We need extra level of indirection for CLANG_RESOURCE_DIR |
815 |
+S=${WORKDIR}/x/y/${MY_P} |
816 |
+ |
817 |
+# least intrusive of all |
818 |
+CMAKE_BUILD_TYPE=RelWithDebInfo |
819 |
+ |
820 |
+PATCHES=( |
821 |
+ # add Prefix include paths for Darwin |
822 |
+ "${FILESDIR}"/5.0.1/darwin_prefix-include-paths.patch |
823 |
+ |
824 |
+ # fix Driver crash with CHOST prefix and long command-line |
825 |
+ # https://bugs.gentoo.org/650082 |
826 |
+ "${FILESDIR}"/6.0.0/0001-Driver-Avoid-invalidated-iterator-in-insertTargetAnd.patch |
827 |
+ # fix test failure with default-compiler-rt |
828 |
+ # https://bugs.gentoo.org/650316 |
829 |
+ "${FILESDIR}"/6.0.0/0002-test-Fix-Cross-DSO-CFI-Android-sanitizer-test-for-rt.patch |
830 |
+ |
831 |
+ # IsGentooLinux() is only used in hardened patches at the moment |
832 |
+ "${FILESDIR}"/6.0.0/0003-Add-Gentoo-Linux-distro.patch |
833 |
+) |
834 |
+HARDENED_PATCHES=( |
835 |
+ "${FILESDIR}"/6.0.0/hardened/0001-Use-z-relro-on-Gentoo.patch |
836 |
+ "${FILESDIR}"/6.0.0/hardened/0002-Enable-Stack-Protector-by-default.patch |
837 |
+ "${FILESDIR}"/6.0.0/hardened/0003-Enable-PIE-by-default.patch |
838 |
+ "${FILESDIR}"/6.0.0/hardened/0004-Enable-FORTIFY_SOURCE-macro-by-default.patch |
839 |
+ "${FILESDIR}"/6.0.0/hardened/0005-Link-with-z-now-by-default-for-Gentoo.patch |
840 |
+) |
841 |
+ |
842 |
+# Multilib notes: |
843 |
+# 1. ABI_* flags control ABIs libclang* is built for only. |
844 |
+# 2. clang is always capable of compiling code for all ABIs for enabled |
845 |
+# target. However, you will need appropriate crt* files (installed |
846 |
+# e.g. by sys-devel/gcc and sys-libs/glibc). |
847 |
+# 3. ${CHOST}-clang wrappers are always installed for all ABIs included |
848 |
+# in the current profile (i.e. alike supported by sys-devel/gcc). |
849 |
+# |
850 |
+# Therefore: use sys-devel/clang[${MULTILIB_USEDEP}] only if you need |
851 |
+# multilib clang* libraries (not runtime, not wrappers). |
852 |
+ |
853 |
+pkg_setup() { |
854 |
+ LLVM_MAX_SLOT=${SLOT} llvm_pkg_setup |
855 |
+ python-single-r1_pkg_setup |
856 |
+} |
857 |
+ |
858 |
+src_unpack() { |
859 |
+ # create extra parent dir for CLANG_RESOURCE_DIR |
860 |
+ mkdir -p x/y || die |
861 |
+ cd x/y || die |
862 |
+ |
863 |
+ einfo "Unpacking ${MY_P}.tar.xz ..." |
864 |
+ tar -xf "${DISTDIR}/${MY_P}.tar.xz" || die |
865 |
+ einfo "Unpacking ${EXTRA_P}.tar.xz ..." |
866 |
+ tar -xf "${DISTDIR}/${EXTRA_P}.tar.xz" || die |
867 |
+ |
868 |
+ mv "${EXTRA_P}" "${S}"/tools/extra || die |
869 |
+ if use test; then |
870 |
+ einfo "Unpacking parts of ${LLVM_P}.tar.xz ..." |
871 |
+ tar -xf "${DISTDIR}/${LLVM_P}.tar.xz" \ |
872 |
+ "${LLVM_P}"/utils/{lit,llvm-lit,unittest} || die |
873 |
+ mv "${LLVM_P}" "${WORKDIR}"/llvm || die |
874 |
+ fi |
875 |
+ |
876 |
+ if ! use doc; then |
877 |
+ einfo "Unpacking llvm-${PV}-manpages.tar.bz2 ..." |
878 |
+ tar -xf "${DISTDIR}/llvm-${PV}-manpages.tar.bz2" || die |
879 |
+ fi |
880 |
+} |
881 |
+ |
882 |
+src_prepare() { |
883 |
+ use hardened && eapply "${HARDENED_PATCHES[@]}" |
884 |
+ |
885 |
+ cmake-utils_src_prepare |
886 |
+ eprefixify lib/Frontend/InitHeaderSearch.cpp |
887 |
+} |
888 |
+ |
889 |
+multilib_src_configure() { |
890 |
+ local llvm_version=$(llvm-config --version) || die |
891 |
+ local clang_version=$(ver_cut 1-3 "${llvm_version}") |
892 |
+ |
893 |
+ local mycmakeargs=( |
894 |
+ # ensure that the correct llvm-config is used |
895 |
+ -DLLVM_CONFIG="$(type -P "${CHOST}-llvm-config")" |
896 |
+ -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr/lib/llvm/${SLOT}" |
897 |
+ -DCMAKE_INSTALL_MANDIR="${EPREFIX}/usr/lib/llvm/${SLOT}/share/man" |
898 |
+ # relative to bindir |
899 |
+ -DCLANG_RESOURCE_DIR="../../../../lib/clang/${clang_version}" |
900 |
+ |
901 |
+ -DBUILD_SHARED_LIBS=ON |
902 |
+ -DLLVM_TARGETS_TO_BUILD="${LLVM_TARGETS// /;}" |
903 |
+ -DLLVM_BUILD_TESTS=$(usex test) |
904 |
+ |
905 |
+ # these are not propagated reliably, so redefine them |
906 |
+ -DLLVM_ENABLE_EH=ON |
907 |
+ -DLLVM_ENABLE_RTTI=ON |
908 |
+ |
909 |
+ -DCMAKE_DISABLE_FIND_PACKAGE_LibXml2=$(usex !xml) |
910 |
+ # libgomp support fails to find headers without explicit -I |
911 |
+ # furthermore, it provides only syntax checking |
912 |
+ -DCLANG_DEFAULT_OPENMP_RUNTIME=libomp |
913 |
+ |
914 |
+ # override default stdlib and rtlib |
915 |
+ -DCLANG_DEFAULT_CXX_STDLIB=$(usex default-libcxx libc++ "") |
916 |
+ -DCLANG_DEFAULT_RTLIB=$(usex default-compiler-rt compiler-rt "") |
917 |
+ |
918 |
+ -DCLANG_ENABLE_ARCMT=$(usex static-analyzer) |
919 |
+ -DCLANG_ENABLE_STATIC_ANALYZER=$(usex static-analyzer) |
920 |
+ # z3 is not multilib-friendly |
921 |
+ -DCLANG_ANALYZER_BUILD_Z3=$(multilib_native_usex z3) |
922 |
+ ) |
923 |
+ use test && mycmakeargs+=( |
924 |
+ -DLLVM_MAIN_SRC_DIR="${WORKDIR}/llvm" |
925 |
+ -DLLVM_LIT_ARGS="-vv;-j;${LIT_JOBS:-$(makeopts_jobs "${MAKEOPTS}" "$(get_nproc)")}" |
926 |
+ ) |
927 |
+ |
928 |
+ if multilib_is_native_abi; then |
929 |
+ mycmakeargs+=( |
930 |
+ # normally copied from LLVM_INCLUDE_DOCS but the latter |
931 |
+ # is lacking value in stand-alone builds |
932 |
+ -DCLANG_INCLUDE_DOCS=$(usex doc) |
933 |
+ -DCLANG_TOOLS_EXTRA_INCLUDE_DOCS=$(usex doc) |
934 |
+ ) |
935 |
+ use doc && mycmakeargs+=( |
936 |
+ -DLLVM_BUILD_DOCS=ON |
937 |
+ -DLLVM_ENABLE_SPHINX=ON |
938 |
+ -DCLANG_INSTALL_SPHINX_HTML_DIR="${EPREFIX}/usr/share/doc/${PF}/html" |
939 |
+ -DCLANG-TOOLS_INSTALL_SPHINX_HTML_DIR="${EPREFIX}/usr/share/doc/${PF}/tools-extra" |
940 |
+ -DSPHINX_WARNINGS_AS_ERRORS=OFF |
941 |
+ ) |
942 |
+ use z3 && mycmakeargs+=( |
943 |
+ -DZ3_INCLUDE_DIR="${EPREFIX}/usr/include/z3" |
944 |
+ ) |
945 |
+ else |
946 |
+ mycmakeargs+=( |
947 |
+ -DLLVM_TOOL_CLANG_TOOLS_EXTRA_BUILD=OFF |
948 |
+ ) |
949 |
+ fi |
950 |
+ |
951 |
+ if [[ -n ${EPREFIX} ]]; then |
952 |
+ mycmakeargs+=( |
953 |
+ -DGCC_INSTALL_PREFIX="${EPREFIX}/usr" |
954 |
+ ) |
955 |
+ fi |
956 |
+ |
957 |
+ if tc-is-cross-compiler; then |
958 |
+ [[ -x "/usr/bin/clang-tblgen" ]] \ |
959 |
+ || die "/usr/bin/clang-tblgen not found or usable" |
960 |
+ mycmakeargs+=( |
961 |
+ -DCMAKE_CROSSCOMPILING=ON |
962 |
+ -DCLANG_TABLEGEN=/usr/bin/clang-tblgen |
963 |
+ ) |
964 |
+ fi |
965 |
+ |
966 |
+ # LLVM_ENABLE_ASSERTIONS=NO does not guarantee this for us, #614844 |
967 |
+ use debug || local -x CPPFLAGS="${CPPFLAGS} -DNDEBUG" |
968 |
+ cmake-utils_src_configure |
969 |
+} |
970 |
+ |
971 |
+multilib_src_compile() { |
972 |
+ cmake-utils_src_compile |
973 |
+ |
974 |
+ # provide a symlink for tests |
975 |
+ if [[ ! -L ${WORKDIR}/lib/clang ]]; then |
976 |
+ mkdir -p "${WORKDIR}"/lib || die |
977 |
+ ln -s "${BUILD_DIR}/$(get_libdir)/clang" "${WORKDIR}"/lib/clang || die |
978 |
+ fi |
979 |
+} |
980 |
+ |
981 |
+multilib_src_test() { |
982 |
+ # respect TMPDIR! |
983 |
+ local -x LIT_PRESERVES_TMP=1 |
984 |
+ cmake-utils_src_make check-clang |
985 |
+ multilib_is_native_abi && cmake-utils_src_make check-clang-tools |
986 |
+} |
987 |
+ |
988 |
+src_install() { |
989 |
+ MULTILIB_WRAPPED_HEADERS=( |
990 |
+ /usr/include/clang/Config/config.h |
991 |
+ ) |
992 |
+ |
993 |
+ multilib-minimal_src_install |
994 |
+ |
995 |
+ # Move runtime headers to /usr/lib/clang, where they belong |
996 |
+ mv "${ED%/}"/usr/include/clangrt "${ED%/}"/usr/lib/clang || die |
997 |
+ # move (remaining) wrapped headers back |
998 |
+ mv "${ED%/}"/usr/include "${ED%/}"/usr/lib/llvm/${SLOT}/include || die |
999 |
+ |
1000 |
+ # Apply CHOST and version suffix to clang tools |
1001 |
+ # note: we use two version components here (vs 3 in runtime path) |
1002 |
+ local llvm_version=$(llvm-config --version) || die |
1003 |
+ local clang_version=$(ver_cut 1-2 "${llvm_version}") |
1004 |
+ local clang_full_version=$(ver_cut 1-3 "${llvm_version}") |
1005 |
+ local clang_tools=( clang clang++ clang-cl clang-cpp ) |
1006 |
+ local abi i |
1007 |
+ |
1008 |
+ # cmake gives us: |
1009 |
+ # - clang-X.Y |
1010 |
+ # - clang -> clang-X.Y |
1011 |
+ # - clang++, clang-cl, clang-cpp -> clang |
1012 |
+ # we want to have: |
1013 |
+ # - clang-X.Y |
1014 |
+ # - clang++-X.Y, clang-cl-X.Y, clang-cpp-X.Y -> clang-X.Y |
1015 |
+ # - clang, clang++, clang-cl, clang-cpp -> clang*-X.Y |
1016 |
+ # also in CHOST variant |
1017 |
+ for i in "${clang_tools[@]:1}"; do |
1018 |
+ rm "${ED%/}/usr/lib/llvm/${SLOT}/bin/${i}" || die |
1019 |
+ dosym "clang-${clang_version}" "/usr/lib/llvm/${SLOT}/bin/${i}-${clang_version}" |
1020 |
+ dosym "${i}-${clang_version}" "/usr/lib/llvm/${SLOT}/bin/${i}" |
1021 |
+ done |
1022 |
+ |
1023 |
+ # now create target symlinks for all supported ABIs |
1024 |
+ for abi in $(get_all_abis); do |
1025 |
+ local abi_chost=$(get_abi_CHOST "${abi}") |
1026 |
+ for i in "${clang_tools[@]}"; do |
1027 |
+ dosym "${i}-${clang_version}" \ |
1028 |
+ "/usr/lib/llvm/${SLOT}/bin/${abi_chost}-${i}-${clang_version}" |
1029 |
+ dosym "${abi_chost}-${i}-${clang_version}" \ |
1030 |
+ "/usr/lib/llvm/${SLOT}/bin/${abi_chost}-${i}" |
1031 |
+ done |
1032 |
+ done |
1033 |
+ |
1034 |
+ # Remove unnecessary headers on FreeBSD, bug #417171 |
1035 |
+ if use kernel_FreeBSD; then |
1036 |
+ rm "${ED}"usr/lib/clang/${clang_full_version}/include/{std,float,iso,limits,tgmath,varargs}*.h || die |
1037 |
+ fi |
1038 |
+} |
1039 |
+ |
1040 |
+multilib_src_install() { |
1041 |
+ cmake-utils_src_install |
1042 |
+ |
1043 |
+ # move headers to /usr/include for wrapping & ABI mismatch checks |
1044 |
+ # (also drop the version suffix from runtime headers) |
1045 |
+ rm -rf "${ED%/}"/usr/include || die |
1046 |
+ mv "${ED%/}"/usr/lib/llvm/${SLOT}/include "${ED%/}"/usr/include || die |
1047 |
+ mv "${ED%/}"/usr/lib/llvm/${SLOT}/$(get_libdir)/clang "${ED%/}"/usr/include/clangrt || die |
1048 |
+} |
1049 |
+ |
1050 |
+multilib_src_install_all() { |
1051 |
+ python_fix_shebang "${ED}" |
1052 |
+ if use static-analyzer; then |
1053 |
+ python_optimize "${ED}"usr/lib/llvm/${SLOT}/share/scan-view |
1054 |
+ fi |
1055 |
+ |
1056 |
+ # install pre-generated manpages |
1057 |
+ if ! use doc; then |
1058 |
+ insinto "/usr/lib/llvm/${SLOT}/share/man/man1" |
1059 |
+ doins "${WORKDIR}/x/y/llvm-${PV}-manpages/clang"/*.1 |
1060 |
+ fi |
1061 |
+ |
1062 |
+ docompress "/usr/lib/llvm/${SLOT}/share/man" |
1063 |
+ # match 'html' non-compression |
1064 |
+ use doc && docompress -x "/usr/share/doc/${PF}/tools-extra" |
1065 |
+ # +x for some reason; TODO: investigate |
1066 |
+ use static-analyzer && fperms a-x "/usr/lib/llvm/${SLOT}/share/man/man1/scan-build.1" |
1067 |
+} |
1068 |
+ |
1069 |
+pkg_postinst() { |
1070 |
+ if [[ ${ROOT} == / && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then |
1071 |
+ eselect compiler-shadow update all |
1072 |
+ fi |
1073 |
+ |
1074 |
+ elog "You can find additional utility scripts in:" |
1075 |
+ elog " ${EROOT}/usr/lib/llvm/${SLOT}/share/clang" |
1076 |
+ elog "To use these scripts, you will need Python 2.7. Some of them are vim" |
1077 |
+ elog "integration scripts (with instructions inside). The run-clang-tidy.py" |
1078 |
+ elog "scripts requires the following additional package:" |
1079 |
+ elog " dev-python/pyyaml" |
1080 |
+} |
1081 |
+ |
1082 |
+pkg_postrm() { |
1083 |
+ if [[ ${ROOT} == / && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then |
1084 |
+ eselect compiler-shadow clean all |
1085 |
+ fi |
1086 |
+} |
1087 |
|
1088 |
diff --git a/sys-devel/clang/files/4.0.1/0001-Frontend-Correct-values-of-ATOMIC_-_LOCK_FREE-to-mat.patch b/sys-devel/clang/files/4.0.1/0001-Frontend-Correct-values-of-ATOMIC_-_LOCK_FREE-to-mat.patch |
1089 |
new file mode 100644 |
1090 |
index 0000000..f52d445 |
1091 |
--- /dev/null |
1092 |
+++ b/sys-devel/clang/files/4.0.1/0001-Frontend-Correct-values-of-ATOMIC_-_LOCK_FREE-to-mat.patch |
1093 |
@@ -0,0 +1,87 @@ |
1094 |
+From f1ea62e93cba334828c427146cc2ca7718a9ffb3 Mon Sep 17 00:00:00 2001 |
1095 |
+From: Michal Gorny <mgorny@g.o> |
1096 |
+Date: Mon, 9 Jan 2017 20:54:20 +0000 |
1097 |
+Subject: [PATCH] [Frontend] Correct values of ATOMIC_*_LOCK_FREE to match |
1098 |
+ builtin |
1099 |
+ |
1100 |
+Correct the logic used to set ATOMIC_*_LOCK_FREE preprocessor macros not |
1101 |
+to rely on the ABI alignment of types. Instead, just assume all those |
1102 |
+types are aligned correctly by default since clang uses safe alignment |
1103 |
+for _Atomic types even if the underlying types are aligned to a lower |
1104 |
+boundary by default. |
1105 |
+ |
1106 |
+For example, the 'long long' and 'double' types on x86 are aligned to |
1107 |
+32-bit boundary by default. However, '_Atomic long long' and '_Atomic |
1108 |
+double' are aligned to 64-bit boundary, therefore satisfying |
1109 |
+the requirements of lock-free atomic operations. |
1110 |
+ |
1111 |
+This fixes PR #19355 by correcting the value of |
1112 |
+__GCC_ATOMIC_LLONG_LOCK_FREE on x86, and therefore also fixing |
1113 |
+the assumption made in libc++ tests. This also fixes PR #30581 by |
1114 |
+applying a consistent logic between the functions used to implement |
1115 |
+both interfaces. |
1116 |
+ |
1117 |
+Differential Revision: https://reviews.llvm.org/D28213 |
1118 |
+ |
1119 |
+git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@291477 91177308-0d34-0410-b5e6-96231b3b80d8 |
1120 |
+--- |
1121 |
+ lib/Frontend/InitPreprocessor.cpp | 10 ++++------ |
1122 |
+ test/Sema/atomic-ops.c | 4 ---- |
1123 |
+ 2 files changed, 4 insertions(+), 10 deletions(-) |
1124 |
+ |
1125 |
+diff --git a/lib/Frontend/InitPreprocessor.cpp b/lib/Frontend/InitPreprocessor.cpp |
1126 |
+index 17603ada11..4502c92499 100644 |
1127 |
+--- a/lib/Frontend/InitPreprocessor.cpp |
1128 |
++++ b/lib/Frontend/InitPreprocessor.cpp |
1129 |
+@@ -286,12 +286,12 @@ static void DefineFastIntType(unsigned TypeWidth, bool IsSigned, |
1130 |
+ |
1131 |
+ /// Get the value the ATOMIC_*_LOCK_FREE macro should have for a type with |
1132 |
+ /// the specified properties. |
1133 |
+-static const char *getLockFreeValue(unsigned TypeWidth, unsigned TypeAlign, |
1134 |
+- unsigned InlineWidth) { |
1135 |
++static const char *getLockFreeValue(unsigned TypeWidth, unsigned InlineWidth) { |
1136 |
+ // Fully-aligned, power-of-2 sizes no larger than the inline |
1137 |
+ // width will be inlined as lock-free operations. |
1138 |
+- if (TypeWidth == TypeAlign && (TypeWidth & (TypeWidth - 1)) == 0 && |
1139 |
+- TypeWidth <= InlineWidth) |
1140 |
++ // Note: we do not need to check alignment since _Atomic(T) is always |
1141 |
++ // appropriately-aligned in clang. |
1142 |
++ if ((TypeWidth & (TypeWidth - 1)) == 0 && TypeWidth <= InlineWidth) |
1143 |
+ return "2"; // "always lock free" |
1144 |
+ // We cannot be certain what operations the lib calls might be |
1145 |
+ // able to implement as lock-free on future processors. |
1146 |
+@@ -881,7 +881,6 @@ static void InitializePredefinedMacros(const TargetInfo &TI, |
1147 |
+ #define DEFINE_LOCK_FREE_MACRO(TYPE, Type) \ |
1148 |
+ Builder.defineMacro("__GCC_ATOMIC_" #TYPE "_LOCK_FREE", \ |
1149 |
+ getLockFreeValue(TI.get##Type##Width(), \ |
1150 |
+- TI.get##Type##Align(), \ |
1151 |
+ InlineWidthBits)); |
1152 |
+ DEFINE_LOCK_FREE_MACRO(BOOL, Bool); |
1153 |
+ DEFINE_LOCK_FREE_MACRO(CHAR, Char); |
1154 |
+@@ -894,7 +893,6 @@ static void InitializePredefinedMacros(const TargetInfo &TI, |
1155 |
+ DEFINE_LOCK_FREE_MACRO(LLONG, LongLong); |
1156 |
+ Builder.defineMacro("__GCC_ATOMIC_POINTER_LOCK_FREE", |
1157 |
+ getLockFreeValue(TI.getPointerWidth(0), |
1158 |
+- TI.getPointerAlign(0), |
1159 |
+ InlineWidthBits)); |
1160 |
+ #undef DEFINE_LOCK_FREE_MACRO |
1161 |
+ } |
1162 |
+diff --git a/test/Sema/atomic-ops.c b/test/Sema/atomic-ops.c |
1163 |
+index 8ebf3eaed4..d3ebdf67db 100644 |
1164 |
+--- a/test/Sema/atomic-ops.c |
1165 |
++++ b/test/Sema/atomic-ops.c |
1166 |
+@@ -14,11 +14,7 @@ _Static_assert(__GCC_ATOMIC_WCHAR_T_LOCK_FREE == 2, ""); |
1167 |
+ _Static_assert(__GCC_ATOMIC_SHORT_LOCK_FREE == 2, ""); |
1168 |
+ _Static_assert(__GCC_ATOMIC_INT_LOCK_FREE == 2, ""); |
1169 |
+ _Static_assert(__GCC_ATOMIC_LONG_LOCK_FREE == 2, ""); |
1170 |
+-#ifdef __i386__ |
1171 |
+-_Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 1, ""); |
1172 |
+-#else |
1173 |
+ _Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 2, ""); |
1174 |
+-#endif |
1175 |
+ _Static_assert(__GCC_ATOMIC_POINTER_LOCK_FREE == 2, ""); |
1176 |
+ |
1177 |
+ _Static_assert(__c11_atomic_is_lock_free(1), ""); |
1178 |
+-- |
1179 |
+2.12.0 |
1180 |
+ |
1181 |
|
1182 |
diff --git a/sys-devel/clang/files/4.0.1/0002-cmake-Support-stand-alone-Sphinx-doxygen-doc-build.patch b/sys-devel/clang/files/4.0.1/0002-cmake-Support-stand-alone-Sphinx-doxygen-doc-build.patch |
1183 |
new file mode 100644 |
1184 |
index 0000000..0ecd5bc |
1185 |
--- /dev/null |
1186 |
+++ b/sys-devel/clang/files/4.0.1/0002-cmake-Support-stand-alone-Sphinx-doxygen-doc-build.patch |
1187 |
@@ -0,0 +1,64 @@ |
1188 |
+From 8dd12df445c9a35f7b1c0202eb7c74b954b0980d Mon Sep 17 00:00:00 2001 |
1189 |
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@g.o> |
1190 |
+Date: Sun, 21 Aug 2016 23:31:55 +0200 |
1191 |
+Subject: [PATCH 7/7] cmake: Support stand-alone Sphinx & doxygen doc build |
1192 |
+ |
1193 |
+Copy the necessary options and configuration checks from LLVM to clang, |
1194 |
+to support stand-alone documentation builds. |
1195 |
+ |
1196 |
+Patch: https://reviews.llvm.org/D23758 |
1197 |
+--- |
1198 |
+ CMakeLists.txt | 37 +++++++++++++++++++++++++++++++++++++ |
1199 |
+ 1 file changed, 37 insertions(+) |
1200 |
+ |
1201 |
+diff --git a/CMakeLists.txt b/CMakeLists.txt |
1202 |
+index 8ed8c10..3f34d8c 100644 |
1203 |
+--- a/CMakeLists.txt |
1204 |
++++ b/CMakeLists.txt |
1205 |
+@@ -162,6 +162,43 @@ Please install Python or specify the PYTHON_EXECUTABLE CMake variable.") |
1206 |
+ endif() |
1207 |
+ endif() |
1208 |
+ |
1209 |
++ option (LLVM_BUILD_DOCS "Build the llvm documentation." OFF) |
1210 |
++ option (LLVM_INCLUDE_DOCS "Generate build targets for llvm documentation." ON) |
1211 |
++ option (LLVM_ENABLE_DOXYGEN "Use doxygen to generate llvm API documentation." OFF) |
1212 |
++ option (LLVM_ENABLE_SPHINX "Use Sphinx to generate llvm documentation." OFF) |
1213 |
++ |
1214 |
++ if (LLVM_ENABLE_DOXYGEN) |
1215 |
++ message(STATUS "Doxygen enabled.") |
1216 |
++ find_package(Doxygen REQUIRED) |
1217 |
++ |
1218 |
++ if (DOXYGEN_FOUND) |
1219 |
++ # If we find doxygen and we want to enable doxygen by default create a |
1220 |
++ # global aggregate doxygen target for generating llvm and any/all |
1221 |
++ # subprojects doxygen documentation. |
1222 |
++ if (LLVM_BUILD_DOCS) |
1223 |
++ add_custom_target(doxygen ALL) |
1224 |
++ endif() |
1225 |
++ |
1226 |
++ option(LLVM_DOXYGEN_EXTERNAL_SEARCH "Enable doxygen external search." OFF) |
1227 |
++ if (LLVM_DOXYGEN_EXTERNAL_SEARCH) |
1228 |
++ set(LLVM_DOXYGEN_SEARCHENGINE_URL "" CACHE STRING "URL to use for external search.") |
1229 |
++ set(LLVM_DOXYGEN_SEARCH_MAPPINGS "" CACHE STRING "Doxygen Search Mappings") |
1230 |
++ endif() |
1231 |
++ endif() |
1232 |
++ else() |
1233 |
++ message(STATUS "Doxygen disabled.") |
1234 |
++ endif() |
1235 |
++ |
1236 |
++ if (LLVM_ENABLE_SPHINX) |
1237 |
++ message(STATUS "Sphinx enabled.") |
1238 |
++ find_package(Sphinx REQUIRED) |
1239 |
++ if (LLVM_BUILD_DOCS) |
1240 |
++ add_custom_target(sphinx ALL) |
1241 |
++ endif() |
1242 |
++ else() |
1243 |
++ message(STATUS "Sphinx disabled.") |
1244 |
++ endif() |
1245 |
++ |
1246 |
+ set( CLANG_BUILT_STANDALONE 1 ) |
1247 |
+ set(BACKEND_PACKAGE_STRING "LLVM ${LLVM_PACKAGE_VERSION}") |
1248 |
+ else() |
1249 |
+-- |
1250 |
+2.9.3 |
1251 |
+ |
1252 |
|
1253 |
diff --git a/sys-devel/clang/files/4.0.1/0003-Add-Gentoo-Linux-distro.patch b/sys-devel/clang/files/4.0.1/0003-Add-Gentoo-Linux-distro.patch |
1254 |
new file mode 100644 |
1255 |
index 0000000..eb85ba5 |
1256 |
--- /dev/null |
1257 |
+++ b/sys-devel/clang/files/4.0.1/0003-Add-Gentoo-Linux-distro.patch |
1258 |
@@ -0,0 +1,32 @@ |
1259 |
+--- a/include/clang/Driver/Distro.h |
1260 |
++++ b/include/clang/Driver/Distro.h |
1261 |
+@@ -26,6 +26,7 @@ |
1262 |
+ // NB: Releases of a particular Linux distro should be kept together |
1263 |
+ // in this enum, because some tests are done by integer comparison against |
1264 |
+ // the first and last known member in the family, e.g. IsRedHat(). |
1265 |
++ GentooLinux, |
1266 |
+ ArchLinux, |
1267 |
+ DebianLenny, |
1268 |
+ DebianSqueeze, |
1269 |
+@@ -97,6 +98,10 @@ |
1270 |
+ /// @name Convenience Predicates |
1271 |
+ /// @{ |
1272 |
+ |
1273 |
++ bool IsGentooLinux() const { |
1274 |
++ return DistroVal == GentooLinux; |
1275 |
++ } |
1276 |
++ |
1277 |
+ bool IsRedhat() const { |
1278 |
+ return DistroVal == Fedora || (DistroVal >= RHEL5 && DistroVal <= RHEL7); |
1279 |
+ } |
1280 |
+--- a/lib/Driver/Distro.cpp |
1281 |
++++ b/lib/Driver/Distro.cpp |
1282 |
+@@ -128,6 +128,9 @@ |
1283 |
+ if (VFS.exists("/etc/arch-release")) |
1284 |
+ return Distro::ArchLinux; |
1285 |
+ |
1286 |
++ if (VFS.exists("/etc/gentoo-release")) |
1287 |
++ return Distro::GentooLinux; |
1288 |
++ |
1289 |
+ return Distro::UnknownDistro; |
1290 |
+ } |
1291 |
|
1292 |
diff --git a/sys-devel/clang/files/4.0.1/extra/0001-test-Fix-test-dependencies-when-using-installed-tool.patch b/sys-devel/clang/files/4.0.1/extra/0001-test-Fix-test-dependencies-when-using-installed-tool.patch |
1293 |
new file mode 100644 |
1294 |
index 0000000..3779bc6 |
1295 |
--- /dev/null |
1296 |
+++ b/sys-devel/clang/files/4.0.1/extra/0001-test-Fix-test-dependencies-when-using-installed-tool.patch |
1297 |
@@ -0,0 +1,48 @@ |
1298 |
+From f1355920fbe819c5b1f5a870fc76cffcdd6328f0 Mon Sep 17 00:00:00 2001 |
1299 |
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@g.o> |
1300 |
+Date: Fri, 10 Feb 2017 22:44:53 +0100 |
1301 |
+Subject: [PATCH 1/2] [test] Fix test dependencies when using installed tools |
1302 |
+ |
1303 |
+Use the LLVM_UTILS_PROVIDED variable to determine whether test tool |
1304 |
+dependencies should be exposed for clang-tools-extra tests. If clang is |
1305 |
+being built stand-alone and LLVM test tools (FileCheck, count and not) |
1306 |
+are installed, the top-level CMakeLists.txt of clang sets this variable |
1307 |
+to indicate that they will not be built as a part of this build, |
1308 |
+and therefore no dependencies should be emitted for them. This fixes |
1309 |
+the dependency errors when building clang stand-alone with tests |
1310 |
+enabled. |
1311 |
+--- |
1312 |
+ test/CMakeLists.txt | 10 +++++++--- |
1313 |
+ 1 file changed, 7 insertions(+), 3 deletions(-) |
1314 |
+ |
1315 |
+diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt |
1316 |
+index a852ef60..c26bd5c4 100644 |
1317 |
+--- a/test/CMakeLists.txt |
1318 |
++++ b/test/CMakeLists.txt |
1319 |
+@@ -31,9 +31,6 @@ if(CLANG_TOOLS_TEST_USE_VG) |
1320 |
+ endif() |
1321 |
+ |
1322 |
+ set(CLANG_TOOLS_TEST_DEPS |
1323 |
+- # Base line deps. |
1324 |
+- FileCheck count not |
1325 |
+- |
1326 |
+ # clang-tidy tests require it. |
1327 |
+ clang-headers |
1328 |
+ |
1329 |
+@@ -58,6 +55,13 @@ set(CLANG_TOOLS_TEST_DEPS |
1330 |
+ ExtraToolsUnitTests |
1331 |
+ ) |
1332 |
+ |
1333 |
++if(NOT LLVM_UTILS_PROVIDED) |
1334 |
++ list(APPEND CLANG_TOOLS_TEST_DEPS |
1335 |
++ # Base line deps. |
1336 |
++ FileCheck count not |
1337 |
++ ) |
1338 |
++endif() |
1339 |
++ |
1340 |
+ add_lit_testsuite(check-clang-tools "Running the Clang extra tools' regression tests" |
1341 |
+ ${CMAKE_CURRENT_BINARY_DIR} |
1342 |
+ DEPENDS ${CLANG_TOOLS_TEST_DEPS} |
1343 |
+-- |
1344 |
+2.12.0 |
1345 |
+ |
1346 |
|
1347 |
diff --git a/sys-devel/clang/files/4.0.1/extra/0002-test-Fix-clang-library-dir-in-LD_LIBRARY_PATH-For-st.patch b/sys-devel/clang/files/4.0.1/extra/0002-test-Fix-clang-library-dir-in-LD_LIBRARY_PATH-For-st.patch |
1348 |
new file mode 100644 |
1349 |
index 0000000..22f6d56 |
1350 |
--- /dev/null |
1351 |
+++ b/sys-devel/clang/files/4.0.1/extra/0002-test-Fix-clang-library-dir-in-LD_LIBRARY_PATH-For-st.patch |
1352 |
@@ -0,0 +1,83 @@ |
1353 |
+From f3ff810e81c35133f6a7e463d860bcd4ca30be84 Mon Sep 17 00:00:00 2001 |
1354 |
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@g.o> |
1355 |
+Date: Sun, 19 Feb 2017 12:13:04 +0100 |
1356 |
+Subject: [PATCH 2/2] [test] Fix clang library dir in LD_LIBRARY_PATH For |
1357 |
+ stand-alone build |
1358 |
+ |
1359 |
+Prepend the clang library directory (determined using SHLIBDIR, alike |
1360 |
+in clang) to the LD_LIBRARY_PATH to ensure that just-built clang |
1361 |
+libraries will be used instead of a previous installed version. |
1362 |
+ |
1363 |
+When a stand-alone build is performed, LLVM_LIBS_DIR contains the path |
1364 |
+to installed LLVM library directory. The same directory frequently |
1365 |
+contains a previously installed version of clang. SHLIBDIR, on the other |
1366 |
+hand, is always the build-tree directory, and therefore contains |
1367 |
+the freshly built clang libraries. |
1368 |
+ |
1369 |
+In a non-stand-alone build, both paths will be the same and therefore |
1370 |
+including them both will not cause any issues. |
1371 |
+--- |
1372 |
+ test/Unit/lit.cfg | 9 ++++++--- |
1373 |
+ test/lit.cfg | 5 ++++- |
1374 |
+ test/lit.site.cfg.in | 1 + |
1375 |
+ 3 files changed, 11 insertions(+), 4 deletions(-) |
1376 |
+ |
1377 |
+diff --git a/test/Unit/lit.cfg b/test/Unit/lit.cfg |
1378 |
+index ff70123c..3a1da187 100644 |
1379 |
+--- a/test/Unit/lit.cfg |
1380 |
++++ b/test/Unit/lit.cfg |
1381 |
+@@ -41,14 +41,17 @@ elif platform.system() == 'Windows': |
1382 |
+ shlibpath_var = 'PATH' |
1383 |
+ |
1384 |
+ # Point the dynamic loader at dynamic libraries in 'lib'. |
1385 |
++shlibdir = getattr(config, 'shlibdir', None) |
1386 |
++if not shlibdir: |
1387 |
++ lit_config.fatal('No shlibdir set!') |
1388 |
+ llvm_libs_dir = getattr(config, 'llvm_libs_dir', None) |
1389 |
+ if not llvm_libs_dir: |
1390 |
+ lit_config.fatal('No LLVM libs dir set!') |
1391 |
+-shlibpath = os.path.pathsep.join((llvm_libs_dir, |
1392 |
++shlibpath = os.path.pathsep.join((shlibdir, llvm_libs_dir, |
1393 |
+ config.environment.get(shlibpath_var,''))) |
1394 |
+ |
1395 |
+ # Win32 seeks DLLs along %PATH%. |
1396 |
+-if sys.platform in ['win32', 'cygwin'] and os.path.isdir(config.shlibdir): |
1397 |
+- shlibpath = os.path.pathsep.join((config.shlibdir, shlibpath)) |
1398 |
++if sys.platform in ['win32', 'cygwin'] and os.path.isdir(shlibdir): |
1399 |
++ shlibpath = os.path.pathsep.join((shlibdir, shlibpath)) |
1400 |
+ |
1401 |
+ config.environment[shlibpath_var] = shlibpath |
1402 |
+diff --git a/test/lit.cfg b/test/lit.cfg |
1403 |
+index bb592936..0e7de849 100644 |
1404 |
+--- a/test/lit.cfg |
1405 |
++++ b/test/lit.cfg |
1406 |
+@@ -99,10 +99,13 @@ if clang_tools_binary_dir is not None: |
1407 |
+ clang_tools_dir, llvm_tools_dir, config.environment['PATH'])) |
1408 |
+ config.environment['PATH'] = path |
1409 |
+ |
1410 |
++ clang_libs_dir = getattr(config, 'clang_libs_dir', None) |
1411 |
++ if not clang_libs_dir: |
1412 |
++ lit_config.fatal('No Clang libs dir set!') |
1413 |
+ llvm_libs_dir = getattr(config, 'llvm_libs_dir', None) |
1414 |
+ if not llvm_libs_dir: |
1415 |
+ lit_config.fatal('No LLVM libs dir set!') |
1416 |
+- path = os.path.pathsep.join((llvm_libs_dir, |
1417 |
++ path = os.path.pathsep.join((clang_libs_dir, llvm_libs_dir, |
1418 |
+ config.environment.get('LD_LIBRARY_PATH',''))) |
1419 |
+ config.environment['LD_LIBRARY_PATH'] = path |
1420 |
+ |
1421 |
+diff --git a/test/lit.site.cfg.in b/test/lit.site.cfg.in |
1422 |
+index dfd0164c..f310b59a 100644 |
1423 |
+--- a/test/lit.site.cfg.in |
1424 |
++++ b/test/lit.site.cfg.in |
1425 |
+@@ -7,6 +7,7 @@ config.llvm_libs_dir = "@LLVM_LIBS_DIR@" |
1426 |
+ config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@" |
1427 |
+ config.clang_tools_binary_dir = "@CLANG_TOOLS_BINARY_DIR@" |
1428 |
+ config.clang_tools_dir = "@CLANG_TOOLS_DIR@" |
1429 |
++config.clang_libs_dir = "@SHLIBDIR@" |
1430 |
+ config.python_executable = "@PYTHON_EXECUTABLE@" |
1431 |
+ config.target_triple = "@TARGET_TRIPLE@" |
1432 |
+ |
1433 |
+-- |
1434 |
+2.12.0 |
1435 |
+ |
1436 |
|
1437 |
diff --git a/sys-devel/clang/files/4.0.1/hardened/0001-Use-z-relro-on-Gentoo.patch b/sys-devel/clang/files/4.0.1/hardened/0001-Use-z-relro-on-Gentoo.patch |
1438 |
new file mode 100644 |
1439 |
index 0000000..93e7c6a |
1440 |
--- /dev/null |
1441 |
+++ b/sys-devel/clang/files/4.0.1/hardened/0001-Use-z-relro-on-Gentoo.patch |
1442 |
@@ -0,0 +1,11 @@ |
1443 |
+--- a/lib/Driver/ToolChains.cpp |
1444 |
++++ b/lib/Driver/ToolChains.cpp |
1445 |
+@@ -4112,7 +4112,7 @@ |
1446 |
+ |
1447 |
+ Distro Distro(D.getVFS()); |
1448 |
+ |
1449 |
+- if (Distro.IsOpenSUSE() || Distro.IsUbuntu()) { |
1450 |
++ if (Distro.IsOpenSUSE() || Distro.IsUbuntu() || Distro.IsGentooLinux()) { |
1451 |
+ ExtraOpts.push_back("-z"); |
1452 |
+ ExtraOpts.push_back("relro"); |
1453 |
+ } |
1454 |
|
1455 |
diff --git a/sys-devel/clang/files/4.0.1/hardened/0002-Enable-Stack-Protector-by-default.patch b/sys-devel/clang/files/4.0.1/hardened/0002-Enable-Stack-Protector-by-default.patch |
1456 |
new file mode 100644 |
1457 |
index 0000000..13ac645 |
1458 |
--- /dev/null |
1459 |
+++ b/sys-devel/clang/files/4.0.1/hardened/0002-Enable-Stack-Protector-by-default.patch |
1460 |
@@ -0,0 +1,23 @@ |
1461 |
+--- a/lib/Driver/ToolChains.cpp |
1462 |
++++ b/lib/Driver/ToolChains.cpp |
1463 |
+@@ -4866,6 +4866,10 @@ |
1464 |
+ CmdArgs.push_back("-lunwind"); |
1465 |
+ } |
1466 |
+ |
1467 |
++unsigned Linux::GetDefaultStackProtectorLevel(bool KernelOrKext) const { |
1468 |
++ return 2; |
1469 |
++} |
1470 |
++ |
1471 |
+ /// DragonFly - DragonFly tool chain which can call as(1) and ld(1) directly. |
1472 |
+ |
1473 |
+ DragonFly::DragonFly(const Driver &D, const llvm::Triple &Triple, |
1474 |
+--- a/lib/Driver/ToolChains.h |
1475 |
++++ b/lib/Driver/ToolChains.h |
1476 |
+@@ -880,6 +880,7 @@ |
1477 |
+ void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs, |
1478 |
+ llvm::opt::ArgStringList &CC1Args) const override; |
1479 |
+ bool isPIEDefault() const override; |
1480 |
++ unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override; |
1481 |
+ SanitizerMask getSupportedSanitizers() const override; |
1482 |
+ void addProfileRTLibs(const llvm::opt::ArgList &Args, |
1483 |
+ llvm::opt::ArgStringList &CmdArgs) const override; |
1484 |
|
1485 |
diff --git a/sys-devel/clang/files/4.0.1/hardened/0003-Enable-PIE-by-default.patch b/sys-devel/clang/files/4.0.1/hardened/0003-Enable-PIE-by-default.patch |
1486 |
new file mode 100644 |
1487 |
index 0000000..e1908bc |
1488 |
--- /dev/null |
1489 |
+++ b/sys-devel/clang/files/4.0.1/hardened/0003-Enable-PIE-by-default.patch |
1490 |
@@ -0,0 +1,26 @@ |
1491 |
+--- a/lib/Driver/ToolChains.cpp |
1492 |
++++ b/lib/Driver/ToolChains.cpp |
1493 |
+@@ -4721,7 +4721,9 @@ |
1494 |
+ } |
1495 |
+ } |
1496 |
+ |
1497 |
+-bool Linux::isPIEDefault() const { return getSanitizerArgs().requiresPIE(); } |
1498 |
++bool Linux::isPIEDefault() const { |
1499 |
++ return true; |
1500 |
++} |
1501 |
+ |
1502 |
+ SanitizerMask Linux::getSupportedSanitizers() const { |
1503 |
+ const bool IsX86 = getTriple().getArch() == llvm::Triple::x86; |
1504 |
+--- a/lib/Driver/Tools.cpp |
1505 |
++++ b/lib/Driver/Tools.cpp |
1506 |
+@@ -9258,7 +9258,9 @@ |
1507 |
+ if (!D.SysRoot.empty()) |
1508 |
+ CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot)); |
1509 |
+ |
1510 |
+- if (IsPIE) |
1511 |
++ if (Args.hasArg(options::OPT_nopie)) |
1512 |
++ CmdArgs.push_back("-nopie"); |
1513 |
++ else if (IsPIE) |
1514 |
+ CmdArgs.push_back("-pie"); |
1515 |
+ |
1516 |
+ CmdArgs.push_back("--eh-frame-hdr"); |
1517 |
|
1518 |
diff --git a/sys-devel/clang/files/4.0.1/hardened/0004-Link-with-z-now-by-default-for-Gentoo.patch b/sys-devel/clang/files/4.0.1/hardened/0004-Link-with-z-now-by-default-for-Gentoo.patch |
1519 |
new file mode 100644 |
1520 |
index 0000000..b404db5 |
1521 |
--- /dev/null |
1522 |
+++ b/sys-devel/clang/files/4.0.1/hardened/0004-Link-with-z-now-by-default-for-Gentoo.patch |
1523 |
@@ -0,0 +1,14 @@ |
1524 |
+--- a/lib/Driver/ToolChains.cpp |
1525 |
++++ b/lib/Driver/ToolChains.cpp |
1526 |
+@@ -4112,6 +4112,11 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) |
1527 |
+ |
1528 |
+ Distro Distro(D.getVFS()); |
1529 |
+ |
1530 |
++ if (Distro.IsGentooLinux()) { |
1531 |
++ ExtraOpts.push_back("-z"); |
1532 |
++ ExtraOpts.push_back("now"); |
1533 |
++ } |
1534 |
++ |
1535 |
+ if (Distro.IsOpenSUSE() || Distro.IsUbuntu() || Distro.IsGentooLinux()) { |
1536 |
+ ExtraOpts.push_back("-z"); |
1537 |
+ ExtraOpts.push_back("relro"); |
1538 |
|
1539 |
diff --git a/sys-devel/clang/files/5.0.1/0001-Driver-Use-arch-type-to-find-compiler-rt-libraries-o.patch b/sys-devel/clang/files/5.0.1/0001-Driver-Use-arch-type-to-find-compiler-rt-libraries-o.patch |
1540 |
new file mode 100644 |
1541 |
index 0000000..7d53cbd |
1542 |
--- /dev/null |
1543 |
+++ b/sys-devel/clang/files/5.0.1/0001-Driver-Use-arch-type-to-find-compiler-rt-libraries-o.patch |
1544 |
@@ -0,0 +1,136 @@ |
1545 |
+From 19e3dc0ce4949cc7f869b4552c6a7f28cd59c3b7 Mon Sep 17 00:00:00 2001 |
1546 |
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@g.o> |
1547 |
+Date: Thu, 17 Nov 2016 14:19:18 +0100 |
1548 |
+Subject: [PATCH] [Driver] Use arch type to find compiler-rt libraries (on |
1549 |
+ Linux) |
1550 |
+ |
1551 |
+Use llvm::Triple::getArchTypeName() when looking for compiler-rt |
1552 |
+libraries, rather than the exact arch string from the triple. This is |
1553 |
+more correct as it matches the values used when building compiler-rt |
1554 |
+(builtin-config-ix.cmake) which are the subset of the values allowed |
1555 |
+in triples. |
1556 |
+ |
1557 |
+For example, this fixes an issue when the compiler set for |
1558 |
+i686-pc-linux-gnu triple would not find an i386 compiler-rt library, |
1559 |
+while this is the exact arch that is detected by compiler-rt. The same |
1560 |
+applies to any other i?86 variant allowed by LLVM. |
1561 |
+ |
1562 |
+This also makes the special case for MSVC unnecessary, since now i386 |
1563 |
+will be used reliably for all 32-bit x86 variants. |
1564 |
+--- |
1565 |
+ lib/Driver/ToolChain.cpp | 5 +---- |
1566 |
+ .../usr/i686-unknown-linux/lib/.keep | 0 |
1567 |
+ .../usr/lib/gcc/i686-unknown-linux/4.6.0/crtbegin.o | 0 |
1568 |
+ test/Driver/linux-ld.c | 21 +++++++++++++++++++++ |
1569 |
+ test/Driver/nostdlib.c | 2 +- |
1570 |
+ test/Driver/print-libgcc-file-name-clangrt.c | 10 ++++++++-- |
1571 |
+ test/Driver/windows-cross.c | 2 +- |
1572 |
+ 7 files changed, 32 insertions(+), 8 deletions(-) |
1573 |
+ create mode 100644 test/Driver/Inputs/basic_linux_tree/usr/i686-unknown-linux/lib/.keep |
1574 |
+ create mode 100644 test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/i686-unknown-linux/4.6.0/crtbegin.o |
1575 |
+ |
1576 |
+diff --git a/lib/Driver/ToolChain.cpp b/lib/Driver/ToolChain.cpp |
1577 |
+index 6adc0386ee..7e4222f087 100644 |
1578 |
+--- a/lib/Driver/ToolChain.cpp |
1579 |
++++ b/lib/Driver/ToolChain.cpp |
1580 |
+@@ -283,15 +283,12 @@ static StringRef getArchNameForCompilerRTLib(const ToolChain &TC, |
1581 |
+ const llvm::Triple &Triple = TC.getTriple(); |
1582 |
+ bool IsWindows = Triple.isOSWindows(); |
1583 |
+ |
1584 |
+- if (Triple.isWindowsMSVCEnvironment() && TC.getArch() == llvm::Triple::x86) |
1585 |
+- return "i386"; |
1586 |
+- |
1587 |
+ if (TC.getArch() == llvm::Triple::arm || TC.getArch() == llvm::Triple::armeb) |
1588 |
+ return (arm::getARMFloatABI(TC, Args) == arm::FloatABI::Hard && !IsWindows) |
1589 |
+ ? "armhf" |
1590 |
+ : "arm"; |
1591 |
+ |
1592 |
+- return TC.getArchName(); |
1593 |
++ return llvm::Triple::getArchTypeName(TC.getArch()); |
1594 |
+ } |
1595 |
+ |
1596 |
+ std::string ToolChain::getCompilerRT(const ArgList &Args, StringRef Component, |
1597 |
+diff --git a/test/Driver/Inputs/basic_linux_tree/usr/i686-unknown-linux/lib/.keep b/test/Driver/Inputs/basic_linux_tree/usr/i686-unknown-linux/lib/.keep |
1598 |
+new file mode 100644 |
1599 |
+index 0000000000..e69de29bb2 |
1600 |
+diff --git a/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/i686-unknown-linux/4.6.0/crtbegin.o b/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/i686-unknown-linux/4.6.0/crtbegin.o |
1601 |
+new file mode 100644 |
1602 |
+index 0000000000..e69de29bb2 |
1603 |
+diff --git a/test/Driver/linux-ld.c b/test/Driver/linux-ld.c |
1604 |
+index e5aa870866..92b199b9d4 100644 |
1605 |
+--- a/test/Driver/linux-ld.c |
1606 |
++++ b/test/Driver/linux-ld.c |
1607 |
+@@ -71,6 +71,27 @@ |
1608 |
+ // CHECK-LD-RT: libclang_rt.builtins-x86_64.a" |
1609 |
+ // |
1610 |
+ // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ |
1611 |
++// RUN: --target=i686-unknown-linux \ |
1612 |
++// RUN: --gcc-toolchain="" \ |
1613 |
++// RUN: --sysroot=%S/Inputs/basic_linux_tree \ |
1614 |
++// RUN: --rtlib=compiler-rt \ |
1615 |
++// RUN: | FileCheck --check-prefix=CHECK-LD-RT-I686 %s |
1616 |
++// CHECK-LD-RT-I686-NOT: warning: |
1617 |
++// CHECK-LD-RT-I686: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" |
1618 |
++// CHECK-LD-RT-I686: "--eh-frame-hdr" |
1619 |
++// CHECK-LD-RT-I686: "-m" "elf_i386" |
1620 |
++// CHECK-LD-RT-I686: "-dynamic-linker" |
1621 |
++// CHECK-LD-RT-I686: "{{.*}}/usr/lib/gcc/i686-unknown-linux/4.6.0{{/|\\\\}}crtbegin.o" |
1622 |
++// CHECK-LD-RT-I686: "-L[[SYSROOT]]/usr/lib/gcc/i686-unknown-linux/4.6.0" |
1623 |
++// CHECK-LD-RT-I686: "-L[[SYSROOT]]/usr/lib/gcc/i686-unknown-linux/4.6.0/../../../../i686-unknown-linux/lib" |
1624 |
++// CHECK-LD-RT-I686: "-L[[SYSROOT]]/usr/lib/gcc/i686-unknown-linux/4.6.0/../../.." |
1625 |
++// CHECK-LD-RT-I686: "-L[[SYSROOT]]/lib" |
1626 |
++// CHECK-LD-RT-I686: "-L[[SYSROOT]]/usr/lib" |
1627 |
++// CHECK-LD-RT-I686: libclang_rt.builtins-i386.a" |
1628 |
++// CHECK-LD-RT-I686: "-lc" |
1629 |
++// CHECK-LD-RT-I686: libclang_rt.builtins-i386.a" |
1630 |
++// |
1631 |
++// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ |
1632 |
+ // RUN: --target=arm-linux-androideabi \ |
1633 |
+ // RUN: --gcc-toolchain="" \ |
1634 |
+ // RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \ |
1635 |
+diff --git a/test/Driver/nostdlib.c b/test/Driver/nostdlib.c |
1636 |
+index a9ef665c57..c9793d968c 100644 |
1637 |
+--- a/test/Driver/nostdlib.c |
1638 |
++++ b/test/Driver/nostdlib.c |
1639 |
+@@ -27,5 +27,5 @@ |
1640 |
+ // |
1641 |
+ // CHECK-LINUX-NOSTDLIB: warning: argument unused during compilation: '--rtlib=compiler-rt' |
1642 |
+ // CHECK-LINUX-NOSTDLIB: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}" |
1643 |
+-// CHECK-LINUX-NOSTDLIB-NOT: "{{.*}}/Inputs/resource_dir{{/|\\\\}}lib{{/|\\\\}}linux{{/|\\\\}}libclang_rt.builtins-i686.a" |
1644 |
++// CHECK-LINUX-NOSTDLIB-NOT: "{{.*}}/Inputs/resource_dir{{/|\\\\}}lib{{/|\\\\}}linux{{/|\\\\}}libclang_rt.builtins-i386.a" |
1645 |
+ // CHECK-MSVC-NOSTDLIB: warning: argument unused during compilation: '--rtlib=compiler-rt' |
1646 |
+diff --git a/test/Driver/print-libgcc-file-name-clangrt.c b/test/Driver/print-libgcc-file-name-clangrt.c |
1647 |
+index 9f8120c31d..28c758881d 100644 |
1648 |
+--- a/test/Driver/print-libgcc-file-name-clangrt.c |
1649 |
++++ b/test/Driver/print-libgcc-file-name-clangrt.c |
1650 |
+@@ -6,6 +6,12 @@ |
1651 |
+ // CHECK-CLANGRT-X8664: libclang_rt.builtins-x86_64.a |
1652 |
+ |
1653 |
+ // RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \ |
1654 |
++// RUN: --target=i386-pc-linux \ |
1655 |
++// RUN: | FileCheck --check-prefix=CHECK-CLANGRT-I386 %s |
1656 |
++// CHECK-CLANGRT-I386: libclang_rt.builtins-i386.a |
1657 |
++ |
1658 |
++// Check whether alternate arch values map to the correct library. |
1659 |
++// |
1660 |
++// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \ |
1661 |
+ // RUN: --target=i686-pc-linux \ |
1662 |
+-// RUN: | FileCheck --check-prefix=CHECK-CLANGRT-I686 %s |
1663 |
+-// CHECK-CLANGRT-I686: libclang_rt.builtins-i686.a |
1664 |
++// RUN: | FileCheck --check-prefix=CHECK-CLANGRT-I386 %s |
1665 |
+diff --git a/test/Driver/windows-cross.c b/test/Driver/windows-cross.c |
1666 |
+index 5a2fe52b09..78b4981c9d 100644 |
1667 |
+--- a/test/Driver/windows-cross.c |
1668 |
++++ b/test/Driver/windows-cross.c |
1669 |
+@@ -59,7 +59,7 @@ |
1670 |
+ // RUN: | FileCheck %s --check-prefix CHECK-SANITIZE-ADDRESS-EXE-X86 |
1671 |
+ |
1672 |
+ // CHECK-SANITIZE-ADDRESS-EXE-X86: "-fsanitize=address" |
1673 |
+-// CHECK-SANITIZE-ADDRESS-EXE-X86: "{{.*}}clang_rt.asan_dynamic-i686.lib" "{{.*}}clang_rt.asan_dynamic_runtime_thunk-i686.lib" "--undefined" "___asan_seh_interceptor" |
1674 |
++// CHECK-SANITIZE-ADDRESS-EXE-X86: "{{.*}}clang_rt.asan_dynamic-i386.lib" "{{.*}}clang_rt.asan_dynamic_runtime_thunk-i386.lib" "--undefined" "___asan_seh_interceptor" |
1675 |
+ |
1676 |
+ // RUN: %clang -### -target armv7-windows-itanium --sysroot %S/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin -fuse-ld=lld-link2 -shared -o shared.dll -fsanitize=tsan -x c++ %s 2>&1 \ |
1677 |
+ // RUN: | FileCheck %s --check-prefix CHECK-SANITIZE-TSAN |
1678 |
+-- |
1679 |
+2.11.0 |
1680 |
+ |
1681 |
|
1682 |
diff --git a/sys-devel/clang/files/5.0.1/0002-test-Fix-clang-test-for-FreeBSD-and-NetBSD.patch b/sys-devel/clang/files/5.0.1/0002-test-Fix-clang-test-for-FreeBSD-and-NetBSD.patch |
1683 |
new file mode 100644 |
1684 |
index 0000000..1751a4f |
1685 |
--- /dev/null |
1686 |
+++ b/sys-devel/clang/files/5.0.1/0002-test-Fix-clang-test-for-FreeBSD-and-NetBSD.patch |
1687 |
@@ -0,0 +1,76 @@ |
1688 |
+From 4650c277d616e5d297baf28682eb792e2e0144b1 Mon Sep 17 00:00:00 2001 |
1689 |
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@g.o> |
1690 |
+Date: Sun, 1 Apr 2018 23:20:56 +0200 |
1691 |
+Subject: [PATCH] [test] Fix clang-test for FreeBSD and NetBSD |
1692 |
+ |
1693 |
+Lit tries to inject the shared library paths, but no action is taken |
1694 |
+when platform.system() is not recognized, results in an environment |
1695 |
+variable with an empty name, which is illegal. |
1696 |
+ |
1697 |
+The patch fixes this mechanism for FreeBSD and NetBSD, and gives an |
1698 |
+warning on other platforms, so that the latecomers don't have to spend |
1699 |
+time on debugging lit. |
1700 |
+ |
1701 |
+Thanks Zhihao Yuan for the patch! |
1702 |
+ |
1703 |
+Differential Revision: https://reviews.llvm.org/D39162 |
1704 |
+ |
1705 |
+git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@316411 91177308-0d34-0410-b5e6-96231b3b80d8 |
1706 |
+ |
1707 |
+(rebased for release_50 branch) |
1708 |
+--- |
1709 |
+ test/Unit/lit.cfg | 41 ++++++++++++++++++++--------------------- |
1710 |
+ 1 file changed, 20 insertions(+), 21 deletions(-) |
1711 |
+ |
1712 |
+diff --git a/test/Unit/lit.cfg b/test/Unit/lit.cfg |
1713 |
+index 90eb2ac604..2cabf4bba1 100644 |
1714 |
+--- a/test/Unit/lit.cfg |
1715 |
++++ b/test/Unit/lit.cfg |
1716 |
+@@ -87,24 +87,23 @@ if config.test_exec_root is None: |
1717 |
+ lit_config.load_config(config, site_cfg) |
1718 |
+ raise SystemExit |
1719 |
+ |
1720 |
+-shlibpath_var = '' |
1721 |
+-if platform.system() == 'Linux': |
1722 |
+- shlibpath_var = 'LD_LIBRARY_PATH' |
1723 |
+-elif platform.system() == 'Darwin': |
1724 |
+- shlibpath_var = 'DYLD_LIBRARY_PATH' |
1725 |
+-elif platform.system() == 'Windows': |
1726 |
+- shlibpath_var = 'PATH' |
1727 |
+- |
1728 |
+-# in stand-alone builds, shlibdir is clang's build tree |
1729 |
+-# while llvm_libs_dir is installed LLVM (and possibly older clang) |
1730 |
+-llvm_shlib_dir = getattr(config, 'shlibdir', None) |
1731 |
+-if not llvm_shlib_dir: |
1732 |
+- lit_config.fatal('No shlibdir set!') |
1733 |
+-# Point the dynamic loader at dynamic libraries in 'lib'. |
1734 |
+-llvm_libs_dir = getattr(config, 'llvm_libs_dir', None) |
1735 |
+-if not llvm_libs_dir: |
1736 |
+- lit_config.fatal('No LLVM libs dir set!') |
1737 |
+-shlibpath = os.path.pathsep.join((llvm_shlib_dir, llvm_libs_dir, |
1738 |
+- config.environment.get(shlibpath_var,''))) |
1739 |
+- |
1740 |
+-config.environment[shlibpath_var] = shlibpath |
1741 |
++def find_shlibpath_var(): |
1742 |
++ if platform.system() in ['Linux', 'FreeBSD', 'NetBSD']: |
1743 |
++ yield 'LD_LIBRARY_PATH' |
1744 |
++ elif platform.system() == 'Darwin': |
1745 |
++ yield 'DYLD_LIBRARY_PATH' |
1746 |
++ elif platform.system() == 'Windows': |
1747 |
++ yield 'PATH' |
1748 |
++ |
1749 |
++for shlibpath_var in find_shlibpath_var(): |
1750 |
++ # in stand-alone builds, shlibdir is clang's build tree |
1751 |
++ # while llvm_libs_dir is installed LLVM (and possibly older clang) |
1752 |
++ shlibpath = os.path.pathsep.join( |
1753 |
++ (config.shlibdir, |
1754 |
++ config.llvm_libs_dir, |
1755 |
++ config.environment.get(shlibpath_var, ''))) |
1756 |
++ config.environment[shlibpath_var] = shlibpath |
1757 |
++ break |
1758 |
++else: |
1759 |
++ lit_config.warning("unable to inject shared library path on '{}'" |
1760 |
++ .format(platform.system())) |
1761 |
+-- |
1762 |
+2.17.0.rc2 |
1763 |
+ |
1764 |
|
1765 |
diff --git a/sys-devel/clang/files/5.0.1/0003-Add-Gentoo-Linux-distro.patch b/sys-devel/clang/files/5.0.1/0003-Add-Gentoo-Linux-distro.patch |
1766 |
new file mode 100644 |
1767 |
index 0000000..68770a6 |
1768 |
--- /dev/null |
1769 |
+++ b/sys-devel/clang/files/5.0.1/0003-Add-Gentoo-Linux-distro.patch |
1770 |
@@ -0,0 +1,33 @@ |
1771 |
+--- a/include/clang/Driver/Distro.h |
1772 |
++++ b/include/clang/Driver/Distro.h |
1773 |
+@@ -26,6 +26,7 @@ public: |
1774 |
+ // NB: Releases of a particular Linux distro should be kept together |
1775 |
+ // in this enum, because some tests are done by integer comparison against |
1776 |
+ // the first and last known member in the family, e.g. IsRedHat(). |
1777 |
++ GentooLinux, |
1778 |
+ ArchLinux, |
1779 |
+ DebianLenny, |
1780 |
+ DebianSqueeze, |
1781 |
+@@ -98,6 +99,10 @@ public: |
1782 |
+ /// @name Convenience Predicates |
1783 |
+ /// @{ |
1784 |
+ |
1785 |
++ bool IsGentooLinux() const { |
1786 |
++ return DistroVal == GentooLinux; |
1787 |
++ } |
1788 |
++ |
1789 |
+ bool IsRedhat() const { |
1790 |
+ return DistroVal == Fedora || (DistroVal >= RHEL5 && DistroVal <= RHEL7); |
1791 |
+ } |
1792 |
+--- a/lib/Driver/Distro.cpp |
1793 |
++++ b/lib/Driver/Distro.cpp |
1794 |
+@@ -129,6 +129,9 @@ static Distro::DistroType DetectDistro(vfs::FileSystem &VFS) { |
1795 |
+ if (VFS.exists("/etc/arch-release")) |
1796 |
+ return Distro::ArchLinux; |
1797 |
+ |
1798 |
++ if (VFS.exists("/etc/gentoo-release")) |
1799 |
++ return Distro::GentooLinux; |
1800 |
++ |
1801 |
+ return Distro::UnknownDistro; |
1802 |
+ } |
1803 |
+ |
1804 |
|
1805 |
diff --git a/sys-devel/clang/files/5.0.1/darwin_prefix-include-paths.patch b/sys-devel/clang/files/5.0.1/darwin_prefix-include-paths.patch |
1806 |
new file mode 100644 |
1807 |
index 0000000..7744b94 |
1808 |
--- /dev/null |
1809 |
+++ b/sys-devel/clang/files/5.0.1/darwin_prefix-include-paths.patch |
1810 |
@@ -0,0 +1,18 @@ |
1811 |
+--- a/lib/Frontend/InitHeaderSearch.cpp |
1812 |
++++ b/lib/Frontend/InitHeaderSearch.cpp |
1813 |
+@@ -233,6 +233,7 @@ |
1814 |
+ case llvm::Triple::Bitrig: |
1815 |
+ break; |
1816 |
+ default: |
1817 |
++ AddPath("@GENTOO_PORTAGE_EPREFIX@/usr/include", System, false); |
1818 |
+ // FIXME: temporary hack: hard-coded paths. |
1819 |
+ AddPath("/usr/local/include", System, false); |
1820 |
+ break; |
1821 |
+@@ -505,6 +506,7 @@ |
1822 |
+ // Add the default framework include paths on Darwin. |
1823 |
+ if (HSOpts.UseStandardSystemIncludes) { |
1824 |
+ if (triple.isOSDarwin()) { |
1825 |
++ AddPath("@GENTOO_PORTAGE_EPREFIX@/Frameworks", System, true); |
1826 |
+ AddPath("/System/Library/Frameworks", System, true); |
1827 |
+ AddPath("/Library/Frameworks", System, true); |
1828 |
+ } |
1829 |
|
1830 |
diff --git a/sys-devel/clang/files/5.0.1/extra/0001-Assume-the-shared-library-path-variable-is-LD_LIBRAR.patch b/sys-devel/clang/files/5.0.1/extra/0001-Assume-the-shared-library-path-variable-is-LD_LIBRAR.patch |
1831 |
new file mode 100644 |
1832 |
index 0000000..cbdb0b8 |
1833 |
--- /dev/null |
1834 |
+++ b/sys-devel/clang/files/5.0.1/extra/0001-Assume-the-shared-library-path-variable-is-LD_LIBRAR.patch |
1835 |
@@ -0,0 +1,37 @@ |
1836 |
+From 5c5bb3948697f2ca184a03dedd5666eb2de547ba Mon Sep 17 00:00:00 2001 |
1837 |
+From: Dimitry Andric <dimitry@××××××.com> |
1838 |
+Date: Sat, 20 Jan 2018 14:34:33 +0000 |
1839 |
+Subject: [PATCH] Assume the shared library path variable is LD_LIBRARY_PATH on |
1840 |
+ systems except Darwin and Windows. This prevents inserting an environment |
1841 |
+ variable with an empty name (which is illegal and leads to a Python |
1842 |
+ exception) on any of the BSDs. |
1843 |
+ |
1844 |
+git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@323040 91177308-0d34-0410-b5e6-96231b3b80d8 |
1845 |
+--- |
1846 |
+ test/Unit/lit.cfg | 7 +++---- |
1847 |
+ 1 file changed, 3 insertions(+), 4 deletions(-) |
1848 |
+ |
1849 |
+diff --git a/test/Unit/lit.cfg b/test/Unit/lit.cfg |
1850 |
+index fc63afdb..b40e1cae 100644 |
1851 |
+--- a/test/Unit/lit.cfg |
1852 |
++++ b/test/Unit/lit.cfg |
1853 |
+@@ -19,13 +19,12 @@ config.test_exec_root = config.test_source_root |
1854 |
+ # ;-separated list of subdirectories). |
1855 |
+ config.test_format = lit.formats.GoogleTest('.', 'Tests') |
1856 |
+ |
1857 |
+-shlibpath_var = '' |
1858 |
+-if platform.system() == 'Linux': |
1859 |
+- shlibpath_var = 'LD_LIBRARY_PATH' |
1860 |
+-elif platform.system() == 'Darwin': |
1861 |
++if platform.system() == 'Darwin': |
1862 |
+ shlibpath_var = 'DYLD_LIBRARY_PATH' |
1863 |
+ elif platform.system() == 'Windows': |
1864 |
+ shlibpath_var = 'PATH' |
1865 |
++else: |
1866 |
++ shlibpath_var = 'LD_LIBRARY_PATH' |
1867 |
+ |
1868 |
+ # Point the dynamic loader at dynamic libraries in 'lib'. |
1869 |
+ shlibpath = os.path.pathsep.join((config.shlibdir, config.llvm_libs_dir, |
1870 |
+-- |
1871 |
+2.17.0.rc2 |
1872 |
+ |
1873 |
|
1874 |
diff --git a/sys-devel/clang/files/5.0.1/hardened/0001-Use-z-relro-on-Gentoo.patch b/sys-devel/clang/files/5.0.1/hardened/0001-Use-z-relro-on-Gentoo.patch |
1875 |
new file mode 100644 |
1876 |
index 0000000..eeda778 |
1877 |
--- /dev/null |
1878 |
+++ b/sys-devel/clang/files/5.0.1/hardened/0001-Use-z-relro-on-Gentoo.patch |
1879 |
@@ -0,0 +1,11 @@ |
1880 |
+--- a/lib/Driver/ToolChains/Linux.cpp |
1881 |
++++ b/lib/Driver/ToolChains/Linux.cpp |
1882 |
+@@ -210,7 +210,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) |
1883 |
+ |
1884 |
+ Distro Distro(D.getVFS()); |
1885 |
+ |
1886 |
+- if (Distro.IsOpenSUSE() || Distro.IsUbuntu()) { |
1887 |
++ if (Distro.IsOpenSUSE() || Distro.IsUbuntu() || Distro.IsGentooLinux()) { |
1888 |
+ ExtraOpts.push_back("-z"); |
1889 |
+ ExtraOpts.push_back("relro"); |
1890 |
+ } |
1891 |
|
1892 |
diff --git a/sys-devel/clang/files/5.0.1/hardened/0002-Enable-Stack-Protector-by-default.patch b/sys-devel/clang/files/5.0.1/hardened/0002-Enable-Stack-Protector-by-default.patch |
1893 |
new file mode 100644 |
1894 |
index 0000000..2f5faf5 |
1895 |
--- /dev/null |
1896 |
+++ b/sys-devel/clang/files/5.0.1/hardened/0002-Enable-Stack-Protector-by-default.patch |
1897 |
@@ -0,0 +1,25 @@ |
1898 |
+--- a/lib/Driver/ToolChains/Linux.cpp |
1899 |
++++ b/lib/Driver/ToolChains/Linux.cpp |
1900 |
+@@ -820,6 +820,10 @@ bool Linux::isPIEDefault() const { |
1901 |
+ getTriple().isMusl() || getSanitizerArgs().requiresPIE(); |
1902 |
+ } |
1903 |
+ |
1904 |
++unsigned Linux::GetDefaultStackProtectorLevel(bool KernelOrKext) const { |
1905 |
++ return 2; |
1906 |
++} |
1907 |
++ |
1908 |
+ SanitizerMask Linux::getSupportedSanitizers() const { |
1909 |
+ const bool IsX86 = getTriple().getArch() == llvm::Triple::x86; |
1910 |
+ const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;diff --git a/lib/Driver/ToolChains/Linux.cpp b/lib/Driver/ToolChains/Linux.cpp |
1911 |
+diff --git a/lib/Driver/ToolChains/Linux.h b/lib/Driver/ToolChains/Linux.h |
1912 |
+index 9778c1832cc..ddd46a1d587 100644 |
1913 |
+--- a/lib/Driver/ToolChains/Linux.h |
1914 |
++++ b/lib/Driver/ToolChains/Linux.h |
1915 |
+@@ -36,6 +36,7 @@ public: |
1916 |
+ void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs, |
1917 |
+ llvm::opt::ArgStringList &CC1Args) const override; |
1918 |
+ bool isPIEDefault() const override; |
1919 |
++ unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override; |
1920 |
+ SanitizerMask getSupportedSanitizers() const override; |
1921 |
+ void addProfileRTLibs(const llvm::opt::ArgList &Args, |
1922 |
+ llvm::opt::ArgStringList &CmdArgs) const override; |
1923 |
|
1924 |
diff --git a/sys-devel/clang/files/5.0.1/hardened/0003-Enable-PIE-by-default.patch b/sys-devel/clang/files/5.0.1/hardened/0003-Enable-PIE-by-default.patch |
1925 |
new file mode 100644 |
1926 |
index 0000000..301ee11 |
1927 |
--- /dev/null |
1928 |
+++ b/sys-devel/clang/files/5.0.1/hardened/0003-Enable-PIE-by-default.patch |
1929 |
@@ -0,0 +1,24 @@ |
1930 |
+--- a/lib/Driver/ToolChains/Gnu.cpp |
1931 |
++++ b/lib/Driver/ToolChains/Gnu.cpp |
1932 |
+@@ -443,7 +443,9 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA, |
1933 |
+ if (!D.SysRoot.empty()) |
1934 |
+ CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot)); |
1935 |
+ |
1936 |
+- if (IsPIE) |
1937 |
++ if (Args.hasArg(options::OPT_nopie)) |
1938 |
++ CmdArgs.push_back("-nopie"); |
1939 |
++ else if (IsPIE) |
1940 |
+ CmdArgs.push_back("-pie"); |
1941 |
+ |
1942 |
+ if (Args.hasArg(options::OPT_rdynamic)) |
1943 |
+--- a/lib/Driver/ToolChains/Linux.cpp |
1944 |
++++ b/lib/Driver/ToolChains/Linux.cpp |
1945 |
+@@ -819,7 +819,7 @@ void Linux::AddIAMCUIncludeArgs(const ArgList &DriverArgs, |
1946 |
+ } |
1947 |
+ } |
1948 |
+ |
1949 |
+-bool Linux::isPIEDefault() const { return getSanitizerArgs().requiresPIE(); } |
1950 |
++bool Linux::isPIEDefault() const { return true; } |
1951 |
+ |
1952 |
+ SanitizerMask Linux::getSupportedSanitizers() const { |
1953 |
+ const bool IsX86 = getTriple().getArch() == llvm::Triple::x86; |
1954 |
|
1955 |
diff --git a/sys-devel/clang/files/5.0.1/hardened/0004-Enable-FORTIFY_SOURCE-macro-by-default.patch b/sys-devel/clang/files/5.0.1/hardened/0004-Enable-FORTIFY_SOURCE-macro-by-default.patch |
1956 |
new file mode 100644 |
1957 |
index 0000000..410bae9 |
1958 |
--- /dev/null |
1959 |
+++ b/sys-devel/clang/files/5.0.1/hardened/0004-Enable-FORTIFY_SOURCE-macro-by-default.patch |
1960 |
@@ -0,0 +1,35 @@ |
1961 |
+From 68d39575cdff576b85907bea8e42b7ef26384dbb Mon Sep 17 00:00:00 2001 |
1962 |
+From: Matthias Dahl <matthias.dahl@×××××××××××××.eu> |
1963 |
+Date: Wed, 20 Sep 2017 16:17:31 +0200 |
1964 |
+Subject: [PATCH 3/3] Enable FORTIFY_SOURCE macro by default |
1965 |
+ |
1966 |
+FORTIFY_SOURCE only works for optimization levels > 0 and is currently not |
1967 |
+compatible with the address sanitizer, thus the macro is only set if the input |
1968 |
+language is C or C++ and the optimization level > 0 while the address sanitizer |
1969 |
+is not requested. |
1970 |
+--- |
1971 |
+ lib/Frontend/CompilerInvocation.cpp | 8 ++++++++ |
1972 |
+ 1 file changed, 8 insertions(+) |
1973 |
+ |
1974 |
+diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp |
1975 |
+index 0d0869c815d..88c16534103 100644 |
1976 |
+--- a/lib/Frontend/CompilerInvocation.cpp |
1977 |
++++ b/lib/Frontend/CompilerInvocation.cpp |
1978 |
+@@ -2694,6 +2694,14 @@ bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res, |
1979 |
+ !LangOpts.Sanitize.has(SanitizerKind::Address) && |
1980 |
+ !LangOpts.Sanitize.has(SanitizerKind::Memory); |
1981 |
+ |
1982 |
++ // Set the macro before the command line macros are being processed, so it can be |
1983 |
++ // properly unset if required to in case of incompatibilities. |
1984 |
++ if (Res.getCodeGenOpts().OptimizationLevel > 0 && |
1985 |
++ (DashX.getLanguage() == InputKind::C || DashX.getLanguage() == InputKind::CXX) && |
1986 |
++ !LangOpts.Sanitize.has(SanitizerKind::Address)) { |
1987 |
++ Res.getPreprocessorOpts().addMacroDef("_FORTIFY_SOURCE=2"); |
1988 |
++ } |
1989 |
++ |
1990 |
+ // FIXME: ParsePreprocessorArgs uses the FileManager to read the contents of |
1991 |
+ // PCH file and find the original header name. Remove the need to do that in |
1992 |
+ // ParsePreprocessorArgs and remove the FileManager |
1993 |
+-- |
1994 |
+2.14.1 |
1995 |
+ |
1996 |
|
1997 |
diff --git a/sys-devel/clang/files/5.0.1/hardened/0005-Link-with-z-now-by-default-for-Gentoo.patch b/sys-devel/clang/files/5.0.1/hardened/0005-Link-with-z-now-by-default-for-Gentoo.patch |
1998 |
new file mode 100644 |
1999 |
index 0000000..ff0642f |
2000 |
--- /dev/null |
2001 |
+++ b/sys-devel/clang/files/5.0.1/hardened/0005-Link-with-z-now-by-default-for-Gentoo.patch |
2002 |
@@ -0,0 +1,14 @@ |
2003 |
+--- a/lib/Driver/ToolChains/Linux.cpp |
2004 |
++++ b/lib/Driver/ToolChains/Linux.cpp |
2005 |
+@@ -212,6 +212,11 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) |
2006 |
+ |
2007 |
+ Distro Distro(D.getVFS()); |
2008 |
+ |
2009 |
++ if (Distro.IsGentooLinux()) { |
2010 |
++ ExtraOpts.push_back("-z"); |
2011 |
++ ExtraOpts.push_back("now"); |
2012 |
++ } |
2013 |
++ |
2014 |
+ if (Distro.IsOpenSUSE() || Distro.IsUbuntu() || Distro.IsGentooLinux()) { |
2015 |
+ ExtraOpts.push_back("-z"); |
2016 |
+ ExtraOpts.push_back("relro"); |
2017 |
|
2018 |
diff --git a/sys-devel/clang/files/6.0.0/0001-Driver-Avoid-invalidated-iterator-in-insertTargetAnd.patch b/sys-devel/clang/files/6.0.0/0001-Driver-Avoid-invalidated-iterator-in-insertTargetAnd.patch |
2019 |
new file mode 100644 |
2020 |
index 0000000..20ba89b |
2021 |
--- /dev/null |
2022 |
+++ b/sys-devel/clang/files/6.0.0/0001-Driver-Avoid-invalidated-iterator-in-insertTargetAnd.patch |
2023 |
@@ -0,0 +1,55 @@ |
2024 |
+From 99418eabfbe5378d7a751444856c6c5c656519c4 Mon Sep 17 00:00:00 2001 |
2025 |
+From: Serge Pavlov <sepavloff@×××××.com> |
2026 |
+Date: Mon, 19 Mar 2018 16:13:43 +0000 |
2027 |
+Subject: [PATCH 1/2] [Driver] Avoid invalidated iterator in |
2028 |
+ insertTargetAndModeArgs |
2029 |
+ |
2030 |
+Doing an .insert() can potentially invalidate iterators by reallocating the |
2031 |
+vector's storage. When all the stars align just right, this causes segfaults |
2032 |
+or glibc aborts. |
2033 |
+ |
2034 |
+Gentoo Linux bug (crashes while building Chromium): https://bugs.gentoo.org/650082. |
2035 |
+ |
2036 |
+Patch by Hector Martin! |
2037 |
+ |
2038 |
+Differential Revision: https://reviews.llvm.org/D44607 |
2039 |
+ |
2040 |
+ |
2041 |
+git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@327863 91177308-0d34-0410-b5e6-96231b3b80d8 |
2042 |
+--- |
2043 |
+ tools/driver/driver.cpp | 9 +++++---- |
2044 |
+ 1 file changed, 5 insertions(+), 4 deletions(-) |
2045 |
+ |
2046 |
+diff --git a/tools/driver/driver.cpp b/tools/driver/driver.cpp |
2047 |
+index fa757da953..1b614accb2 100644 |
2048 |
+--- a/tools/driver/driver.cpp |
2049 |
++++ b/tools/driver/driver.cpp |
2050 |
+@@ -212,20 +212,21 @@ static void insertTargetAndModeArgs(const ParsedClangName &NameParts, |
2051 |
+ // Put target and mode arguments at the start of argument list so that |
2052 |
+ // arguments specified in command line could override them. Avoid putting |
2053 |
+ // them at index 0, as an option like '-cc1' must remain the first. |
2054 |
+- auto InsertionPoint = ArgVector.begin(); |
2055 |
+- if (InsertionPoint != ArgVector.end()) |
2056 |
++ int InsertionPoint = 0; |
2057 |
++ if (ArgVector.size() > 0) |
2058 |
+ ++InsertionPoint; |
2059 |
+ |
2060 |
+ if (NameParts.DriverMode) { |
2061 |
+ // Add the mode flag to the arguments. |
2062 |
+- ArgVector.insert(InsertionPoint, |
2063 |
++ ArgVector.insert(ArgVector.begin() + InsertionPoint, |
2064 |
+ GetStableCStr(SavedStrings, NameParts.DriverMode)); |
2065 |
+ } |
2066 |
+ |
2067 |
+ if (NameParts.TargetIsValid) { |
2068 |
+ const char *arr[] = {"-target", GetStableCStr(SavedStrings, |
2069 |
+ NameParts.TargetPrefix)}; |
2070 |
+- ArgVector.insert(InsertionPoint, std::begin(arr), std::end(arr)); |
2071 |
++ ArgVector.insert(ArgVector.begin() + InsertionPoint, |
2072 |
++ std::begin(arr), std::end(arr)); |
2073 |
+ } |
2074 |
+ } |
2075 |
+ |
2076 |
+-- |
2077 |
+2.16.2 |
2078 |
+ |
2079 |
|
2080 |
diff --git a/sys-devel/clang/files/6.0.0/0002-test-Fix-Cross-DSO-CFI-Android-sanitizer-test-for-rt.patch b/sys-devel/clang/files/6.0.0/0002-test-Fix-Cross-DSO-CFI-Android-sanitizer-test-for-rt.patch |
2081 |
new file mode 100644 |
2082 |
index 0000000..0c66448 |
2083 |
--- /dev/null |
2084 |
+++ b/sys-devel/clang/files/6.0.0/0002-test-Fix-Cross-DSO-CFI-Android-sanitizer-test-for-rt.patch |
2085 |
@@ -0,0 +1,30 @@ |
2086 |
+From f81bc3f2d174ac21e576cdddb736524531258fbe Mon Sep 17 00:00:00 2001 |
2087 |
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@g.o> |
2088 |
+Date: Mon, 19 Mar 2018 20:55:47 +0100 |
2089 |
+Subject: [PATCH 2/2] [test] Fix Cross-DSO CFI Android sanitizer test for |
2090 |
+ -rtlib=compiler-rt |
2091 |
+ |
2092 |
+Fix the CHECK-CFI-CROSS-DSO-ANDROID test to be more precise and match |
2093 |
+specifically 'clang_rt.cfi' rather than any compiler-rt library. This |
2094 |
+fixes the failure when the linker command-line contains |
2095 |
+clang_rt.builtins library due to CLANG_DEFAULT_RTLIB=compiler-rt. |
2096 |
+--- |
2097 |
+ test/Driver/sanitizer-ld.c | 2 +- |
2098 |
+ 1 file changed, 1 insertion(+), 1 deletion(-) |
2099 |
+ |
2100 |
+diff --git a/test/Driver/sanitizer-ld.c b/test/Driver/sanitizer-ld.c |
2101 |
+index 0da4255f69..9309450186 100644 |
2102 |
+--- a/test/Driver/sanitizer-ld.c |
2103 |
++++ b/test/Driver/sanitizer-ld.c |
2104 |
+@@ -514,7 +514,7 @@ |
2105 |
+ // RUN: --sysroot=%S/Inputs/basic_android_tree \ |
2106 |
+ // RUN: | FileCheck --check-prefix=CHECK-CFI-CROSS-DSO-ANDROID %s |
2107 |
+ // CHECK-CFI-CROSS-DSO-ANDROID: "{{.*}}ld{{(.exe)?}}" |
2108 |
+-// CHECK-CFI-CROSS-DSO-ANDROID-NOT: libclang_rt. |
2109 |
++// CHECK-CFI-CROSS-DSO-ANDROID-NOT: libclang_rt.cfi |
2110 |
+ |
2111 |
+ // Cross-DSO CFI with diagnostics on Android links just the UBSAN runtime. |
2112 |
+ // RUN: %clang -fsanitize=cfi -fsanitize-cfi-cross-dso %s -### -o %t.o 2>&1 \ |
2113 |
+-- |
2114 |
+2.16.2 |
2115 |
+ |
2116 |
|
2117 |
diff --git a/sys-devel/clang/files/6.0.0/0003-Add-Gentoo-Linux-distro.patch b/sys-devel/clang/files/6.0.0/0003-Add-Gentoo-Linux-distro.patch |
2118 |
new file mode 100644 |
2119 |
index 0000000..a11dcfe |
2120 |
--- /dev/null |
2121 |
+++ b/sys-devel/clang/files/6.0.0/0003-Add-Gentoo-Linux-distro.patch |
2122 |
@@ -0,0 +1,33 @@ |
2123 |
+--- a/include/clang/Driver/Distro.h |
2124 |
++++ b/include/clang/Driver/Distro.h |
2125 |
+@@ -26,6 +26,7 @@ public: |
2126 |
+ // NB: Releases of a particular Linux distro should be kept together |
2127 |
+ // in this enum, because some tests are done by integer comparison against |
2128 |
+ // the first and last known member in the family, e.g. IsRedHat(). |
2129 |
++ GentooLinux, |
2130 |
+ AlpineLinux, |
2131 |
+ ArchLinux, |
2132 |
+ DebianLenny, |
2133 |
+@@ -98,6 +99,10 @@ public: |
2134 |
+ /// @name Convenience Predicates |
2135 |
+ /// @{ |
2136 |
+ |
2137 |
++ bool IsGentooLinux() const { |
2138 |
++ return DistroVal == GentooLinux; |
2139 |
++ } |
2140 |
++ |
2141 |
+ bool IsRedhat() const { |
2142 |
+ return DistroVal == Fedora || (DistroVal >= RHEL5 && DistroVal <= RHEL7); |
2143 |
+ } |
2144 |
+--- a/lib/Driver/Distro.cpp |
2145 |
++++ b/lib/Driver/Distro.cpp |
2146 |
+@@ -129,6 +129,9 @@ static Distro::DistroType DetectDistro(vfs::FileSystem &VFS) { |
2147 |
+ if (VFS.exists("/etc/arch-release")) |
2148 |
+ return Distro::ArchLinux; |
2149 |
+ |
2150 |
++ if (VFS.exists("/etc/gentoo-release")) |
2151 |
++ return Distro::GentooLinux; |
2152 |
++ |
2153 |
+ return Distro::UnknownDistro; |
2154 |
+ } |
2155 |
+ |
2156 |
|
2157 |
diff --git a/sys-devel/clang/files/6.0.0/hardened/0001-Use-z-relro-on-Gentoo.patch b/sys-devel/clang/files/6.0.0/hardened/0001-Use-z-relro-on-Gentoo.patch |
2158 |
new file mode 100644 |
2159 |
index 0000000..653c933 |
2160 |
--- /dev/null |
2161 |
+++ b/sys-devel/clang/files/6.0.0/hardened/0001-Use-z-relro-on-Gentoo.patch |
2162 |
@@ -0,0 +1,11 @@ |
2163 |
+--- a/lib/Driver/ToolChains/Linux.cpp |
2164 |
++++ b/lib/Driver/ToolChains/Linux.cpp |
2165 |
+@@ -210,7 +210,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) |
2166 |
+ |
2167 |
+ Distro Distro(D.getVFS()); |
2168 |
+ |
2169 |
+- if (Distro.IsOpenSUSE() || Distro.IsUbuntu() || Distro.IsAlpineLinux()) { |
2170 |
++ if (Distro.IsOpenSUSE() || Distro.IsUbuntu() || Distro.IsAlpineLinux() || Distro.IsGentooLinux()) { |
2171 |
+ ExtraOpts.push_back("-z"); |
2172 |
+ ExtraOpts.push_back("relro"); |
2173 |
+ } |
2174 |
|
2175 |
diff --git a/sys-devel/clang/files/6.0.0/hardened/0002-Enable-Stack-Protector-by-default.patch b/sys-devel/clang/files/6.0.0/hardened/0002-Enable-Stack-Protector-by-default.patch |
2176 |
new file mode 100644 |
2177 |
index 0000000..2f5faf5 |
2178 |
--- /dev/null |
2179 |
+++ b/sys-devel/clang/files/6.0.0/hardened/0002-Enable-Stack-Protector-by-default.patch |
2180 |
@@ -0,0 +1,25 @@ |
2181 |
+--- a/lib/Driver/ToolChains/Linux.cpp |
2182 |
++++ b/lib/Driver/ToolChains/Linux.cpp |
2183 |
+@@ -820,6 +820,10 @@ bool Linux::isPIEDefault() const { |
2184 |
+ getTriple().isMusl() || getSanitizerArgs().requiresPIE(); |
2185 |
+ } |
2186 |
+ |
2187 |
++unsigned Linux::GetDefaultStackProtectorLevel(bool KernelOrKext) const { |
2188 |
++ return 2; |
2189 |
++} |
2190 |
++ |
2191 |
+ SanitizerMask Linux::getSupportedSanitizers() const { |
2192 |
+ const bool IsX86 = getTriple().getArch() == llvm::Triple::x86; |
2193 |
+ const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;diff --git a/lib/Driver/ToolChains/Linux.cpp b/lib/Driver/ToolChains/Linux.cpp |
2194 |
+diff --git a/lib/Driver/ToolChains/Linux.h b/lib/Driver/ToolChains/Linux.h |
2195 |
+index 9778c1832cc..ddd46a1d587 100644 |
2196 |
+--- a/lib/Driver/ToolChains/Linux.h |
2197 |
++++ b/lib/Driver/ToolChains/Linux.h |
2198 |
+@@ -36,6 +36,7 @@ public: |
2199 |
+ void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs, |
2200 |
+ llvm::opt::ArgStringList &CC1Args) const override; |
2201 |
+ bool isPIEDefault() const override; |
2202 |
++ unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override; |
2203 |
+ SanitizerMask getSupportedSanitizers() const override; |
2204 |
+ void addProfileRTLibs(const llvm::opt::ArgList &Args, |
2205 |
+ llvm::opt::ArgStringList &CmdArgs) const override; |
2206 |
|
2207 |
diff --git a/sys-devel/clang/files/6.0.0/hardened/0003-Enable-PIE-by-default.patch b/sys-devel/clang/files/6.0.0/hardened/0003-Enable-PIE-by-default.patch |
2208 |
new file mode 100644 |
2209 |
index 0000000..2b9ad5e |
2210 |
--- /dev/null |
2211 |
+++ b/sys-devel/clang/files/6.0.0/hardened/0003-Enable-PIE-by-default.patch |
2212 |
@@ -0,0 +1,12 @@ |
2213 |
+--- a/lib/Driver/ToolChains/Linux.cpp |
2214 |
++++ b/lib/Driver/ToolChains/Linux.cpp |
2215 |
+@@ -816,8 +816,7 @@ void Linux::AddIAMCUIncludeArgs(const ArgList &DriverArgs, |
2216 |
+ } |
2217 |
+ |
2218 |
+ bool Linux::isPIEDefault() const { |
2219 |
+- return (getTriple().isAndroid() && !getTriple().isAndroidVersionLT(16)) || |
2220 |
+- getTriple().isMusl() || getSanitizerArgs().requiresPIE(); |
2221 |
++ return true; |
2222 |
+ } |
2223 |
+ |
2224 |
+ unsigned Linux::GetDefaultStackProtectorLevel(bool KernelOrKext) const { |
2225 |
|
2226 |
diff --git a/sys-devel/clang/files/6.0.0/hardened/0004-Enable-FORTIFY_SOURCE-macro-by-default.patch b/sys-devel/clang/files/6.0.0/hardened/0004-Enable-FORTIFY_SOURCE-macro-by-default.patch |
2227 |
new file mode 100644 |
2228 |
index 0000000..410bae9 |
2229 |
--- /dev/null |
2230 |
+++ b/sys-devel/clang/files/6.0.0/hardened/0004-Enable-FORTIFY_SOURCE-macro-by-default.patch |
2231 |
@@ -0,0 +1,35 @@ |
2232 |
+From 68d39575cdff576b85907bea8e42b7ef26384dbb Mon Sep 17 00:00:00 2001 |
2233 |
+From: Matthias Dahl <matthias.dahl@×××××××××××××.eu> |
2234 |
+Date: Wed, 20 Sep 2017 16:17:31 +0200 |
2235 |
+Subject: [PATCH 3/3] Enable FORTIFY_SOURCE macro by default |
2236 |
+ |
2237 |
+FORTIFY_SOURCE only works for optimization levels > 0 and is currently not |
2238 |
+compatible with the address sanitizer, thus the macro is only set if the input |
2239 |
+language is C or C++ and the optimization level > 0 while the address sanitizer |
2240 |
+is not requested. |
2241 |
+--- |
2242 |
+ lib/Frontend/CompilerInvocation.cpp | 8 ++++++++ |
2243 |
+ 1 file changed, 8 insertions(+) |
2244 |
+ |
2245 |
+diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp |
2246 |
+index 0d0869c815d..88c16534103 100644 |
2247 |
+--- a/lib/Frontend/CompilerInvocation.cpp |
2248 |
++++ b/lib/Frontend/CompilerInvocation.cpp |
2249 |
+@@ -2694,6 +2694,14 @@ bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res, |
2250 |
+ !LangOpts.Sanitize.has(SanitizerKind::Address) && |
2251 |
+ !LangOpts.Sanitize.has(SanitizerKind::Memory); |
2252 |
+ |
2253 |
++ // Set the macro before the command line macros are being processed, so it can be |
2254 |
++ // properly unset if required to in case of incompatibilities. |
2255 |
++ if (Res.getCodeGenOpts().OptimizationLevel > 0 && |
2256 |
++ (DashX.getLanguage() == InputKind::C || DashX.getLanguage() == InputKind::CXX) && |
2257 |
++ !LangOpts.Sanitize.has(SanitizerKind::Address)) { |
2258 |
++ Res.getPreprocessorOpts().addMacroDef("_FORTIFY_SOURCE=2"); |
2259 |
++ } |
2260 |
++ |
2261 |
+ // FIXME: ParsePreprocessorArgs uses the FileManager to read the contents of |
2262 |
+ // PCH file and find the original header name. Remove the need to do that in |
2263 |
+ // ParsePreprocessorArgs and remove the FileManager |
2264 |
+-- |
2265 |
+2.14.1 |
2266 |
+ |
2267 |
|
2268 |
diff --git a/sys-devel/clang/files/6.0.0/hardened/0005-Link-with-z-now-by-default-for-Gentoo.patch b/sys-devel/clang/files/6.0.0/hardened/0005-Link-with-z-now-by-default-for-Gentoo.patch |
2269 |
new file mode 100644 |
2270 |
index 0000000..28942ae |
2271 |
--- /dev/null |
2272 |
+++ b/sys-devel/clang/files/6.0.0/hardened/0005-Link-with-z-now-by-default-for-Gentoo.patch |
2273 |
@@ -0,0 +1,11 @@ |
2274 |
+--- a/lib/Driver/ToolChains/Linux.cpp |
2275 |
++++ b/lib/Driver/ToolChains/Linux.cpp |
2276 |
+@@ -210,7 +210,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) |
2277 |
+ |
2278 |
+ Distro Distro(D.getVFS()); |
2279 |
+ |
2280 |
+- if (Distro.IsAlpineLinux()) { |
2281 |
++ if (Distro.IsAlpineLinux() || Distro.IsGentooLinux()) { |
2282 |
+ ExtraOpts.push_back("-z"); |
2283 |
+ ExtraOpts.push_back("now"); |
2284 |
+ } |
2285 |
|
2286 |
diff --git a/sys-devel/clang/metadata.xml b/sys-devel/clang/metadata.xml |
2287 |
new file mode 100644 |
2288 |
index 0000000..04b324c |
2289 |
--- /dev/null |
2290 |
+++ b/sys-devel/clang/metadata.xml |
2291 |
@@ -0,0 +1,35 @@ |
2292 |
+<?xml version="1.0" encoding="UTF-8"?> |
2293 |
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> |
2294 |
+<pkgmetadata> |
2295 |
+ <maintainer type="project"> |
2296 |
+ <email>llvm@g.o</email> |
2297 |
+ </maintainer> |
2298 |
+ <longdescription>The goal of the Clang project is to create a new C, C++, Objective C and Objective C++ front-end for the LLVM compiler. |
2299 |
+ |
2300 |
+Features and Goals |
2301 |
+ |
2302 |
+Some of the goals for the project include the following: |
2303 |
+ |
2304 |
+End-User Features: |
2305 |
+Fast compiles and low memory use |
2306 |
+Expressive diagnostics |
2307 |
+GCC compatibility |
2308 |
+Utility and Applications: |
2309 |
+ |
2310 |
+Modular library based architecture |
2311 |
+Support diverse clients (refactoring, static analysis, code generation, etc) |
2312 |
+Allow tight integration with IDEs |
2313 |
+Use the LLVM BSD License |
2314 |
+Internal Design and Implementation: |
2315 |
+ |
2316 |
+A real-world, production quality compiler |
2317 |
+A simple and hackable code base |
2318 |
+A single unified parser for C, Objective C, C++, and Objective C++ |
2319 |
+Conformance with C/C++/ObjC and their variants</longdescription> |
2320 |
+ <use> |
2321 |
+ <flag name="default-compiler-rt">Use compiler-rt instead of libgcc as the default rtlib for clang</flag> |
2322 |
+ <flag name="default-libcxx">Use libc++ instead of libstdc++ as the default stdlib for clang</flag> |
2323 |
+ <flag name="static-analyzer">Install the Clang static analyzer</flag> |
2324 |
+ <flag name="z3">Enable the static analyzer constraint manager backend using <pkg>sci-mathematics/z3</pkg></flag> |
2325 |
+ </use> |
2326 |
+</pkgmetadata> |