1 |
commit: 8eff1b80294e92ebc2f0273980ccabdc615f85f3 |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Dec 2 19:27:50 2015 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Dec 2 19:55:48 2015 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8eff1b80 |
7 |
|
8 |
sys-devel/llvm: Fix bogus flags and paths in llvm-config, #565358 |
9 |
|
10 |
Fix llvm-config to avoid bogus results. In particular: |
11 |
|
12 |
1. Limit --cflags and --cxxflags to package-specific flags. Do not |
13 |
output the whole flag-string used during the build. This fixes libclc |
14 |
build issues when LLVM build flags were not tolerated by clang. |
15 |
|
16 |
2. Fix library names and paths to use shared library suffix rather than |
17 |
static library suffix, especially that we do not install static |
18 |
libraries. |
19 |
|
20 |
3. Wipe out --system-libs since they should not be required for dynamic |
21 |
linking. |
22 |
|
23 |
4. Ban --obj-root and --src-root when running outside source tree, since |
24 |
we are not installing any sources and therefore their results would |
25 |
always be bogus. |
26 |
|
27 |
Based on patch provided by Steven Newbury. |
28 |
|
29 |
Fixes: https://bugs.gentoo.org/565358 |
30 |
|
31 |
sys-devel/llvm/files/llvm-3.7-llvm-config.patch | 113 +++++++++++++++++++++ |
32 |
.../{llvm-9999.ebuild => llvm-3.7.0-r3.ebuild} | 104 +++++++++++-------- |
33 |
sys-devel/llvm/llvm-9999.ebuild | 4 + |
34 |
3 files changed, 181 insertions(+), 40 deletions(-) |
35 |
|
36 |
diff --git a/sys-devel/llvm/files/llvm-3.7-llvm-config.patch b/sys-devel/llvm/files/llvm-3.7-llvm-config.patch |
37 |
new file mode 100644 |
38 |
index 0000000..932c92b |
39 |
--- /dev/null |
40 |
+++ b/sys-devel/llvm/files/llvm-3.7-llvm-config.patch |
41 |
@@ -0,0 +1,113 @@ |
42 |
+From 8a51e9673859eb3fb819f0d1dad5e2a60d1a3c0a Mon Sep 17 00:00:00 2001 |
43 |
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@g.o> |
44 |
+Date: Wed, 2 Dec 2015 16:04:56 +0100 |
45 |
+Subject: [PATCH] llvm-config: Clean up exported values, update for shared |
46 |
+ linking |
47 |
+ |
48 |
+Gentoo-specific fixup for llvm-config, including: |
49 |
+- wiping build-specific CFLAGS, CXXFLAGS, |
50 |
+- updating library suffixes for shared libs, |
51 |
+- wiping --system-libs for shared linking, |
52 |
+- banning --obj-root and --src-root due to no sources installed. |
53 |
+ |
54 |
+Thanks to Steven Newbury for the initial patch. |
55 |
+ |
56 |
+Bug: https://bugs.gentoo.org/565358 |
57 |
+Bug: https://bugs.gentoo.org/501684 |
58 |
+--- |
59 |
+ tools/llvm-config/CMakeLists.txt | 11 ++++++++--- |
60 |
+ tools/llvm-config/llvm-config.cpp | 22 ++++++++++++++++------ |
61 |
+ utils/llvm-build/llvmbuild/main.py | 4 +++- |
62 |
+ 4 files changed, 27 insertions(+), 10 deletions(-) |
63 |
+ |
64 |
+diff --git a/tools/llvm-config/CMakeLists.txt b/tools/llvm-config/CMakeLists.txt |
65 |
+index edbd8c9..9a801bd 100644 |
66 |
+--- a/tools/llvm-config/CMakeLists.txt |
67 |
++++ b/tools/llvm-config/CMakeLists.txt |
68 |
+@@ -22,12 +22,17 @@ get_property(COMPILE_FLAGS TARGET llvm-config PROPERTY COMPILE_FLAGS) |
69 |
+ set(LLVM_SRC_ROOT ${LLVM_MAIN_SRC_DIR}) |
70 |
+ set(LLVM_OBJ_ROOT ${LLVM_BINARY_DIR}) |
71 |
+ set(LLVM_CPPFLAGS "${CMAKE_CPP_FLAGS} ${CMAKE_CPP_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${LLVM_DEFINITIONS}") |
72 |
+-set(LLVM_CFLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${LLVM_DEFINITIONS}") |
73 |
+-set(LLVM_CXXFLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${COMPILE_FLAGS} ${LLVM_DEFINITIONS}") |
74 |
++# Just use CMAKE_CPP_FLAGS for CFLAGS and CXXFLAGS, otherwise compiler |
75 |
++# specific flags will be set when we don't know what compiler will be used |
76 |
++# with external project utilising llvm-config. C++ Standard is required. |
77 |
++# TODO: figure out if we can remove -std=c++11 and move it to revdeps. |
78 |
++set(LLVM_CFLAGS "${CMAKE_CPP_FLAGS} ${CMAKE_C_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${LLVM_DEFINITIONS}") |
79 |
++set(LLVM_CXXFLAGS "${CMAKE_CPP_FLAGS} -std=c++11 ${CMAKE_CXX_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${LLVM_DEFINITIONS}") |
80 |
+ # Use the C++ link flags, since they should be a superset of C link flags. |
81 |
+ set(LLVM_LDFLAGS "${CMAKE_CXX_LINK_FLAGS}") |
82 |
+ set(LLVM_BUILDMODE ${CMAKE_BUILD_TYPE}) |
83 |
+-set(LLVM_SYSTEM_LIBS ${SYSTEM_LIBS}) |
84 |
++# We don't do static libs, so we don't need to supply any system-libs |
85 |
++set(LLVM_SYSTEM_LIBS "") |
86 |
+ string(REPLACE ";" " " LLVM_TARGETS_BUILT "${LLVM_TARGETS_TO_BUILD}") |
87 |
+ configure_file(${BUILDVARIABLES_SRCPATH} ${BUILDVARIABLES_OBJPATH} @ONLY) |
88 |
+ |
89 |
+diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp |
90 |
+index 879b9ab..d2c43fa 100644 |
91 |
+--- a/tools/llvm-config/llvm-config.cpp |
92 |
++++ b/tools/llvm-config/llvm-config.cpp |
93 |
+@@ -323,10 +323,19 @@ int main(int argc, char **argv) { |
94 |
+ #else |
95 |
+ OS << "ON\n"; |
96 |
+ #endif |
97 |
+- } else if (Arg == "--obj-root") { |
98 |
+- OS << ActivePrefix << '\n'; |
99 |
+- } else if (Arg == "--src-root") { |
100 |
+- OS << LLVM_SRC_ROOT << '\n'; |
101 |
++ } else if (Arg == "--obj-root" || Arg == "--src-root") { |
102 |
++ if (IsInDevelopmentTree) { |
103 |
++ if (Arg == "--obj-root") { |
104 |
++ OS << ActivePrefix << '\n'; |
105 |
++ } else { |
106 |
++ OS << LLVM_SRC_ROOT << '\n'; |
107 |
++ } |
108 |
++ } else { |
109 |
++ // sources are not installed |
110 |
++ llvm::errs() << "llvm-config: sources not installed, " |
111 |
++ << Arg << " not available\n"; |
112 |
++ exit(1); |
113 |
++ } |
114 |
+ } else { |
115 |
+ usage(); |
116 |
+ } |
117 |
+@@ -360,8 +369,9 @@ int main(int argc, char **argv) { |
118 |
+ OS << ActiveLibDir << '/' << Lib; |
119 |
+ } else if (PrintLibs) { |
120 |
+ // If this is a typical library name, include it using -l. |
121 |
+- if (Lib.startswith("lib") && Lib.endswith(".a")) { |
122 |
+- OS << "-l" << Lib.slice(3, Lib.size()-2); |
123 |
++ if (Lib.startswith("lib") && Lib.endswith(LTDL_SHLIB_EXT)) { |
124 |
++ // sizeof counts trailing NUL |
125 |
++ OS << "-l" << Lib.slice(3, Lib.size()-sizeof(LTDL_SHLIB_EXT)+1); |
126 |
+ continue; |
127 |
+ } |
128 |
+ |
129 |
+diff --git a/utils/llvm-build/llvmbuild/main.py b/utils/llvm-build/llvmbuild/main.py |
130 |
+index 353741f..4ba5e91 100644 |
131 |
+--- a/utils/llvm-build/llvmbuild/main.py |
132 |
++++ b/utils/llvm-build/llvmbuild/main.py |
133 |
+@@ -393,6 +393,8 @@ subdirectories = %s |
134 |
+ // |
135 |
+ //===----------------------------------------------------------------------===// |
136 |
+ |
137 |
++#include "llvm/Config/config.h" |
138 |
++ |
139 |
+ """) |
140 |
+ f.write('struct AvailableComponent {\n') |
141 |
+ f.write(' /// The name of the component.\n') |
142 |
+@@ -413,7 +415,7 @@ subdirectories = %s |
143 |
+ if library_name is None: |
144 |
+ library_name_as_cstr = '0' |
145 |
+ else: |
146 |
+- library_name_as_cstr = '"lib%s.a"' % library_name |
147 |
++ library_name_as_cstr = '"lib%s" LTDL_SHLIB_EXT' % library_name |
148 |
+ f.write(' { "%s", %s, %d, { %s } },\n' % ( |
149 |
+ name, library_name_as_cstr, is_installed, |
150 |
+ ', '.join('"%s"' % dep |
151 |
+ |
152 |
+-- |
153 |
+2.6.3 |
154 |
+ |
155 |
|
156 |
diff --git a/sys-devel/llvm/llvm-9999.ebuild b/sys-devel/llvm/llvm-3.7.0-r3.ebuild |
157 |
similarity index 82% |
158 |
copy from sys-devel/llvm/llvm-9999.ebuild |
159 |
copy to sys-devel/llvm/llvm-3.7.0-r3.ebuild |
160 |
index a413692..4fe4d69 100644 |
161 |
--- a/sys-devel/llvm/llvm-9999.ebuild |
162 |
+++ b/sys-devel/llvm/llvm-3.7.0-r3.ebuild |
163 |
@@ -7,19 +7,22 @@ EAPI=5 |
164 |
: ${CMAKE_MAKEFILE_GENERATOR:=ninja} |
165 |
PYTHON_COMPAT=( python2_7 pypy ) |
166 |
|
167 |
-inherit check-reqs cmake-utils eutils flag-o-matic git-r3 multilib \ |
168 |
+inherit check-reqs cmake-utils eutils flag-o-matic multilib \ |
169 |
multilib-minimal python-r1 toolchain-funcs pax-utils |
170 |
|
171 |
DESCRIPTION="Low Level Virtual Machine" |
172 |
HOMEPAGE="http://llvm.org/" |
173 |
-SRC_URI="" |
174 |
-EGIT_REPO_URI="http://llvm.org/git/llvm.git |
175 |
- https://github.com/llvm-mirror/llvm.git" |
176 |
+SRC_URI="http://llvm.org/releases/${PV}/${P}.src.tar.xz |
177 |
+ clang? ( http://llvm.org/releases/${PV}/compiler-rt-${PV}.src.tar.xz |
178 |
+ http://llvm.org/releases/${PV}/cfe-${PV}.src.tar.xz |
179 |
+ http://llvm.org/releases/${PV}/clang-tools-extra-${PV}.src.tar.xz ) |
180 |
+ lldb? ( http://llvm.org/releases/${PV}/lldb-${PV}.src.tar.xz ) |
181 |
+ !doc? ( http://dev.gentoo.org/~voyageur/distfiles/${P}-manpages.tar.bz2 )" |
182 |
|
183 |
LICENSE="UoI-NCSA" |
184 |
SLOT="0/${PV}" |
185 |
-KEYWORDS="" |
186 |
-IUSE="clang debug +doc gold libedit +libffi lldb multitarget ncurses ocaml |
187 |
+KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~ppc64 ~sparc ~x86 ~amd64-fbsd ~x86-fbsd ~x64-freebsd ~amd64-linux ~arm-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos" |
188 |
+IUSE="clang debug doc gold libedit +libffi lldb multitarget ncurses ocaml |
189 |
python +static-analyzer test xml video_cards_radeon kernel_Darwin" |
190 |
|
191 |
COMMON_DEPEND=" |
192 |
@@ -39,7 +42,8 @@ COMMON_DEPEND=" |
193 |
ocaml? ( |
194 |
>=dev-lang/ocaml-4.00.0:0= |
195 |
dev-ml/findlib |
196 |
- dev-ml/ocaml-ctypes )" |
197 |
+ dev-ml/ocaml-ctypes |
198 |
+ !!<=sys-devel/llvm-3.7.0-r1[ocaml] )" |
199 |
# configparser-3.2 breaks the build (3.3 or none at all are fine) |
200 |
DEPEND="${COMMON_DEPEND} |
201 |
dev-lang/perl |
202 |
@@ -71,6 +75,8 @@ REQUIRED_USE="${PYTHON_REQUIRED_USE} |
203 |
lldb? ( clang xml ) |
204 |
test? ( || ( $(python_gen_useflags 'python*') ) )" |
205 |
|
206 |
+S=${WORKDIR}/${P/_}.src |
207 |
+ |
208 |
pkg_pretend() { |
209 |
# in megs |
210 |
# !clang !debug !multitarget -O2 400 |
211 |
@@ -124,40 +130,30 @@ pkg_setup() { |
212 |
} |
213 |
|
214 |
src_unpack() { |
215 |
- if use clang; then |
216 |
- git-r3_fetch "http://llvm.org/git/compiler-rt.git |
217 |
- https://github.com/llvm-mirror/compiler-rt.git" |
218 |
- git-r3_fetch "http://llvm.org/git/clang.git |
219 |
- https://github.com/llvm-mirror/clang.git" |
220 |
- git-r3_fetch "http://llvm.org/git/clang-tools-extra.git |
221 |
- https://github.com/llvm-mirror/clang-tools-extra.git" |
222 |
- fi |
223 |
- if use lldb; then |
224 |
- git-r3_fetch "http://llvm.org/git/lldb.git |
225 |
- https://github.com/llvm-mirror/lldb.git" |
226 |
- fi |
227 |
- git-r3_fetch |
228 |
+ default |
229 |
|
230 |
if use clang; then |
231 |
- git-r3_checkout http://llvm.org/git/compiler-rt.git \ |
232 |
- "${S}"/projects/compiler-rt |
233 |
- git-r3_checkout http://llvm.org/git/clang.git \ |
234 |
- "${S}"/tools/clang |
235 |
- git-r3_checkout http://llvm.org/git/clang-tools-extra.git \ |
236 |
- "${S}"/tools/clang/tools/extra |
237 |
+ mv "${WORKDIR}"/cfe-${PV/_}.src "${S}"/tools/clang \ |
238 |
+ || die "clang source directory move failed" |
239 |
+ mv "${WORKDIR}"/compiler-rt-${PV/_}.src "${S}"/projects/compiler-rt \ |
240 |
+ || die "compiler-rt source directory move failed" |
241 |
+ mv "${WORKDIR}"/clang-tools-extra-${PV/_}.src "${S}"/tools/clang/tools/extra \ |
242 |
+ || die "clang-tools-extra source directory move failed" |
243 |
fi |
244 |
+ |
245 |
if use lldb; then |
246 |
- git-r3_checkout http://llvm.org/git/lldb.git \ |
247 |
- "${S}"/tools/lldb |
248 |
+ mv "${WORKDIR}"/lldb-${PV/_}.src "${S}"/tools/lldb \ |
249 |
+ || die "lldb source directory move failed" |
250 |
fi |
251 |
- git-r3_checkout |
252 |
} |
253 |
|
254 |
src_prepare() { |
255 |
# Make ocaml warnings non-fatal, bug #537308 |
256 |
sed -e "/RUN/s/-warn-error A//" -i test/Bindings/OCaml/*ml || die |
257 |
# Fix libdir for ocaml bindings install, bug #559134 |
258 |
- epatch "${FILESDIR}"/cmake/${PN}-3.7.0-ocaml-multilib.patch |
259 |
+ epatch "${FILESDIR}"/cmake/${P}-ocaml-multilib.patch |
260 |
+ # Do not build/install ocaml docs with USE=-doc, bug #562008 |
261 |
+ epatch "${FILESDIR}"/cmake/${P}-ocaml-build_doc.patch |
262 |
|
263 |
# Make it possible to override Sphinx HTML install dirs |
264 |
# https://llvm.org/bugs/show_bug.cgi?id=23780 |
265 |
@@ -171,20 +167,28 @@ src_prepare() { |
266 |
# https://llvm.org/bugs/show_bug.cgi?id=18341 |
267 |
epatch "${FILESDIR}"/cmake/0004-cmake-Do-not-install-libgtest.patch |
268 |
|
269 |
- # Allow custom cmake build types (like 'Gentoo') |
270 |
- epatch "${FILESDIR}"/cmake/${PN}-3.8-allow_custom_cmake_build_types.patch |
271 |
+ # Fix llvm-config for shared linking and sane flags |
272 |
+ # https://bugs.gentoo.org/show_bug.cgi?id=565358 |
273 |
+ epatch "${FILESDIR}"/llvm-3.7-llvm-config.patch |
274 |
|
275 |
if use clang; then |
276 |
# Automatically select active system GCC's libraries, bugs #406163 and #417913 |
277 |
epatch "${FILESDIR}"/clang-3.5-gentoo-runtime-gcc-detection-v3.patch |
278 |
|
279 |
- epatch "${FILESDIR}"/clang-3.8-gentoo-install.patch |
280 |
+ epatch "${FILESDIR}"/clang-3.6-gentoo-install.patch |
281 |
+ |
282 |
+ sed -i -e "s^@EPREFIX@^${EPREFIX}^" \ |
283 |
+ tools/clang/tools/scan-build/scan-build || die |
284 |
|
285 |
# Install clang runtime into /usr/lib/clang |
286 |
# https://llvm.org/bugs/show_bug.cgi?id=23792 |
287 |
- epatch "${FILESDIR}"/cmake/clang-0001-Install-clang-runtime-into-usr-lib-without-suffix-3.8.patch |
288 |
+ epatch "${FILESDIR}"/cmake/clang-0001-Install-clang-runtime-into-usr-lib-without-suffix.patch |
289 |
epatch "${FILESDIR}"/cmake/compiler-rt-0001-cmake-Install-compiler-rt-into-usr-lib-without-suffi.patch |
290 |
|
291 |
+ # Do not force -march flags on arm platforms |
292 |
+ # https://bugs.gentoo.org/show_bug.cgi?id=562706 |
293 |
+ epatch "${FILESDIR}"/cmake/${P}-compiler_rt_arm_march_flags.patch |
294 |
+ |
295 |
# Make it possible to override CLANG_LIBDIR_SUFFIX |
296 |
# (that is used only to find LLVMgold.so) |
297 |
# https://llvm.org/bugs/show_bug.cgi?id=23793 |
298 |
@@ -201,6 +205,15 @@ src_prepare() { |
299 |
# https://llvm.org/bugs/show_bug.cgi?id=18841 |
300 |
sed -e 's/add_subdirectory(readline)/#&/' \ |
301 |
-i tools/lldb/scripts/Python/modules/CMakeLists.txt || die |
302 |
+ |
303 |
+ # Fix Python paths, bugs #562436 and #562438 |
304 |
+ epatch "${FILESDIR}"/${PN}-3.7-lldb_python.patch |
305 |
+ sed -e "s/GENTOO_LIBDIR/$(get_libdir)/" \ |
306 |
+ -i tools/lldb/scripts/Python/finishSwigPythonLLDB.py || die |
307 |
+ |
308 |
+ # Fix build with ncurses[tinfo], #560474 |
309 |
+ # http://llvm.org/viewvc/llvm-project?view=revision&revision=247842 |
310 |
+ epatch "${FILESDIR}"/cmake/${P}-lldb_tinfo.patch |
311 |
fi |
312 |
|
313 |
# User patches |
314 |
@@ -382,7 +395,7 @@ src_install() { |
315 |
|
316 |
if use clang; then |
317 |
# note: magic applied in multilib_src_install()! |
318 |
- CLANG_VERSION=3.8 |
319 |
+ CLANG_VERSION=${PV%.*} |
320 |
|
321 |
MULTILIB_CHOST_TOOLS+=( |
322 |
/usr/bin/clang |
323 |
@@ -405,8 +418,8 @@ multilib_src_install() { |
324 |
cmake-utils_src_install |
325 |
|
326 |
if multilib_is_native_abi; then |
327 |
- # Install docs. |
328 |
- #use doc && dohtml -r "${S}"/docs/_build/html/ |
329 |
+ # Install man pages. |
330 |
+ use doc || doman "${WORKDIR}"/${P}-manpages/*.1 |
331 |
|
332 |
# Symlink the gold plugin. |
333 |
if use gold; then |
334 |
@@ -461,9 +474,22 @@ multilib_src_install_all() { |
335 |
if use clang; then |
336 |
pushd tools/clang >/dev/null || die |
337 |
|
338 |
+ if use static-analyzer ; then |
339 |
+ pushd tools/scan-build >/dev/null || die |
340 |
+ |
341 |
+ dobin ccc-analyzer scan-build |
342 |
+ dosym ccc-analyzer /usr/bin/c++-analyzer |
343 |
+ doman scan-build.1 |
344 |
+ |
345 |
+ insinto /usr/share/llvm |
346 |
+ doins scanview.css sorttable.js |
347 |
+ |
348 |
+ popd >/dev/null || die |
349 |
+ fi |
350 |
+ |
351 |
python_inst() { |
352 |
if use static-analyzer ; then |
353 |
- pushd tools/scan-view/bin >/dev/null || die |
354 |
+ pushd tools/scan-view >/dev/null || die |
355 |
|
356 |
python_doscript scan-view |
357 |
|
358 |
@@ -472,8 +498,6 @@ multilib_src_install_all() { |
359 |
python_domodule *.py Resources |
360 |
|
361 |
popd >/dev/null || die |
362 |
- |
363 |
- # TODO: remove files installed in /usr/share |
364 |
fi |
365 |
|
366 |
if use python ; then |
367 |
|
368 |
diff --git a/sys-devel/llvm/llvm-9999.ebuild b/sys-devel/llvm/llvm-9999.ebuild |
369 |
index a413692..ce52542 100644 |
370 |
--- a/sys-devel/llvm/llvm-9999.ebuild |
371 |
+++ b/sys-devel/llvm/llvm-9999.ebuild |
372 |
@@ -174,6 +174,10 @@ src_prepare() { |
373 |
# Allow custom cmake build types (like 'Gentoo') |
374 |
epatch "${FILESDIR}"/cmake/${PN}-3.8-allow_custom_cmake_build_types.patch |
375 |
|
376 |
+ # Fix llvm-config for shared linking and sane flags |
377 |
+ # https://bugs.gentoo.org/show_bug.cgi?id=565358 |
378 |
+ epatch "${FILESDIR}"/llvm-3.7-llvm-config.patch |
379 |
+ |
380 |
if use clang; then |
381 |
# Automatically select active system GCC's libraries, bugs #406163 and #417913 |
382 |
epatch "${FILESDIR}"/clang-3.5-gentoo-runtime-gcc-detection-v3.patch |