1 |
commit: 67b9dfae193718a8aab6f799c169d6998f444eb1 |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Aug 1 16:41:02 2018 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Aug 1 20:53:20 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=67b9dfae |
7 |
|
8 |
sys-devel/clang: Branch out LLVM 7.0 |
9 |
|
10 |
sys-devel/clang/clang-7.0.9999.ebuild | 298 ++++++++++++++++++++++++++++++++++ |
11 |
1 file changed, 298 insertions(+) |
12 |
|
13 |
diff --git a/sys-devel/clang/clang-7.0.9999.ebuild b/sys-devel/clang/clang-7.0.9999.ebuild |
14 |
new file mode 100644 |
15 |
index 00000000000..68737b42224 |
16 |
--- /dev/null |
17 |
+++ b/sys-devel/clang/clang-7.0.9999.ebuild |
18 |
@@ -0,0 +1,298 @@ |
19 |
+# Copyright 1999-2018 Gentoo Foundation |
20 |
+# Distributed under the terms of the GNU General Public License v2 |
21 |
+ |
22 |
+EAPI=6 |
23 |
+ |
24 |
+: ${CMAKE_MAKEFILE_GENERATOR:=ninja} |
25 |
+# (needed due to CMAKE_BUILD_TYPE != Gentoo) |
26 |
+CMAKE_MIN_VERSION=3.7.0-r1 |
27 |
+PYTHON_COMPAT=( python2_7 ) |
28 |
+ |
29 |
+inherit cmake-utils eapi7-ver flag-o-matic git-r3 llvm \ |
30 |
+ multilib-minimal multiprocessing pax-utils python-single-r1 \ |
31 |
+ toolchain-funcs |
32 |
+ |
33 |
+DESCRIPTION="C language family frontend for LLVM" |
34 |
+HOMEPAGE="https://llvm.org/" |
35 |
+SRC_URI="" |
36 |
+EGIT_REPO_URI="https://git.llvm.org/git/clang.git |
37 |
+ https://github.com/llvm-mirror/clang.git" |
38 |
+EGIT_BRANCH="release_70" |
39 |
+ |
40 |
+# Keep in sync with sys-devel/llvm |
41 |
+ALL_LLVM_TARGETS=( AArch64 AMDGPU ARM BPF Hexagon Lanai Mips MSP430 |
42 |
+ NVPTX PowerPC Sparc SystemZ X86 XCore ) |
43 |
+ALL_LLVM_TARGETS=( "${ALL_LLVM_TARGETS[@]/#/llvm_targets_}" ) |
44 |
+LLVM_TARGET_USEDEPS=${ALL_LLVM_TARGETS[@]/%/?} |
45 |
+ |
46 |
+LICENSE="UoI-NCSA" |
47 |
+SLOT="$(ver_cut 1)" |
48 |
+KEYWORDS="" |
49 |
+IUSE="debug default-compiler-rt default-libcxx doc +static-analyzer |
50 |
+ test xml z3 kernel_FreeBSD ${ALL_LLVM_TARGETS[*]}" |
51 |
+RESTRICT="!test? ( test )" |
52 |
+ |
53 |
+RDEPEND=" |
54 |
+ ~sys-devel/llvm-${PV}:${SLOT}=[debug=,${LLVM_TARGET_USEDEPS// /,},${MULTILIB_USEDEP}] |
55 |
+ static-analyzer? ( |
56 |
+ dev-lang/perl:* |
57 |
+ z3? ( sci-mathematics/z3:0= ) |
58 |
+ ) |
59 |
+ xml? ( dev-libs/libxml2:2=[${MULTILIB_USEDEP}] ) |
60 |
+ ${PYTHON_DEPS}" |
61 |
+# configparser-3.2 breaks the build (3.3 or none at all are fine) |
62 |
+DEPEND="${RDEPEND} |
63 |
+ doc? ( dev-python/sphinx ) |
64 |
+ xml? ( virtual/pkgconfig ) |
65 |
+ !!<dev-python/configparser-3.3.0.2 |
66 |
+ ${PYTHON_DEPS}" |
67 |
+RDEPEND="${RDEPEND} |
68 |
+ !<sys-devel/llvm-4.0.0_rc:0 |
69 |
+ !sys-devel/clang:0" |
70 |
+PDEPEND=" |
71 |
+ sys-devel/clang-common |
72 |
+ ~sys-devel/clang-runtime-${PV} |
73 |
+ default-compiler-rt? ( =sys-libs/compiler-rt-${PV%_*}* ) |
74 |
+ default-libcxx? ( >=sys-libs/libcxx-${PV} )" |
75 |
+ |
76 |
+REQUIRED_USE="${PYTHON_REQUIRED_USE} |
77 |
+ || ( ${ALL_LLVM_TARGETS[*]} )" |
78 |
+ |
79 |
+# We need extra level of indirection for CLANG_RESOURCE_DIR |
80 |
+S=${WORKDIR}/x/y/${P} |
81 |
+ |
82 |
+# least intrusive of all |
83 |
+CMAKE_BUILD_TYPE=RelWithDebInfo |
84 |
+ |
85 |
+# Multilib notes: |
86 |
+# 1. ABI_* flags control ABIs libclang* is built for only. |
87 |
+# 2. clang is always capable of compiling code for all ABIs for enabled |
88 |
+# target. However, you will need appropriate crt* files (installed |
89 |
+# e.g. by sys-devel/gcc and sys-libs/glibc). |
90 |
+# 3. ${CHOST}-clang wrappers are always installed for all ABIs included |
91 |
+# in the current profile (i.e. alike supported by sys-devel/gcc). |
92 |
+# |
93 |
+# Therefore: use sys-devel/clang[${MULTILIB_USEDEP}] only if you need |
94 |
+# multilib clang* libraries (not runtime, not wrappers). |
95 |
+ |
96 |
+pkg_setup() { |
97 |
+ LLVM_MAX_SLOT=${SLOT} llvm_pkg_setup |
98 |
+ python-single-r1_pkg_setup |
99 |
+} |
100 |
+ |
101 |
+src_unpack() { |
102 |
+ # create extra parent dir for CLANG_RESOURCE_DIR |
103 |
+ mkdir -p x/y || die |
104 |
+ cd x/y || die |
105 |
+ |
106 |
+ git-r3_fetch "https://git.llvm.org/git/clang-tools-extra.git |
107 |
+ https://github.com/llvm-mirror/clang-tools-extra.git" |
108 |
+ if use test; then |
109 |
+ # needed for patched gtest |
110 |
+ git-r3_fetch "https://git.llvm.org/git/llvm.git |
111 |
+ https://github.com/llvm-mirror/llvm.git" |
112 |
+ fi |
113 |
+ git-r3_fetch |
114 |
+ |
115 |
+ git-r3_checkout https://llvm.org/git/clang-tools-extra.git \ |
116 |
+ "${S}"/tools/extra |
117 |
+ if use test; then |
118 |
+ git-r3_checkout https://llvm.org/git/llvm.git \ |
119 |
+ "${WORKDIR}"/llvm '' \ |
120 |
+ lib/Testing/Support utils/{lit,llvm-lit,unittest} |
121 |
+ fi |
122 |
+ git-r3_checkout "${EGIT_REPO_URI}" "${S}" |
123 |
+} |
124 |
+ |
125 |
+multilib_src_configure() { |
126 |
+ local llvm_version=$(llvm-config --version) || die |
127 |
+ local clang_version=$(ver_cut 1-3 "${llvm_version}") |
128 |
+ |
129 |
+ local mycmakeargs=( |
130 |
+ # ensure that the correct llvm-config is used |
131 |
+ -DLLVM_CONFIG="$(type -P "${CHOST}-llvm-config")" |
132 |
+ -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr/lib/llvm/${SLOT}" |
133 |
+ -DCMAKE_INSTALL_MANDIR="${EPREFIX}/usr/lib/llvm/${SLOT}/share/man" |
134 |
+ # relative to bindir |
135 |
+ -DCLANG_RESOURCE_DIR="../../../../lib/clang/${clang_version}" |
136 |
+ |
137 |
+ -DBUILD_SHARED_LIBS=ON |
138 |
+ -DLLVM_TARGETS_TO_BUILD="${LLVM_TARGETS// /;}" |
139 |
+ -DLLVM_BUILD_TESTS=$(usex test) |
140 |
+ |
141 |
+ # these are not propagated reliably, so redefine them |
142 |
+ -DLLVM_ENABLE_EH=ON |
143 |
+ -DLLVM_ENABLE_RTTI=ON |
144 |
+ |
145 |
+ -DCMAKE_DISABLE_FIND_PACKAGE_LibXml2=$(usex !xml) |
146 |
+ # libgomp support fails to find headers without explicit -I |
147 |
+ # furthermore, it provides only syntax checking |
148 |
+ -DCLANG_DEFAULT_OPENMP_RUNTIME=libomp |
149 |
+ |
150 |
+ # override default stdlib and rtlib |
151 |
+ -DCLANG_DEFAULT_CXX_STDLIB=$(usex default-libcxx libc++ "") |
152 |
+ -DCLANG_DEFAULT_RTLIB=$(usex default-compiler-rt compiler-rt "") |
153 |
+ |
154 |
+ -DCLANG_ENABLE_ARCMT=$(usex static-analyzer) |
155 |
+ -DCLANG_ENABLE_STATIC_ANALYZER=$(usex static-analyzer) |
156 |
+ # z3 is not multilib-friendly |
157 |
+ -DCLANG_ANALYZER_BUILD_Z3=$(multilib_native_usex z3) |
158 |
+ ) |
159 |
+ use test && mycmakeargs+=( |
160 |
+ -DLLVM_MAIN_SRC_DIR="${WORKDIR}/llvm" |
161 |
+ -DLLVM_LIT_ARGS="-vv;-j;${LIT_JOBS:-$(makeopts_jobs "${MAKEOPTS}" "$(get_nproc)")}" |
162 |
+ ) |
163 |
+ |
164 |
+ if multilib_is_native_abi; then |
165 |
+ mycmakeargs+=( |
166 |
+ # normally copied from LLVM_INCLUDE_DOCS but the latter |
167 |
+ # is lacking value in stand-alone builds |
168 |
+ -DCLANG_INCLUDE_DOCS=$(usex doc) |
169 |
+ -DCLANG_TOOLS_EXTRA_INCLUDE_DOCS=$(usex doc) |
170 |
+ ) |
171 |
+ use doc && mycmakeargs+=( |
172 |
+ -DLLVM_BUILD_DOCS=ON |
173 |
+ -DLLVM_ENABLE_SPHINX=ON |
174 |
+ -DCLANG_INSTALL_SPHINX_HTML_DIR="${EPREFIX}/usr/share/doc/${PF}/html" |
175 |
+ -DCLANG-TOOLS_INSTALL_SPHINX_HTML_DIR="${EPREFIX}/usr/share/doc/${PF}/tools-extra" |
176 |
+ -DSPHINX_WARNINGS_AS_ERRORS=OFF |
177 |
+ ) |
178 |
+ use z3 && mycmakeargs+=( |
179 |
+ -DZ3_INCLUDE_DIR="${EPREFIX}/usr/include/z3" |
180 |
+ ) |
181 |
+ else |
182 |
+ mycmakeargs+=( |
183 |
+ -DLLVM_TOOL_CLANG_TOOLS_EXTRA_BUILD=OFF |
184 |
+ ) |
185 |
+ fi |
186 |
+ |
187 |
+ if [[ -n ${EPREFIX} ]]; then |
188 |
+ mycmakeargs+=( |
189 |
+ -DGCC_INSTALL_PREFIX="${EPREFIX}/usr" |
190 |
+ ) |
191 |
+ fi |
192 |
+ |
193 |
+ if tc-is-cross-compiler; then |
194 |
+ [[ -x "/usr/bin/clang-tblgen" ]] \ |
195 |
+ || die "/usr/bin/clang-tblgen not found or usable" |
196 |
+ mycmakeargs+=( |
197 |
+ -DCMAKE_CROSSCOMPILING=ON |
198 |
+ -DCLANG_TABLEGEN=/usr/bin/clang-tblgen |
199 |
+ ) |
200 |
+ fi |
201 |
+ |
202 |
+ # LLVM_ENABLE_ASSERTIONS=NO does not guarantee this for us, #614844 |
203 |
+ use debug || local -x CPPFLAGS="${CPPFLAGS} -DNDEBUG" |
204 |
+ cmake-utils_src_configure |
205 |
+} |
206 |
+ |
207 |
+multilib_src_compile() { |
208 |
+ cmake-utils_src_compile |
209 |
+ |
210 |
+ # provide a symlink for tests |
211 |
+ if [[ ! -L ${WORKDIR}/lib/clang ]]; then |
212 |
+ mkdir -p "${WORKDIR}"/lib || die |
213 |
+ ln -s "${BUILD_DIR}/$(get_libdir)/clang" "${WORKDIR}"/lib/clang || die |
214 |
+ fi |
215 |
+} |
216 |
+ |
217 |
+multilib_src_test() { |
218 |
+ # respect TMPDIR! |
219 |
+ local -x LIT_PRESERVES_TMP=1 |
220 |
+ cmake-utils_src_make check-clang |
221 |
+ multilib_is_native_abi && cmake-utils_src_make check-clang-tools |
222 |
+} |
223 |
+ |
224 |
+src_install() { |
225 |
+ MULTILIB_WRAPPED_HEADERS=( |
226 |
+ /usr/include/clang/Config/config.h |
227 |
+ ) |
228 |
+ |
229 |
+ multilib-minimal_src_install |
230 |
+ |
231 |
+ # Move runtime headers to /usr/lib/clang, where they belong |
232 |
+ mv "${ED%/}"/usr/include/clangrt "${ED%/}"/usr/lib/clang || die |
233 |
+ # move (remaining) wrapped headers back |
234 |
+ mv "${ED%/}"/usr/include "${ED%/}"/usr/lib/llvm/${SLOT}/include || die |
235 |
+ |
236 |
+ # Apply CHOST and version suffix to clang tools |
237 |
+ # note: we use two version components here (vs 3 in runtime path) |
238 |
+ local llvm_version=$(llvm-config --version) || die |
239 |
+ local clang_version=$(ver_cut 1 "${llvm_version}") |
240 |
+ local clang_full_version=$(ver_cut 1-3 "${llvm_version}") |
241 |
+ local clang_tools=( clang clang++ clang-cl clang-cpp ) |
242 |
+ local abi i |
243 |
+ |
244 |
+ # cmake gives us: |
245 |
+ # - clang-X |
246 |
+ # - clang -> clang-X |
247 |
+ # - clang++, clang-cl, clang-cpp -> clang |
248 |
+ # we want to have: |
249 |
+ # - clang-X |
250 |
+ # - clang++-X, clang-cl-X, clang-cpp-X -> clang-X |
251 |
+ # - clang, clang++, clang-cl, clang-cpp -> clang*-X |
252 |
+ # also in CHOST variant |
253 |
+ for i in "${clang_tools[@]:1}"; do |
254 |
+ rm "${ED%/}/usr/lib/llvm/${SLOT}/bin/${i}" || die |
255 |
+ dosym "clang-${clang_version}" "/usr/lib/llvm/${SLOT}/bin/${i}-${clang_version}" |
256 |
+ dosym "${i}-${clang_version}" "/usr/lib/llvm/${SLOT}/bin/${i}" |
257 |
+ done |
258 |
+ |
259 |
+ # now create target symlinks for all supported ABIs |
260 |
+ for abi in $(get_all_abis); do |
261 |
+ local abi_chost=$(get_abi_CHOST "${abi}") |
262 |
+ for i in "${clang_tools[@]}"; do |
263 |
+ dosym "${i}-${clang_version}" \ |
264 |
+ "/usr/lib/llvm/${SLOT}/bin/${abi_chost}-${i}-${clang_version}" |
265 |
+ dosym "${abi_chost}-${i}-${clang_version}" \ |
266 |
+ "/usr/lib/llvm/${SLOT}/bin/${abi_chost}-${i}" |
267 |
+ done |
268 |
+ done |
269 |
+ |
270 |
+ # Remove unnecessary headers on FreeBSD, bug #417171 |
271 |
+ if use kernel_FreeBSD; then |
272 |
+ rm "${ED}"usr/lib/clang/${clang_full_version}/include/{std,float,iso,limits,tgmath,varargs}*.h || die |
273 |
+ fi |
274 |
+} |
275 |
+ |
276 |
+multilib_src_install() { |
277 |
+ cmake-utils_src_install |
278 |
+ |
279 |
+ # move headers to /usr/include for wrapping & ABI mismatch checks |
280 |
+ # (also drop the version suffix from runtime headers) |
281 |
+ rm -rf "${ED%/}"/usr/include || die |
282 |
+ mv "${ED%/}"/usr/lib/llvm/${SLOT}/include "${ED%/}"/usr/include || die |
283 |
+ mv "${ED%/}"/usr/lib/llvm/${SLOT}/$(get_libdir)/clang "${ED%/}"/usr/include/clangrt || die |
284 |
+} |
285 |
+ |
286 |
+multilib_src_install_all() { |
287 |
+ python_fix_shebang "${ED}" |
288 |
+ if use static-analyzer; then |
289 |
+ python_optimize "${ED}"usr/lib/llvm/${SLOT}/share/scan-view |
290 |
+ fi |
291 |
+ |
292 |
+ docompress "/usr/lib/llvm/${SLOT}/share/man" |
293 |
+ # match 'html' non-compression |
294 |
+ use doc && docompress -x "/usr/share/doc/${PF}/tools-extra" |
295 |
+ # +x for some reason; TODO: investigate |
296 |
+ use static-analyzer && fperms a-x "/usr/lib/llvm/${SLOT}/share/man/man1/scan-build.1" |
297 |
+} |
298 |
+ |
299 |
+pkg_postinst() { |
300 |
+ if [[ ${ROOT} == / && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then |
301 |
+ eselect compiler-shadow update all |
302 |
+ fi |
303 |
+ |
304 |
+ elog "You can find additional utility scripts in:" |
305 |
+ elog " ${EROOT}/usr/lib/llvm/${SLOT}/share/clang" |
306 |
+ elog "To use these scripts, you will need Python 2.7. Some of them are vim" |
307 |
+ elog "integration scripts (with instructions inside). The run-clang-tidy.py" |
308 |
+ elog "scripts requires the following additional package:" |
309 |
+ elog " dev-python/pyyaml" |
310 |
+} |
311 |
+ |
312 |
+pkg_postrm() { |
313 |
+ if [[ ${ROOT} == / && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then |
314 |
+ eselect compiler-shadow clean all |
315 |
+ fi |
316 |
+} |