Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-devel/clang/, sys-devel/clang/files/9999/
Date: Mon, 22 Aug 2016 15:12:08
Message-Id: 1471878709.4ab9c2e321dbe726cbf8083adc157d1bc63e36de.mgorny@gentoo
1 commit: 4ab9c2e321dbe726cbf8083adc157d1bc63e36de
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Sat Aug 20 21:38:24 2016 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Mon Aug 22 15:11:49 2016 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4ab9c2e3
7
8 sys-devel/clang: Enable stand-alone builds against sys-devel/llvm
9
10 sys-devel/clang/clang-9999-r100.ebuild | 36 ---
11 sys-devel/clang/clang-9999.ebuild | 265 +++++++++++++++++++++
12 ...rdering-dep-between-HTML-Sphinx-docs-and-.patch | 27 +++
13 ...ort-obtaining-active-toolchain-from-gcc-c.patch | 46 ++++
14 ...ort-checking-for-rlimits-via-cmake-when-b.patch | 84 +++++++
15 ...t-llvm-lit-search-to-match-the-one-in-LLV.patch | 29 +++
16 ...rting-overriding-runtime-libdir-via-CLANG.patch | 86 +++++++
17 ...LANG_GOLD_LIBDIR_SUFFIX-to-specify-loc-of.patch | 64 +++++
18 ...port-stand-alone-Sphinx-doxygen-doc-build.patch | 64 +++++
19 sys-devel/clang/metadata.xml | 2 +
20 10 files changed, 667 insertions(+), 36 deletions(-)
21
22 diff --git a/sys-devel/clang/clang-9999-r100.ebuild b/sys-devel/clang/clang-9999-r100.ebuild
23 deleted file mode 100644
24 index eb10ee5..0000000
25 --- a/sys-devel/clang/clang-9999-r100.ebuild
26 +++ /dev/null
27 @@ -1,36 +0,0 @@
28 -# Copyright 1999-2016 Gentoo Foundation
29 -# Distributed under the terms of the GNU General Public License v2
30 -# $Id$
31 -
32 -EAPI=5
33 -
34 -inherit multilib-build
35 -
36 -DESCRIPTION="C language family frontend for LLVM (meta-ebuild)"
37 -HOMEPAGE="http://clang.llvm.org/"
38 -SRC_URI=""
39 -
40 -LICENSE="UoI-NCSA"
41 -SLOT="0/${PV}"
42 -KEYWORDS=""
43 -IUSE="debug multitarget python +static-analyzer"
44 -
45 -RDEPEND="~sys-devel/llvm-${PV}[clang(-),debug=,multitarget?,python?,static-analyzer?,${MULTILIB_USEDEP}]"
46 -
47 -# Please keep this package around since it's quite likely that we'll
48 -# return to separate LLVM & clang ebuilds when the cmake build system
49 -# is complete.
50 -
51 -pkg_postinst() {
52 - if has_version ">=dev-util/ccache-3.1.9-r2" ; then
53 - #add ccache links as clang might get installed after ccache
54 - "${EROOT}"/usr/bin/ccache-config --install-links
55 - fi
56 -}
57 -
58 -pkg_postrm() {
59 - if has_version ">=dev-util/ccache-3.1.9-r2" && [[ -z ${REPLACED_BY_VERSION} ]]; then
60 - # --remove-links would remove all links, --install-links updates them
61 - "${EROOT}"/usr/bin/ccache-config --install-links
62 - fi
63 -}
64
65 diff --git a/sys-devel/clang/clang-9999.ebuild b/sys-devel/clang/clang-9999.ebuild
66 new file mode 100644
67 index 0000000..ad0fcf3
68 --- /dev/null
69 +++ b/sys-devel/clang/clang-9999.ebuild
70 @@ -0,0 +1,265 @@
71 +# Copyright 1999-2016 Gentoo Foundation
72 +# Distributed under the terms of the GNU General Public License v2
73 +# $Id$
74 +
75 +EAPI=6
76 +
77 +: ${CMAKE_MAKEFILE_GENERATOR:=ninja}
78 +CMAKE_MIN_VERSION=3.4.3
79 +PYTHON_COMPAT=( python2_7 )
80 +
81 +inherit check-reqs cmake-utils flag-o-matic git-r3 multilib-minimal \
82 + python-single-r1 toolchain-funcs pax-utils
83 +
84 +DESCRIPTION="C language family frontend for LLVM"
85 +HOMEPAGE="http://llvm.org/"
86 +SRC_URI=""
87 +EGIT_REPO_URI="http://llvm.org/git/clang.git
88 + https://github.com/llvm-mirror/clang.git"
89 +
90 +LICENSE="UoI-NCSA"
91 +SLOT="0/${PV%.*}"
92 +KEYWORDS=""
93 +IUSE="debug default-compiler-rt default-libcxx +doc multitarget python
94 + +static-analyzer test xml video_cards_radeon elibc_musl kernel_FreeBSD"
95 +
96 +RDEPEND="
97 + ~sys-devel/llvm-${PV}:=[debug=,multitarget?,video_cards_radeon?,${MULTILIB_USEDEP}]
98 + static-analyzer? ( dev-lang/perl:* )
99 + xml? ( dev-libs/libxml2:2=[${MULTILIB_USEDEP}] )
100 + !<sys-devel/llvm-${PV}
101 + ${PYTHON_DEPS}"
102 +# configparser-3.2 breaks the build (3.3 or none at all are fine)
103 +DEPEND="${RDEPEND}
104 + doc? ( dev-python/sphinx )
105 + xml? ( virtual/pkgconfig )
106 + !!<dev-python/configparser-3.3.0.2
107 + ${PYTHON_DEPS}"
108 +PDEPEND="
109 + default-compiler-rt? ( sys-libs/compiler-rt )
110 + default-libcxx? ( sys-libs/libcxx )"
111 +
112 +REQUIRED_USE="${PYTHON_REQUIRED_USE}"
113 +
114 +pkg_pretend() {
115 + local build_size=650
116 +
117 + if use debug; then
118 + ewarn "USE=debug is known to increase the size of package considerably"
119 + ewarn "and cause the tests to fail."
120 + ewarn
121 +
122 + (( build_size *= 14 ))
123 + elif is-flagq '-g?(gdb)?([1-9])'; then
124 + ewarn "The C++ compiler -g option is known to increase the size of the package"
125 + ewarn "considerably. If you run out of space, please consider removing it."
126 + ewarn
127 +
128 + (( build_size *= 10 ))
129 + fi
130 +
131 + # Multiply by number of ABIs :).
132 + local abis=( $(multilib_get_enabled_abis) )
133 + (( build_size *= ${#abis[@]} ))
134 +
135 + local CHECKREQS_DISK_BUILD=${build_size}M
136 + check-reqs_pkg_pretend
137 +}
138 +
139 +pkg_setup() {
140 + pkg_pretend
141 +
142 + python-single-r1_pkg_setup
143 +}
144 +
145 +src_unpack() {
146 + git-r3_fetch "http://llvm.org/git/clang-tools-extra.git
147 + https://github.com/llvm-mirror/clang-tools-extra.git"
148 + git-r3_fetch
149 +
150 + git-r3_checkout http://llvm.org/git/clang-tools-extra.git \
151 + "${S}"/tools/clang/tools/extra
152 + git-r3_checkout
153 +}
154 +
155 +src_prepare() {
156 + python_setup
157 +
158 + # fix race condition between sphinx targets
159 + eapply "${FILESDIR}"/9999/0001-cmake-Add-ordering-dep-between-HTML-Sphinx-docs-and-.patch
160 + # automatically select active system GCC's libraries, bugs #406163 and #417913
161 + # TODO: cross-linux tests broken by this one
162 + eapply "${FILESDIR}"/9999/0002-driver-Support-obtaining-active-toolchain-from-gcc-c.patch
163 + # use cmake checks for rlimits, rather than __has_include_next()
164 + eapply "${FILESDIR}"/9999/0003-driver-Support-checking-for-rlimits-via-cmake-when-b.patch
165 + # adjust llvm-lit search to match LLVM cmake macros
166 + eapply "${FILESDIR}"/9999/0004-cmake-Adjust-llvm-lit-search-to-match-the-one-in-LLV.patch
167 + # support overriding clang runtime install directory
168 + eapply "${FILESDIR}"/9999/0005-cmake-Supporting-overriding-runtime-libdir-via-CLANG.patch
169 + # support overriding LLVMgold.so plugin directory
170 + eapply "${FILESDIR}"/9999/0006-cmake-Add-CLANG_GOLD_LIBDIR_SUFFIX-to-specify-loc-of.patch
171 + # fix stand-alone doc build
172 + eapply "${FILESDIR}"/9999/0007-cmake-Support-stand-alone-Sphinx-doxygen-doc-build.patch
173 +
174 + # User patches
175 + eapply_user
176 +
177 + # Native libdir is used to hold LLVMgold.so
178 + NATIVE_LIBDIR=$(get_libdir)
179 +}
180 +
181 +multilib_src_configure() {
182 + local targets
183 + if use multitarget; then
184 + targets=all
185 + else
186 + targets='host;BPF'
187 + use video_cards_radeon && targets+=';AMDGPU'
188 + fi
189 +
190 + local libdir=$(get_libdir)
191 + local mycmakeargs=(
192 + -DLLVM_LIBDIR_SUFFIX=${libdir#lib}
193 + # install clang runtime straight into /usr/lib
194 + -DCLANG_LIBDIR_SUFFIX=""
195 + # specify host's binutils gold plugin path
196 + -DCLANG_GOLD_LIBDIR_SUFFIX="${NATIVE_LIBDIR#lib}"
197 +
198 + -DBUILD_SHARED_LIBS=ON
199 + -DLLVM_TARGETS_TO_BUILD="${targets}"
200 + # TODO: get them properly conditional
201 + #-DLLVM_BUILD_TESTS=$(usex test)
202 +
203 + -DCMAKE_DISABLE_FIND_PACKAGE_LibXml2=$(usex !xml)
204 + # libgomp support fails to find headers without explicit -I
205 + # furthermore, it provides only syntax checking
206 + -DCLANG_DEFAULT_OPENMP_RUNTIME=libomp
207 +
208 + # override default stdlib and rtlib
209 + -DCLANG_DEFAULT_CXX_STDLIB=$(usex default-libcxx libc++ "")
210 + -DCLANG_DEFAULT_RTLIB=$(usex default-compiler-rt compiler-rt "")
211 +
212 + -DCLANG_ENABLE_ARCMT=$(usex static-analyzer)
213 + -DCLANG_ENABLE_STATIC_ANALYZER=$(usex static-analyzer)
214 + )
215 +
216 + if multilib_is_native_abi; then
217 + mycmakeargs+=(
218 + # TODO: docs don't work out-of-llvm
219 + -DLLVM_BUILD_DOCS=$(usex doc)
220 + -DLLVM_ENABLE_SPHINX=$(usex doc)
221 + -DLLVM_ENABLE_DOXYGEN=OFF
222 + -DCLANG_INSTALL_HTML="${EPREFIX}/usr/share/doc/${PF}/clang"
223 + -DSPHINX_WARNINGS_AS_ERRORS=OFF
224 + )
225 + else
226 + mycmakeargs+=(
227 + -DLLVM_EXTERNAL_CLANG_TOOLS_EXTRA_BUILD=OFF
228 + )
229 + fi
230 +
231 + if tc-is-cross-compiler; then
232 + [[ -x "/usr/bin/clang-tblgen" ]] \
233 + || die "/usr/bin/clang-tblgen not found or usable"
234 + mycmakeargs+=(
235 + -DCMAKE_CROSSCOMPILING=ON
236 + -DCLANG_TABLEGEN=/usr/bin/clang-tblgen
237 + )
238 + fi
239 +
240 + cmake-utils_src_configure
241 +}
242 +
243 +multilib_src_compile() {
244 + cmake-utils_src_compile
245 +}
246 +
247 +multilib_src_test() {
248 + # respect TMPDIR!
249 + local -x LIT_PRESERVES_TMP=1
250 + cmake-utils_src_make check-clang
251 +}
252 +
253 +src_install() {
254 + # note: magic applied in multilib_src_install()!
255 + CLANG_VERSION=4.0
256 +
257 + MULTILIB_CHOST_TOOLS=(
258 + /usr/bin/clang
259 + /usr/bin/clang++
260 + /usr/bin/clang-cl
261 + /usr/bin/clang-${CLANG_VERSION}
262 + /usr/bin/clang++-${CLANG_VERSION}
263 + /usr/bin/clang-cl-${CLANG_VERSION}
264 + )
265 +
266 + MULTILIB_WRAPPED_HEADERS=(
267 + /usr/include/clang/Config/config.h
268 + )
269 +
270 + multilib-minimal_src_install
271 +
272 + # Remove unnecessary headers on FreeBSD, bug #417171
273 + if use kernel_FreeBSD && use clang; then
274 + rm "${ED}"usr/lib/clang/${PV}/include/{std,float,iso,limits,tgmath,varargs}*.h || die
275 + fi
276 +}
277 +
278 +multilib_src_install() {
279 + cmake-utils_src_install
280 +
281 + # apply CHOST and CLANG_VERSION to clang executables
282 + # they're statically linked so we don't have to worry about the lib
283 + local clang_tools=( clang clang++ clang-cl )
284 + local i
285 +
286 + # cmake gives us:
287 + # - clang-X.Y
288 + # - clang -> clang-X.Y
289 + # - clang++, clang-cl -> clang
290 + # we want to have:
291 + # - clang-X.Y
292 + # - clang++-X.Y, clang-cl-X.Y -> clang-X.Y
293 + # - clang, clang++, clang-cl -> clang*-X.Y
294 + # so we need to fix the two tools
295 + for i in "${clang_tools[@]:1}"; do
296 + rm "${ED%/}/usr/bin/${i}" || die
297 + dosym "clang-${CLANG_VERSION}" "/usr/bin/${i}-${CLANG_VERSION}"
298 + dosym "${i}-${CLANG_VERSION}" "/usr/bin/${i}"
299 + done
300 +
301 + # now prepend ${CHOST} and let the multilib-build.eclass symlink it
302 + if ! multilib_is_native_abi; then
303 + # non-native? let's replace it with a simple wrapper
304 + for i in "${clang_tools[@]}"; do
305 + rm "${ED%/}/usr/bin/${i}-${CLANG_VERSION}" || die
306 + cat > "${T}"/wrapper.tmp <<-_EOF_
307 + #!${EPREFIX}/bin/sh
308 + exec "${i}-${CLANG_VERSION}" $(get_abi_CFLAGS) "\${@}"
309 + _EOF_
310 + newbin "${T}"/wrapper.tmp "${i}-${CLANG_VERSION}"
311 + done
312 + fi
313 +}
314 +
315 +multilib_src_install_all() {
316 + if use python ; then
317 + pushd bindings/python/clang >/dev/null || die
318 +
319 + python_moduleinto clang
320 + python_domodule *.py
321 +
322 + popd >/dev/null || die
323 + fi
324 +
325 + python_fix_shebang "${ED}"
326 + if use static-analyzer; then
327 + python_optimize "${ED}"usr/share/scan-view
328 + fi
329 +}
330 +
331 +pkg_postinst() {
332 + if ! has_version 'sys-libs/libomp'; then
333 + elog "To enable OpenMP support in clang, install sys-libs/libomp."
334 + fi
335 +}
336
337 diff --git a/sys-devel/clang/files/9999/0001-cmake-Add-ordering-dep-between-HTML-Sphinx-docs-and-.patch b/sys-devel/clang/files/9999/0001-cmake-Add-ordering-dep-between-HTML-Sphinx-docs-and-.patch
338 new file mode 100644
339 index 0000000..35fc19d
340 --- /dev/null
341 +++ b/sys-devel/clang/files/9999/0001-cmake-Add-ordering-dep-between-HTML-Sphinx-docs-and-.patch
342 @@ -0,0 +1,27 @@
343 +From ec16b3f76a26a3a10b0272d012b306963fa93013 Mon Sep 17 00:00:00 2001
344 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@g.o>
345 +Date: Sun, 21 Aug 2016 23:24:19 +0200
346 +Subject: [PATCH 1/7] cmake: Add ordering dep between HTML Sphinx docs and
347 + manpages
348 +
349 +---
350 + docs/CMakeLists.txt | 3 +++
351 + 1 file changed, 3 insertions(+)
352 +
353 +diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt
354 +index 13b79fdf..bd75b63 100644
355 +--- a/docs/CMakeLists.txt
356 ++++ b/docs/CMakeLists.txt
357 +@@ -102,6 +102,9 @@ if (LLVM_ENABLE_SPHINX)
358 + endif()
359 + if (${SPHINX_OUTPUT_MAN})
360 + add_sphinx_target(man clang)
361 ++ if (${SPHINX_OUTPUT_HTML})
362 ++ add_dependencies(docs-clang-html docs-clang-man)
363 ++ endif()
364 + endif()
365 + endif()
366 + endif()
367 +--
368 +2.9.3
369 +
370
371 diff --git a/sys-devel/clang/files/9999/0002-driver-Support-obtaining-active-toolchain-from-gcc-c.patch b/sys-devel/clang/files/9999/0002-driver-Support-obtaining-active-toolchain-from-gcc-c.patch
372 new file mode 100644
373 index 0000000..6128cb9
374 --- /dev/null
375 +++ b/sys-devel/clang/files/9999/0002-driver-Support-obtaining-active-toolchain-from-gcc-c.patch
376 @@ -0,0 +1,46 @@
377 +From 67025453e6c2373c8d761f6435e7fa4ddaacd8fa Mon Sep 17 00:00:00 2001
378 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@g.o>
379 +Date: Fri, 5 Sep 2014 16:49:35 +0200
380 +Subject: [PATCH 2/7] driver: Support obtaining active toolchain from
381 + gcc-config on Gentoo
382 +
383 +Author: Richard Yao <ryao@g.o>
384 +Bug: https://bugs.gentoo.org/406163
385 +Bug: https://bugs.gentoo.org/417913
386 +---
387 + lib/Driver/ToolChains.cpp | 19 +++++++++++++++++++
388 + 1 file changed, 19 insertions(+)
389 +
390 +diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp
391 +index 68d5214..7689f86 100644
392 +--- a/lib/Driver/ToolChains.cpp
393 ++++ b/lib/Driver/ToolChains.cpp
394 +@@ -1418,6 +1418,25 @@ void Generic_GCC::GCCInstallationDetector::init(
395 + }
396 + }
397 +
398 ++ for (unsigned k = 0, ke = CandidateTripleAliases.size(); k < ke; ++k) {
399 ++ llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> File =
400 ++ llvm::MemoryBuffer::getFile(D.SysRoot + "/etc/env.d/gcc/config-" + CandidateTripleAliases[k].str());
401 ++ if (File)
402 ++ {
403 ++ const std::string VersionText = File.get()->getBuffer().rsplit('-').second.substr(0,5).str();
404 ++ const std::string GentooPath = D.SysRoot + "/usr/lib/gcc/" + CandidateTripleAliases[k].str() + "/" + VersionText;
405 ++ if (llvm::sys::fs::exists(GentooPath + "/crtbegin.o"))
406 ++ {
407 ++ Version = GCCVersion::Parse(VersionText);
408 ++ GCCInstallPath = GentooPath;
409 ++ GCCParentLibPath = GCCInstallPath + "/../../..";
410 ++ GCCTriple.setTriple(CandidateTripleAliases[k]);
411 ++ IsValid = true;
412 ++ return;
413 ++ }
414 ++ }
415 ++ }
416 ++
417 + // Loop over the various components which exist and select the best GCC
418 + // installation available. GCC installs are ranked by version number.
419 + Version = GCCVersion::Parse("0.0.0");
420 +--
421 +2.9.3
422 +
423
424 diff --git a/sys-devel/clang/files/9999/0003-driver-Support-checking-for-rlimits-via-cmake-when-b.patch b/sys-devel/clang/files/9999/0003-driver-Support-checking-for-rlimits-via-cmake-when-b.patch
425 new file mode 100644
426 index 0000000..16d63ec
427 --- /dev/null
428 +++ b/sys-devel/clang/files/9999/0003-driver-Support-checking-for-rlimits-via-cmake-when-b.patch
429 @@ -0,0 +1,84 @@
430 +From 27b65490c9764d18fa02274bbb4f75dd5a688506 Mon Sep 17 00:00:00 2001
431 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@g.o>
432 +Date: Sun, 21 Aug 2016 23:30:17 +0200
433 +Subject: [PATCH 3/7] driver: Support checking for rlimits via cmake (when
434 + bootstrapping)
435 +
436 +Add a cmake check for sys/resource.h and replace the __has_include()
437 +check with its result, in order to make it possible to use rlimits when
438 +building with compilers not supporting __has_include() -- i.e. when
439 +bootstrapping.
440 +
441 +Patch: https://reviews.llvm.org/D23744
442 +---
443 + CMakeLists.txt | 3 +++
444 + include/clang/Config/config.h.cmake | 3 +++
445 + tools/driver/cc1_main.cpp | 8 +++-----
446 + 3 files changed, 9 insertions(+), 5 deletions(-)
447 +
448 +diff --git a/CMakeLists.txt b/CMakeLists.txt
449 +index e6dde85..aee0d0a 100644
450 +--- a/CMakeLists.txt
451 ++++ b/CMakeLists.txt
452 +@@ -177,6 +177,9 @@ if (LIBXML2_FOUND)
453 + set(CLANG_HAVE_LIBXML 1)
454 + endif()
455 +
456 ++include(CheckIncludeFile)
457 ++check_include_file(sys/resource.h CLANG_HAVE_RLIMITS)
458 ++
459 + set(CLANG_RESOURCE_DIR "" CACHE STRING
460 + "Relative directory from the Clang binary to its resource files.")
461 +
462 +diff --git a/include/clang/Config/config.h.cmake b/include/clang/Config/config.h.cmake
463 +index 9200ed9..9bf9ea5 100644
464 +--- a/include/clang/Config/config.h.cmake
465 ++++ b/include/clang/Config/config.h.cmake
466 +@@ -35,6 +35,9 @@
467 + /* Define if we have libxml2 */
468 + #cmakedefine CLANG_HAVE_LIBXML ${CLANG_HAVE_LIBXML}
469 +
470 ++/* Define if we have sys/resource.h (rlimits) */
471 ++#cmakedefine CLANG_HAVE_RLIMITS ${CLANG_HAVE_RLIMITS}
472 ++
473 + /* The LLVM product name and version */
474 + #define BACKEND_PACKAGE_STRING "${BACKEND_PACKAGE_STRING}"
475 +
476 +diff --git a/tools/driver/cc1_main.cpp b/tools/driver/cc1_main.cpp
477 +index b8cea41..45d44a0 100644
478 +--- a/tools/driver/cc1_main.cpp
479 ++++ b/tools/driver/cc1_main.cpp
480 +@@ -15,6 +15,7 @@
481 +
482 + #include "llvm/Option/Arg.h"
483 + #include "clang/CodeGen/ObjectFilePCHContainerOperations.h"
484 ++#include "clang/Config/config.h"
485 + #include "clang/Driver/DriverDiagnostic.h"
486 + #include "clang/Driver/Options.h"
487 + #include "clang/Frontend/CompilerInstance.h"
488 +@@ -37,12 +38,9 @@
489 + #include "llvm/Support/raw_ostream.h"
490 + #include <cstdio>
491 +
492 +-#ifdef __has_include
493 +-#if __has_include(<sys/resource.h>)
494 +-#define HAVE_RLIMITS
495 ++#ifdef CLANG_HAVE_RLIMITS
496 + #include <sys/resource.h>
497 + #endif
498 +-#endif
499 +
500 + using namespace clang;
501 + using namespace llvm::opt;
502 +@@ -73,7 +71,7 @@ void initializePollyPasses(llvm::PassRegistry &Registry);
503 + }
504 + #endif
505 +
506 +-#ifdef HAVE_RLIMITS
507 ++#ifdef CLANG_HAVE_RLIMITS
508 + // The amount of stack we think is "sufficient". If less than this much is
509 + // available, we may be unable to reach our template instantiation depth
510 + // limit and other similar limits.
511 +--
512 +2.9.3
513 +
514
515 diff --git a/sys-devel/clang/files/9999/0004-cmake-Adjust-llvm-lit-search-to-match-the-one-in-LLV.patch b/sys-devel/clang/files/9999/0004-cmake-Adjust-llvm-lit-search-to-match-the-one-in-LLV.patch
516 new file mode 100644
517 index 0000000..bcf409c
518 --- /dev/null
519 +++ b/sys-devel/clang/files/9999/0004-cmake-Adjust-llvm-lit-search-to-match-the-one-in-LLV.patch
520 @@ -0,0 +1,29 @@
521 +From d7bc0e05e8064e0c939db6c2fb6d215fd0340708 Mon Sep 17 00:00:00 2001
522 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@g.o>
523 +Date: Sun, 21 Aug 2016 23:30:39 +0200
524 +Subject: [PATCH 4/7] cmake: Adjust llvm-lit search to match the one in LLVM
525 +
526 +Adjust the system lit executable search to look for llvm-lit as that is
527 +the name used in AddLLVM.cmake installed by LLVM.
528 +
529 +Patch: https://reviews.llvm.org/D23745
530 +---
531 + CMakeLists.txt | 2 +-
532 + 1 file changed, 1 insertion(+), 1 deletion(-)
533 +
534 +diff --git a/CMakeLists.txt b/CMakeLists.txt
535 +index aee0d0a..e95ab52 100644
536 +--- a/CMakeLists.txt
537 ++++ b/CMakeLists.txt
538 +@@ -140,7 +140,7 @@ Please install Python or specify the PYTHON_EXECUTABLE CMake variable.")
539 + endif()
540 + else()
541 + # Seek installed Lit.
542 +- find_program(LLVM_LIT "lit.py" ${LLVM_MAIN_SRC_DIR}/utils/lit
543 ++ find_program(LLVM_LIT "llvm-lit" ${LLVM_MAIN_SRC_DIR}/utils/lit
544 + DOC "Path to lit.py")
545 + endif()
546 +
547 +--
548 +2.9.3
549 +
550
551 diff --git a/sys-devel/clang/files/9999/0005-cmake-Supporting-overriding-runtime-libdir-via-CLANG.patch b/sys-devel/clang/files/9999/0005-cmake-Supporting-overriding-runtime-libdir-via-CLANG.patch
552 new file mode 100644
553 index 0000000..da737c1
554 --- /dev/null
555 +++ b/sys-devel/clang/files/9999/0005-cmake-Supporting-overriding-runtime-libdir-via-CLANG.patch
556 @@ -0,0 +1,86 @@
557 +From 8864d8f9da1b30c9539e9dc0388c5d0dccca3a34 Mon Sep 17 00:00:00 2001
558 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@g.o>
559 +Date: Sun, 21 Aug 2016 23:31:06 +0200
560 +Subject: [PATCH 5/7] cmake: Supporting overriding runtime libdir via
561 + CLANG_LIBDIR_SUFFIX
562 +
563 +Make it possible to override the value of CLANG_LIBDIR_SUFFIX, and use
564 +it uniformly to control install location of runtimes (i.e. lib/clang),
565 +therefore supporting sharing a common runtime between multiple multilib
566 +variants.
567 +
568 +Previously, CLANG_LIBDIR_SUFFIX was pinned to LLVM_LIBDIR_SUFFIX
569 +and used only to define runtime path in driver code. This patch extends
570 +its use to building and installing the runtime (the former is needed for
571 +tests to work correctly).
572 +
573 +The goal is to support install layout alike "LLVM_LIBDIR_SUFFIX=64
574 +CLANG_LIBDIR_SUFFIX=''" -- where all shared libraries would be installed
575 +into ABI-specific /usr/lib64, while runtime (that is common between
576 +multilib ABIs) would be installed into /usr/lib.
577 +
578 +Bug: https://llvm.org/bugs/show_bug.cgi?id=23792
579 +Patch: https://reviews.llvm.org/D23752
580 +---
581 + CMakeLists.txt | 5 +++--
582 + lib/Headers/CMakeLists.txt | 4 ++--
583 + runtime/CMakeLists.txt | 4 ++--
584 + 3 files changed, 7 insertions(+), 6 deletions(-)
585 +
586 +diff --git a/CMakeLists.txt b/CMakeLists.txt
587 +index e95ab52..67b85b5 100644
588 +--- a/CMakeLists.txt
589 ++++ b/CMakeLists.txt
590 +@@ -235,8 +235,9 @@ endif()
591 + set(CLANG_VENDOR_UTI "org.llvm.clang" CACHE STRING
592 + "Vendor-specific uti.")
593 +
594 +-# The libdir suffix must exactly match whatever LLVM's configuration used.
595 +-set(CLANG_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}")
596 ++set(CLANG_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE
597 ++ STRING "Define suffix of library directory name for clang runtime (32/64)")
598 ++set(CLANG_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${CLANG_LIBDIR_SUFFIX})
599 +
600 + set(CLANG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
601 + set(CLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
602 +diff --git a/lib/Headers/CMakeLists.txt b/lib/Headers/CMakeLists.txt
603 +index 600fece..86a70c5 100644
604 +--- a/lib/Headers/CMakeLists.txt
605 ++++ b/lib/Headers/CMakeLists.txt
606 +@@ -88,7 +88,7 @@ set(files
607 + xtestintrin.h
608 + )
609 +
610 +-set(output_dir ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/include)
611 ++set(output_dir ${CLANG_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/include)
612 +
613 + # Generate arm_neon.h
614 + clang_tablegen(arm_neon.h -gen-arm-neon
615 +@@ -118,7 +118,7 @@ install(
616 + FILES ${files} ${CMAKE_CURRENT_BINARY_DIR}/arm_neon.h
617 + COMPONENT clang-headers
618 + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
619 +- DESTINATION lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include)
620 ++ DESTINATION lib${CLANG_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include)
621 +
622 + if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
623 + add_custom_target(install-clang-headers
624 +diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt
625 +index 814857f..9348615 100644
626 +--- a/runtime/CMakeLists.txt
627 ++++ b/runtime/CMakeLists.txt
628 +@@ -71,9 +71,9 @@ if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND EXISTS ${COMPILER_RT_SRC_ROOT}/)
629 + -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
630 + -DLLVM_CONFIG_PATH=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-config
631 + -DLLVM_LIT_ARGS=${LLVM_LIT_ARGS}
632 +- -DCOMPILER_RT_OUTPUT_DIR=${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}
633 ++ -DCOMPILER_RT_OUTPUT_DIR=${CLANG_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}
634 + -DCOMPILER_RT_EXEC_OUTPUT_DIR=${LLVM_RUNTIME_OUTPUT_INTDIR}
635 +- -DCOMPILER_RT_INSTALL_PATH:STRING=lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}
636 ++ -DCOMPILER_RT_INSTALL_PATH:STRING=lib${CLANG_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}
637 + -DCOMPILER_RT_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
638 + -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
639 + -DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX}
640 +--
641 +2.9.3
642 +
643
644 diff --git a/sys-devel/clang/files/9999/0006-cmake-Add-CLANG_GOLD_LIBDIR_SUFFIX-to-specify-loc-of.patch b/sys-devel/clang/files/9999/0006-cmake-Add-CLANG_GOLD_LIBDIR_SUFFIX-to-specify-loc-of.patch
645 new file mode 100644
646 index 0000000..18adcca
647 --- /dev/null
648 +++ b/sys-devel/clang/files/9999/0006-cmake-Add-CLANG_GOLD_LIBDIR_SUFFIX-to-specify-loc-of.patch
649 @@ -0,0 +1,64 @@
650 +From cf60af04f0ac2836f50d5a042acc89ef76e76a66 Mon Sep 17 00:00:00 2001
651 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@g.o>
652 +Date: Sun, 21 Aug 2016 23:31:28 +0200
653 +Subject: [PATCH 6/7] cmake: Add CLANG_GOLD_LIBDIR_SUFFIX to specify loc of
654 + LLVMgold.so
655 +
656 +Add CLANG_GOLD_LIBDIR_SUFFIX that defaults to ${LLVM_LIBDIR_SUFFIX}
657 +and can be overriden if LLVMgold.so is installed elsewhere. The use case
658 +are multilib systems where binutils is 64-bit and clang is 32-bit,
659 +therefore the gold plugin is installed in 64-bit libdir while clang
660 +is not.
661 +
662 +Bug: https://llvm.org/bugs/show_bug.cgi?id=23793
663 +Patch: https://reviews.llvm.org/D23754
664 +---
665 + CMakeLists.txt | 3 +++
666 + include/clang/Config/config.h.cmake | 3 +++
667 + lib/Driver/Tools.cpp | 2 +-
668 + 3 files changed, 7 insertions(+), 1 deletion(-)
669 +
670 +diff --git a/CMakeLists.txt b/CMakeLists.txt
671 +index 67b85b5..8ed8c10 100644
672 +--- a/CMakeLists.txt
673 ++++ b/CMakeLists.txt
674 +@@ -239,6 +239,9 @@ set(CLANG_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE
675 + STRING "Define suffix of library directory name for clang runtime (32/64)")
676 + set(CLANG_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${CLANG_LIBDIR_SUFFIX})
677 +
678 ++set(CLANG_GOLD_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE
679 ++ STRING "Define suffix of library directory name that contains LLVMgold.so (32/64)")
680 ++
681 + set(CLANG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
682 + set(CLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
683 +
684 +diff --git a/include/clang/Config/config.h.cmake b/include/clang/Config/config.h.cmake
685 +index 9bf9ea5..26e0e7e 100644
686 +--- a/include/clang/Config/config.h.cmake
687 ++++ b/include/clang/Config/config.h.cmake
688 +@@ -20,6 +20,9 @@
689 + /* Multilib suffix for libdir. */
690 + #define CLANG_LIBDIR_SUFFIX "${CLANG_LIBDIR_SUFFIX}"
691 +
692 ++/* Multilib suffix for libdir containing LLVMgold.so. */
693 ++#define CLANG_GOLD_LIBDIR_SUFFIX "${CLANG_GOLD_LIBDIR_SUFFIX}"
694 ++
695 + /* Relative directory for resource files */
696 + #define CLANG_RESOURCE_DIR "${CLANG_RESOURCE_DIR}"
697 +
698 +diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
699 +index a814df3..333a2e9 100644
700 +--- a/lib/Driver/Tools.cpp
701 ++++ b/lib/Driver/Tools.cpp
702 +@@ -2007,7 +2007,7 @@ static void AddGoldPlugin(const ToolChain &ToolChain, const ArgList &Args,
703 + // forward.
704 + CmdArgs.push_back("-plugin");
705 + std::string Plugin =
706 +- ToolChain.getDriver().Dir + "/../lib" CLANG_LIBDIR_SUFFIX "/LLVMgold.so";
707 ++ ToolChain.getDriver().Dir + "/../lib" CLANG_GOLD_LIBDIR_SUFFIX "/LLVMgold.so";
708 + CmdArgs.push_back(Args.MakeArgString(Plugin));
709 +
710 + // Try to pass driver level flags relevant to LTO code generation down to
711 +--
712 +2.9.3
713 +
714
715 diff --git a/sys-devel/clang/files/9999/0007-cmake-Support-stand-alone-Sphinx-doxygen-doc-build.patch b/sys-devel/clang/files/9999/0007-cmake-Support-stand-alone-Sphinx-doxygen-doc-build.patch
716 new file mode 100644
717 index 0000000..0ecd5bc
718 --- /dev/null
719 +++ b/sys-devel/clang/files/9999/0007-cmake-Support-stand-alone-Sphinx-doxygen-doc-build.patch
720 @@ -0,0 +1,64 @@
721 +From 8dd12df445c9a35f7b1c0202eb7c74b954b0980d Mon Sep 17 00:00:00 2001
722 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@g.o>
723 +Date: Sun, 21 Aug 2016 23:31:55 +0200
724 +Subject: [PATCH 7/7] cmake: Support stand-alone Sphinx & doxygen doc build
725 +
726 +Copy the necessary options and configuration checks from LLVM to clang,
727 +to support stand-alone documentation builds.
728 +
729 +Patch: https://reviews.llvm.org/D23758
730 +---
731 + CMakeLists.txt | 37 +++++++++++++++++++++++++++++++++++++
732 + 1 file changed, 37 insertions(+)
733 +
734 +diff --git a/CMakeLists.txt b/CMakeLists.txt
735 +index 8ed8c10..3f34d8c 100644
736 +--- a/CMakeLists.txt
737 ++++ b/CMakeLists.txt
738 +@@ -162,6 +162,43 @@ Please install Python or specify the PYTHON_EXECUTABLE CMake variable.")
739 + endif()
740 + endif()
741 +
742 ++ option (LLVM_BUILD_DOCS "Build the llvm documentation." OFF)
743 ++ option (LLVM_INCLUDE_DOCS "Generate build targets for llvm documentation." ON)
744 ++ option (LLVM_ENABLE_DOXYGEN "Use doxygen to generate llvm API documentation." OFF)
745 ++ option (LLVM_ENABLE_SPHINX "Use Sphinx to generate llvm documentation." OFF)
746 ++
747 ++ if (LLVM_ENABLE_DOXYGEN)
748 ++ message(STATUS "Doxygen enabled.")
749 ++ find_package(Doxygen REQUIRED)
750 ++
751 ++ if (DOXYGEN_FOUND)
752 ++ # If we find doxygen and we want to enable doxygen by default create a
753 ++ # global aggregate doxygen target for generating llvm and any/all
754 ++ # subprojects doxygen documentation.
755 ++ if (LLVM_BUILD_DOCS)
756 ++ add_custom_target(doxygen ALL)
757 ++ endif()
758 ++
759 ++ option(LLVM_DOXYGEN_EXTERNAL_SEARCH "Enable doxygen external search." OFF)
760 ++ if (LLVM_DOXYGEN_EXTERNAL_SEARCH)
761 ++ set(LLVM_DOXYGEN_SEARCHENGINE_URL "" CACHE STRING "URL to use for external search.")
762 ++ set(LLVM_DOXYGEN_SEARCH_MAPPINGS "" CACHE STRING "Doxygen Search Mappings")
763 ++ endif()
764 ++ endif()
765 ++ else()
766 ++ message(STATUS "Doxygen disabled.")
767 ++ endif()
768 ++
769 ++ if (LLVM_ENABLE_SPHINX)
770 ++ message(STATUS "Sphinx enabled.")
771 ++ find_package(Sphinx REQUIRED)
772 ++ if (LLVM_BUILD_DOCS)
773 ++ add_custom_target(sphinx ALL)
774 ++ endif()
775 ++ else()
776 ++ message(STATUS "Sphinx disabled.")
777 ++ endif()
778 ++
779 + set( CLANG_BUILT_STANDALONE 1 )
780 + set(BACKEND_PACKAGE_STRING "LLVM ${LLVM_PACKAGE_VERSION}")
781 + else()
782 +--
783 +2.9.3
784 +
785
786 diff --git a/sys-devel/clang/metadata.xml b/sys-devel/clang/metadata.xml
787 index 28f4559..38b8ec4 100644
788 --- a/sys-devel/clang/metadata.xml
789 +++ b/sys-devel/clang/metadata.xml
790 @@ -27,6 +27,8 @@ A simple and hackable code base
791 A single unified parser for C, Objective C, C++, and Objective C++
792 Conformance with C/C++/ObjC and their variants</longdescription>
793 <use>
794 + <flag name="default-compiler-rt">Use compiler-rt instead of libgcc as the default rtlib for clang</flag>
795 + <flag name="default-libcxx">Use libc++ instead of libstdc++ as the default stdlib for clang</flag>
796 <flag name="multitarget">Build all host targets (default: host only)</flag>
797 <flag name="static-analyzer">Install the Clang static analyzer</flag>
798 </use>