1 |
commit: 447c9ba39c9ccc93c3660f6c441142450293eb18 |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Jan 3 21:22:06 2018 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Jan 3 22:21:38 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=447c9ba3 |
7 |
|
8 |
sys-devel/clang: Add a live ebuild for 6.0 branch |
9 |
|
10 |
sys-devel/clang/clang-6.0.9999.ebuild | 283 ++++++++++++++++++++++++++++++++++ |
11 |
1 file changed, 283 insertions(+) |
12 |
|
13 |
diff --git a/sys-devel/clang/clang-6.0.9999.ebuild b/sys-devel/clang/clang-6.0.9999.ebuild |
14 |
new file mode 100644 |
15 |
index 00000000000..48c2d57fbee |
16 |
--- /dev/null |
17 |
+++ b/sys-devel/clang/clang-6.0.9999.ebuild |
18 |
@@ -0,0 +1,283 @@ |
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 pax-utils python-single-r1 toolchain-funcs |
31 |
+ |
32 |
+DESCRIPTION="C language family frontend for LLVM" |
33 |
+HOMEPAGE="https://llvm.org/" |
34 |
+SRC_URI="" |
35 |
+EGIT_REPO_URI="https://git.llvm.org/git/clang.git |
36 |
+ https://github.com/llvm-mirror/clang.git" |
37 |
+EGIT_BRANCH="release_60" |
38 |
+ |
39 |
+# Keep in sync with sys-devel/llvm |
40 |
+ALL_LLVM_EXPERIMENTAL_TARGETS=( AVR Nios2 RISCV WebAssembly ) |
41 |
+ALL_LLVM_TARGETS=( AArch64 AMDGPU ARM BPF Hexagon Lanai Mips MSP430 |
42 |
+ NVPTX PowerPC Sparc SystemZ X86 XCore |
43 |
+ "${ALL_LLVM_EXPERIMENTAL_TARGETS[@]}" ) |
44 |
+ALL_LLVM_TARGETS=( "${ALL_LLVM_TARGETS[@]/#/llvm_targets_}" ) |
45 |
+LLVM_TARGET_USEDEPS=${ALL_LLVM_TARGETS[@]/%/?} |
46 |
+ |
47 |
+LICENSE="UoI-NCSA" |
48 |
+SLOT="$(ver_cut 1)" |
49 |
+KEYWORDS="" |
50 |
+IUSE="debug default-compiler-rt default-libcxx doc +static-analyzer |
51 |
+ test xml z3 kernel_FreeBSD ${ALL_LLVM_TARGETS[*]}" |
52 |
+RESTRICT="!test? ( test )" |
53 |
+ |
54 |
+RDEPEND=" |
55 |
+ ~sys-devel/llvm-${PV}:${SLOT}=[debug=,${LLVM_TARGET_USEDEPS// /,},${MULTILIB_USEDEP}] |
56 |
+ static-analyzer? ( |
57 |
+ dev-lang/perl:* |
58 |
+ z3? ( sci-mathematics/z3:0= ) |
59 |
+ ) |
60 |
+ xml? ( dev-libs/libxml2:2=[${MULTILIB_USEDEP}] ) |
61 |
+ ${PYTHON_DEPS}" |
62 |
+# configparser-3.2 breaks the build (3.3 or none at all are fine) |
63 |
+DEPEND="${RDEPEND} |
64 |
+ doc? ( dev-python/sphinx ) |
65 |
+ xml? ( virtual/pkgconfig ) |
66 |
+ !!<dev-python/configparser-3.3.0.2 |
67 |
+ ${PYTHON_DEPS}" |
68 |
+RDEPEND="${RDEPEND} |
69 |
+ !<sys-devel/llvm-4.0.0_rc:0 |
70 |
+ !sys-devel/clang:0" |
71 |
+PDEPEND=" |
72 |
+ ~sys-devel/clang-runtime-${PV} |
73 |
+ default-compiler-rt? ( =sys-libs/compiler-rt-${PV%_*}* ) |
74 |
+ default-libcxx? ( sys-libs/libcxx )" |
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 '' utils/{lit,llvm-lit,unittest} |
120 |
+ fi |
121 |
+ git-r3_checkout "${EGIT_REPO_URI}" "${S}" |
122 |
+} |
123 |
+ |
124 |
+multilib_src_configure() { |
125 |
+ local llvm_version=$(llvm-config --version) || die |
126 |
+ local clang_version=$(ver_cut 1-3 "${llvm_version}") |
127 |
+ |
128 |
+ local mycmakeargs=( |
129 |
+ # ensure that the correct llvm-config is used |
130 |
+ -DLLVM_CONFIG="$(type -P "${CHOST}-llvm-config")" |
131 |
+ -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr/lib/llvm/${SLOT}" |
132 |
+ # relative to bindir |
133 |
+ -DCLANG_RESOURCE_DIR="../../../../lib/clang/${clang_version}" |
134 |
+ |
135 |
+ -DBUILD_SHARED_LIBS=ON |
136 |
+ -DLLVM_TARGETS_TO_BUILD="${LLVM_TARGETS// /;}" |
137 |
+ -DLLVM_BUILD_TESTS=$(usex test) |
138 |
+ |
139 |
+ # these are not propagated reliably, so redefine them |
140 |
+ -DLLVM_ENABLE_EH=ON |
141 |
+ -DLLVM_ENABLE_RTTI=ON |
142 |
+ |
143 |
+ -DCMAKE_DISABLE_FIND_PACKAGE_LibXml2=$(usex !xml) |
144 |
+ # libgomp support fails to find headers without explicit -I |
145 |
+ # furthermore, it provides only syntax checking |
146 |
+ -DCLANG_DEFAULT_OPENMP_RUNTIME=libomp |
147 |
+ |
148 |
+ # override default stdlib and rtlib |
149 |
+ -DCLANG_DEFAULT_CXX_STDLIB=$(usex default-libcxx libc++ "") |
150 |
+ -DCLANG_DEFAULT_RTLIB=$(usex default-compiler-rt compiler-rt "") |
151 |
+ |
152 |
+ -DCLANG_ENABLE_ARCMT=$(usex static-analyzer) |
153 |
+ -DCLANG_ENABLE_STATIC_ANALYZER=$(usex static-analyzer) |
154 |
+ # z3 is not multilib-friendly |
155 |
+ -DCLANG_ANALYZER_BUILD_Z3=$(multilib_native_usex z3) |
156 |
+ ) |
157 |
+ use test && mycmakeargs+=( |
158 |
+ -DLLVM_MAIN_SRC_DIR="${WORKDIR}/llvm" |
159 |
+ -DLLVM_LIT_ARGS="-vv" |
160 |
+ ) |
161 |
+ |
162 |
+ if multilib_is_native_abi; then |
163 |
+ mycmakeargs+=( |
164 |
+ # normally copied from LLVM_INCLUDE_DOCS but the latter |
165 |
+ # is lacking value in stand-alone builds |
166 |
+ -DCLANG_INCLUDE_DOCS=$(usex doc) |
167 |
+ -DCLANG_TOOLS_EXTRA_INCLUDE_DOCS=$(usex doc) |
168 |
+ ) |
169 |
+ use doc && mycmakeargs+=( |
170 |
+ -DLLVM_BUILD_DOCS=ON |
171 |
+ -DLLVM_ENABLE_SPHINX=ON |
172 |
+ -DCLANG_INSTALL_SPHINX_HTML_DIR="${EPREFIX}/usr/share/doc/${PF}/html" |
173 |
+ -DCLANG-TOOLS_INSTALL_SPHINX_HTML_DIR="${EPREFIX}/usr/share/doc/${PF}/tools-extra" |
174 |
+ -DSPHINX_WARNINGS_AS_ERRORS=OFF |
175 |
+ ) |
176 |
+ use z3 && mycmakeargs+=( |
177 |
+ -DZ3_INCLUDE_DIR="${EPREFIX}/usr/include/z3" |
178 |
+ ) |
179 |
+ else |
180 |
+ mycmakeargs+=( |
181 |
+ -DLLVM_TOOL_CLANG_TOOLS_EXTRA_BUILD=OFF |
182 |
+ ) |
183 |
+ fi |
184 |
+ |
185 |
+ if tc-is-cross-compiler; then |
186 |
+ [[ -x "/usr/bin/clang-tblgen" ]] \ |
187 |
+ || die "/usr/bin/clang-tblgen not found or usable" |
188 |
+ mycmakeargs+=( |
189 |
+ -DCMAKE_CROSSCOMPILING=ON |
190 |
+ -DCLANG_TABLEGEN=/usr/bin/clang-tblgen |
191 |
+ ) |
192 |
+ fi |
193 |
+ |
194 |
+ # LLVM_ENABLE_ASSERTIONS=NO does not guarantee this for us, #614844 |
195 |
+ use debug || local -x CPPFLAGS="${CPPFLAGS} -DNDEBUG" |
196 |
+ cmake-utils_src_configure |
197 |
+} |
198 |
+ |
199 |
+multilib_src_compile() { |
200 |
+ cmake-utils_src_compile |
201 |
+ |
202 |
+ # provide a symlink for tests |
203 |
+ if [[ ! -L ${WORKDIR}/lib/clang ]]; then |
204 |
+ mkdir -p "${WORKDIR}"/lib || die |
205 |
+ ln -s "${BUILD_DIR}/$(get_libdir)/clang" "${WORKDIR}"/lib/clang || die |
206 |
+ fi |
207 |
+} |
208 |
+ |
209 |
+multilib_src_test() { |
210 |
+ # respect TMPDIR! |
211 |
+ local -x LIT_PRESERVES_TMP=1 |
212 |
+ cmake-utils_src_make check-clang |
213 |
+ multilib_is_native_abi && cmake-utils_src_make check-clang-tools |
214 |
+} |
215 |
+ |
216 |
+src_install() { |
217 |
+ MULTILIB_WRAPPED_HEADERS=( |
218 |
+ /usr/include/clang/Config/config.h |
219 |
+ ) |
220 |
+ |
221 |
+ multilib-minimal_src_install |
222 |
+ |
223 |
+ # Move runtime headers to /usr/lib/clang, where they belong |
224 |
+ mv "${ED%/}"/usr/include/clangrt "${ED%/}"/usr/lib/clang || die |
225 |
+ # move (remaining) wrapped headers back |
226 |
+ mv "${ED%/}"/usr/include "${ED%/}"/usr/lib/llvm/${SLOT}/include || die |
227 |
+ |
228 |
+ # Apply CHOST and version suffix to clang tools |
229 |
+ # note: we use two version components here (vs 3 in runtime path) |
230 |
+ local llvm_version=$(llvm-config --version) || die |
231 |
+ local clang_version=$(ver_cut 1-2 "${llvm_version}") |
232 |
+ local clang_full_version=$(ver_cut 1-3 "${llvm_version}") |
233 |
+ local clang_tools=( clang clang++ clang-cl clang-cpp ) |
234 |
+ local abi i |
235 |
+ |
236 |
+ # cmake gives us: |
237 |
+ # - clang-X.Y |
238 |
+ # - clang -> clang-X.Y |
239 |
+ # - clang++, clang-cl, clang-cpp -> clang |
240 |
+ # we want to have: |
241 |
+ # - clang-X.Y |
242 |
+ # - clang++-X.Y, clang-cl-X.Y, clang-cpp-X.Y -> clang-X.Y |
243 |
+ # - clang, clang++, clang-cl, clang-cpp -> clang*-X.Y |
244 |
+ # also in CHOST variant |
245 |
+ for i in "${clang_tools[@]:1}"; do |
246 |
+ rm "${ED%/}/usr/lib/llvm/${SLOT}/bin/${i}" || die |
247 |
+ dosym "clang-${clang_version}" "/usr/lib/llvm/${SLOT}/bin/${i}-${clang_version}" |
248 |
+ dosym "${i}-${clang_version}" "/usr/lib/llvm/${SLOT}/bin/${i}" |
249 |
+ done |
250 |
+ |
251 |
+ # now create target symlinks for all supported ABIs |
252 |
+ for abi in $(get_all_abis); do |
253 |
+ local abi_chost=$(get_abi_CHOST "${abi}") |
254 |
+ for i in "${clang_tools[@]}"; do |
255 |
+ dosym "${i}-${clang_version}" \ |
256 |
+ "/usr/lib/llvm/${SLOT}/bin/${abi_chost}-${i}-${clang_version}" |
257 |
+ dosym "${abi_chost}-${i}-${clang_version}" \ |
258 |
+ "/usr/lib/llvm/${SLOT}/bin/${abi_chost}-${i}" |
259 |
+ done |
260 |
+ done |
261 |
+ |
262 |
+ # Remove unnecessary headers on FreeBSD, bug #417171 |
263 |
+ if use kernel_FreeBSD; then |
264 |
+ rm "${ED}"usr/lib/clang/${clang_full_version}/include/{std,float,iso,limits,tgmath,varargs}*.h || die |
265 |
+ fi |
266 |
+} |
267 |
+ |
268 |
+multilib_src_install() { |
269 |
+ cmake-utils_src_install |
270 |
+ |
271 |
+ # move headers to /usr/include for wrapping & ABI mismatch checks |
272 |
+ # (also drop the version suffix from runtime headers) |
273 |
+ rm -rf "${ED%/}"/usr/include || die |
274 |
+ mv "${ED%/}"/usr/lib/llvm/${SLOT}/include "${ED%/}"/usr/include || die |
275 |
+ mv "${ED%/}"/usr/lib/llvm/${SLOT}/$(get_libdir)/clang "${ED%/}"/usr/include/clangrt || die |
276 |
+} |
277 |
+ |
278 |
+multilib_src_install_all() { |
279 |
+ python_fix_shebang "${ED}" |
280 |
+ if use static-analyzer; then |
281 |
+ python_optimize "${ED}"usr/lib/llvm/${SLOT}/share/scan-view |
282 |
+ fi |
283 |
+ |
284 |
+ docompress "/usr/lib/llvm/${SLOT}/share/man" |
285 |
+ # match 'html' non-compression |
286 |
+ use doc && docompress -x "/usr/share/doc/${PF}/tools-extra" |
287 |
+ # +x for some reason; TODO: investigate |
288 |
+ use static-analyzer && fperms a-x "/usr/lib/llvm/${SLOT}/share/man/man1/scan-build.1" |
289 |
+} |
290 |
+ |
291 |
+pkg_postinst() { |
292 |
+ if [[ ${ROOT} == / && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then |
293 |
+ eselect compiler-shadow update all |
294 |
+ fi |
295 |
+} |
296 |
+ |
297 |
+pkg_postrm() { |
298 |
+ if [[ ${ROOT} == / && -f ${EPREFIX}/usr/share/eselect/modules/compiler-shadow.eselect ]] ; then |
299 |
+ eselect compiler-shadow clean all |
300 |
+ fi |
301 |
+} |