Gentoo Archives: gentoo-commits

From: "Anthony G. Basile" <blueness@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/hardened-dev:musl commit in: sys-devel/llvm/, sys-devel/llvm/files/
Date: Sat, 31 Jan 2015 21:54:48
Message-Id: 1422741406.8d75a00db98a0b522aa32267d67b7cf59a707cee.blueness@gentoo
1 commit: 8d75a00db98a0b522aa32267d67b7cf59a707cee
2 Author: Felix Janda <felix.janda <AT> posteo <DOT> de>
3 AuthorDate: Wed Jan 7 21:06:52 2015 +0000
4 Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
5 CommitDate: Sat Jan 31 21:56:46 2015 +0000
6 URL: http://sources.gentoo.org/gitweb/?p=proj/hardened-dev.git;a=commit;h=8d75a00d
7
8 sys-devel/llvm: Hack around linux=glibc assumptions
9
10 ---
11 .../clang-3.4-darwin_prefix-include-paths.patch | 18 +
12 .../llvm/files/clang-3.5-gentoo-install.patch | 57 +++
13 ...clang-3.5-gentoo-runtime-gcc-detection-v3.patch | 42 ++
14 sys-devel/llvm/files/llvm-3.2-nodoctargz.patch | 45 ++
15 sys-devel/llvm/files/llvm-3.5-gcc-4.9.patch | 43 ++
16 sys-devel/llvm/files/llvm-3.5-gentoo-install.patch | 83 ++++
17 .../llvm/files/llvm-3.5-musl-compiler-rt.patch | 58 +++
18 sys-devel/llvm/files/llvm-3.5-musl-fixes.patch | 77 +++
19 sys-devel/llvm/files/llvm-3.5-musl-support.patch | 124 +++++
20 .../files/llvm-3.5.0-fix_LLVMExports_cmake.patch | 39 ++
21 sys-devel/llvm/llvm-3.5.0-r99.ebuild | 530 +++++++++++++++++++++
22 sys-devel/llvm/metadata.xml | 28 ++
23 12 files changed, 1144 insertions(+)
24
25 diff --git a/sys-devel/llvm/files/clang-3.4-darwin_prefix-include-paths.patch b/sys-devel/llvm/files/clang-3.4-darwin_prefix-include-paths.patch
26 new file mode 100644
27 index 0000000..f5f1d9e
28 --- /dev/null
29 +++ b/sys-devel/llvm/files/clang-3.4-darwin_prefix-include-paths.patch
30 @@ -0,0 +1,18 @@
31 +--- tools/clang/lib/Frontend/InitHeaderSearch.cpp
32 ++++ tools/clang/lib/Frontend/InitHeaderSearch.cpp
33 +@@ -233,6 +233,7 @@
34 + case llvm::Triple::Bitrig:
35 + break;
36 + default:
37 ++ AddPath("@GENTOO_PORTAGE_EPREFIX@/usr/include", System, false);
38 + // FIXME: temporary hack: hard-coded paths.
39 + AddPath("/usr/local/include", System, false);
40 + break;
41 +@@ -505,6 +506,7 @@
42 + // Add the default framework include paths on Darwin.
43 + if (HSOpts.UseStandardSystemIncludes) {
44 + if (triple.isOSDarwin()) {
45 ++ AddPath("@GENTOO_PORTAGE_EPREFIX@/Frameworks", System, true);
46 + AddPath("/System/Library/Frameworks", System, true);
47 + AddPath("/Library/Frameworks", System, true);
48 + }
49
50 diff --git a/sys-devel/llvm/files/clang-3.5-gentoo-install.patch b/sys-devel/llvm/files/clang-3.5-gentoo-install.patch
51 new file mode 100644
52 index 0000000..5d4261d
53 --- /dev/null
54 +++ b/sys-devel/llvm/files/clang-3.5-gentoo-install.patch
55 @@ -0,0 +1,57 @@
56 +---
57 + tools/clang/lib/Driver/Tools.cpp | 2 +-
58 + tools/clang/tools/scan-build/scan-build | 4 ++--
59 + tools/clang/tools/scan-view/scan-view | 2 +-
60 + 3 files changed, 4 insertions(+), 4 deletions(-)
61 +
62 +diff --git a/tools/clang/lib/Driver/Tools.cpp b/tools/clang/lib/Driver/Tools.cpp
63 +index 187ed38..55bcd99 100644
64 +--- a/tools/clang/lib/Driver/Tools.cpp
65 ++++ b/tools/clang/lib/Driver/Tools.cpp
66 +@@ -1404,7 +1404,7 @@ static void AddGoldPlugin(const ToolChain &ToolChain, const ArgList &Args,
67 + // as gold requires -plugin to come before any -plugin-opt that -Wl might
68 + // forward.
69 + CmdArgs.push_back("-plugin");
70 +- std::string Plugin = ToolChain.getDriver().Dir + "/../lib/LLVMgold.so";
71 ++ std::string Plugin = ToolChain.getDriver().Dir + "/../@libdir@/LLVMgold.so";
72 + CmdArgs.push_back(Args.MakeArgString(Plugin));
73 +
74 + // Try to pass driver level flags relevant to LTO code generation down to
75 +diff --git a/tools/clang/tools/scan-build/scan-build b/tools/clang/tools/scan-build/scan-build
76 +index 0f119f6..58f78d9 100755
77 +--- a/tools/clang/tools/scan-build/scan-build
78 ++++ b/tools/clang/tools/scan-build/scan-build
79 +@@ -419,7 +419,7 @@
80 +
81 + my $Dir = shift;
82 +
83 +- my $JS = Cwd::realpath("$RealBin/sorttable.js");
84 ++ my $JS = Cwd::realpath("@EPREFIX@/usr/share/llvm/sorttable.js");
85 +
86 + DieDiag("Cannot find 'sorttable.js'.\n")
87 + if (! -r $JS);
88 +@@ -429,7 +429,7 @@
89 + DieDiag("Could not copy 'sorttable.js' to '$Dir'.\n")
90 + if (! -r "$Dir/sorttable.js");
91 +
92 +- my $CSS = Cwd::realpath("$RealBin/scanview.css");
93 ++ my $CSS = Cwd::realpath("@EPREFIX@/usr/share/llvm/scanview.css");
94 +
95 + DieDiag("Cannot find 'scanview.css'.\n")
96 + if (! -r $CSS);
97 +diff --git a/tools/clang/tools/scan-view/scan-view b/tools/clang/tools/scan-view/scan-view
98 +index fb27da6..1f8ddb8 100755
99 +--- a/tools/clang/tools/scan-view/scan-view
100 ++++ b/tools/clang/tools/scan-view/scan-view
101 +@@ -54,7 +54,7 @@ def start_browser(port, options):
102 + webbrowser.open(url)
103 +
104 + def run(port, options, root):
105 +- import ScanView
106 ++ from clang import ScanView
107 + try:
108 + print 'Starting scan-view at: http://%s:%d'%(options.host,
109 + port)
110 +--
111 +1.8.4.4
112 +
113
114 diff --git a/sys-devel/llvm/files/clang-3.5-gentoo-runtime-gcc-detection-v3.patch b/sys-devel/llvm/files/clang-3.5-gentoo-runtime-gcc-detection-v3.patch
115 new file mode 100644
116 index 0000000..1f81af0
117 --- /dev/null
118 +++ b/sys-devel/llvm/files/clang-3.5-gentoo-runtime-gcc-detection-v3.patch
119 @@ -0,0 +1,42 @@
120 +From 916572e1243633ddf913c8f32771a3a7f70fd853 Mon Sep 17 00:00:00 2001
121 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@g.o>
122 +Date: Fri, 5 Sep 2014 16:49:35 +0200
123 +Subject: [PATCH] Support obtaining active toolchain from gcc-config.
124 +
125 +---
126 + tools/clang/lib/Driver/ToolChains.cpp | 19 +++++++++++++++++++
127 + 1 file changed, 19 insertions(+)
128 +
129 +diff --git a/tools/clang/lib/Driver/ToolChains.cpp b/tools/clang/lib/Driver/ToolChains.cpp
130 +index b46f69d..2d4374d 100644
131 +--- a/tools/clang/lib/Driver/ToolChains.cpp
132 ++++ b/tools/clang/lib/Driver/ToolChains.cpp
133 +@@ -1253,6 +1253,25 @@ Generic_GCC::GCCInstallationDetector::init(
134 + Prefixes.push_back("/usr");
135 + }
136 +
137 ++ for (unsigned k = 0, ke = CandidateTripleAliases.size(); k < ke; ++k) {
138 ++ llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> File =
139 ++ llvm::MemoryBuffer::getFile(D.SysRoot + "/etc/env.d/gcc/config-" + CandidateTripleAliases[k].str());
140 ++ if (File)
141 ++ {
142 ++ const std::string VersionText = File.get()->getBuffer().rsplit('-').second.substr(0,5).str();
143 ++ const std::string GentooPath = D.SysRoot + "/usr/lib/gcc/" + CandidateTripleAliases[k].str() + "/" + VersionText;
144 ++ if (llvm::sys::fs::exists(GentooPath + "/crtbegin.o"))
145 ++ {
146 ++ Version = GCCVersion::Parse(VersionText);
147 ++ GCCInstallPath = GentooPath;
148 ++ GCCParentLibPath = GCCInstallPath + "/../../..";
149 ++ GCCTriple.setTriple(CandidateTripleAliases[k]);
150 ++ IsValid = true;
151 ++ return;
152 ++ }
153 ++ }
154 ++ }
155 ++
156 + // Loop over the various components which exist and select the best GCC
157 + // installation available. GCC installs are ranked by version number.
158 + Version = GCCVersion::Parse("0.0.0");
159 +--
160 +2.1.0
161 +
162
163 diff --git a/sys-devel/llvm/files/llvm-3.2-nodoctargz.patch b/sys-devel/llvm/files/llvm-3.2-nodoctargz.patch
164 new file mode 100644
165 index 0000000..3a622b5
166 --- /dev/null
167 +++ b/sys-devel/llvm/files/llvm-3.2-nodoctargz.patch
168 @@ -0,0 +1,45 @@
169 +--- docs/Makefile.orig 2012-04-30 17:00:01.000000000 +0200
170 ++++ docs/Makefile 2012-04-30 17:15:52.000000000 +0200
171 +@@ -52,11 +52,10 @@
172 + # 'make generated BUILD_FOR_WEBSITE=1'
173 + generated:: $(generated_targets)
174 +
175 +-install-html: $(PROJ_OBJ_DIR)/html.tar.gz
176 ++install-html:
177 + $(Echo) Installing HTML documentation
178 + $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_docsdir)/html
179 + $(Verb) $(DataInstall) $(HTML) $(DESTDIR)$(PROJ_docsdir)/html
180 +- $(Verb) $(DataInstall) $(PROJ_OBJ_DIR)/html.tar.gz $(DESTDIR)$(PROJ_docsdir)
181 +
182 + $(PROJ_OBJ_DIR)/html.tar.gz: $(HTML)
183 + $(Echo) Packaging HTML documentation
184 +@@ -68,12 +67,11 @@
185 + install-doxygen: doxygen
186 + $(Echo) Installing doxygen documentation
187 + $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_docsdir)/html/doxygen
188 +- $(Verb) $(DataInstall) $(PROJ_OBJ_DIR)/doxygen.tar.gz $(DESTDIR)$(PROJ_docsdir)
189 + $(Verb) cd $(PROJ_OBJ_DIR)/doxygen && \
190 + $(FIND) . -type f -exec \
191 + $(DataInstall) {} $(DESTDIR)$(PROJ_docsdir)/html/doxygen \;
192 +
193 +-doxygen: regendoc $(PROJ_OBJ_DIR)/doxygen.tar.gz
194 ++doxygen: regendoc
195 +
196 + regendoc:
197 + $(Echo) Building doxygen documentation
198 +@@ -99,7 +97,6 @@
199 + install-ocamldoc: ocamldoc
200 + $(Echo) Installing ocamldoc documentation
201 + $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_docsdir)/ocamldoc/html
202 +- $(Verb) $(DataInstall) $(PROJ_OBJ_DIR)/ocamldoc.tar.gz $(DESTDIR)$(PROJ_docsdir)
203 + $(Verb) cd $(PROJ_OBJ_DIR)/ocamldoc && \
204 + $(FIND) . -type f -exec \
205 + $(DataInstall) {} $(DESTDIR)$(PROJ_docsdir)/ocamldoc/html \;
206 +@@ -109,7 +106,6 @@
207 + $(Verb) $(RM) -rf $(PROJ_OBJ_DIR)/ocamldoc.tar*
208 + $(Verb) $(TAR) cf $(PROJ_OBJ_DIR)/ocamldoc.tar ocamldoc
209 + $(Verb) $(GZIPBIN) $(PROJ_OBJ_DIR)/ocamldoc.tar
210 +- $(Verb) $(CP) $(PROJ_OBJ_DIR)/ocamldoc.tar.gz $(PROJ_OBJ_DIR)/ocamldoc/html/
211 +
212 + regen-ocamldoc:
213 + $(Echo) Building ocamldoc documentation
214
215 diff --git a/sys-devel/llvm/files/llvm-3.5-gcc-4.9.patch b/sys-devel/llvm/files/llvm-3.5-gcc-4.9.patch
216 new file mode 100644
217 index 0000000..7da657f
218 --- /dev/null
219 +++ b/sys-devel/llvm/files/llvm-3.5-gcc-4.9.patch
220 @@ -0,0 +1,43 @@
221 +commit 080fb498017d17af2e4d7563608c7d8a848f20da
222 +Author: Sanjoy Das <sanjoy at azulsystems.com>
223 +Date: Thu Jun 19 15:38:02 2014 -0700
224 +
225 + Fix the --enable-shared build.
226 +
227 + Currently a build configured with ./configure --enable-shared breaks
228 + with an undefined "llvm::cl::parser<llvm::PassInfo
229 + const*>::getOption(unsigned int) const" symbol when linking opt. This
230 + body for this symbol gets emitted into Pass.o (along with the destructor
231 + for PassNameParser), but gets linked into libLLVM-3.5svn.so with local
232 + visibility, causing the link error.
233 +
234 + This fix uses the existing EXTERN_TEMPLATE machinery to force a globally
235 + visible definition for the functions in parser<const PassInfo *> into
236 + Pass.o.
237 +
238 +diff --git a/include/llvm/IR/LegacyPassNameParser.h b/include/llvm/IR/LegacyPassNameParser.h
239 +index e2e4912..a07e3fd 100644
240 +--- a/include/llvm/IR/LegacyPassNameParser.h
241 ++++ b/include/llvm/IR/LegacyPassNameParser.h
242 +@@ -95,6 +95,8 @@ private:
243 + }
244 + };
245 +
246 ++EXTERN_TEMPLATE_INSTANTIATION(class cl::parser<const PassInfo *>);
247 ++
248 + ///===----------------------------------------------------------------------===//
249 + /// FilteredPassNameParser class - Make use of the pass registration
250 + /// mechanism to automatically add a command line argument to opt for
251 +diff --git a/lib/IR/Pass.cpp b/lib/IR/Pass.cpp
252 +index 91d86ae..00ce223 100644
253 +--- a/lib/IR/Pass.cpp
254 ++++ b/lib/IR/Pass.cpp
255 +@@ -234,6 +234,8 @@ PassNameParser::~PassNameParser() {
256 + // attempting to remove the registration listener is an error.
257 + }
258 +
259 ++TEMPLATE_INSTANTIATION(class cl::parser<const PassInfo *>);
260 ++
261 + //===----------------------------------------------------------------------===//
262 + // AnalysisUsage Class Implementation
263 + //
264
265 diff --git a/sys-devel/llvm/files/llvm-3.5-gentoo-install.patch b/sys-devel/llvm/files/llvm-3.5-gentoo-install.patch
266 new file mode 100644
267 index 0000000..7a8c9f7
268 --- /dev/null
269 +++ b/sys-devel/llvm/files/llvm-3.5-gentoo-install.patch
270 @@ -0,0 +1,83 @@
271 +From b8846d389ff5e2b768a114f752cf39788accba26 Mon Sep 17 00:00:00 2001
272 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@g.o>
273 +Date: Mon, 19 Aug 2013 13:22:46 +0200
274 +Subject: [PATCH] gentoo install fixes
275 +
276 +---
277 + Makefile.config.in | 6 +++---
278 + Makefile.rules | 6 +++---
279 + tools/llvm-config/BuildVariables.inc.in | 2 ++
280 + tools/llvm-config/Makefile | 4 ++++
281 + tools/llvm-config/llvm-config.cpp | 5 +++--
282 + utils/FileCheck/Makefile | 2 +-
283 + 7 files changed, 17 insertions(+), 10 deletions(-)
284 +
285 +diff --git a/Makefile.config.in b/Makefile.config.in
286 +index dcca45f..e75ae2e 100644
287 +--- a/Makefile.config.in
288 ++++ b/Makefile.config.in
289 +@@ -95,10 +95,10 @@ PROJ_internal_prefix := $(prefix)
290 + endif
291 +
292 + PROJ_bindir := $(PROJ_prefix)/bin
293 +-PROJ_libdir := $(PROJ_prefix)/lib
294 ++PROJ_libdir := $(PROJ_prefix)/$(GENTOO_LIBDIR)
295 + PROJ_datadir := $(PROJ_prefix)/share
296 +-PROJ_docsdir := $(PROJ_prefix)/docs/llvm
297 +-PROJ_etcdir := $(PROJ_prefix)/etc/llvm
298 ++PROJ_docsdir := $(PROJ_prefix)/share/doc/@PF@
299 ++PROJ_etcdir := @EPREFIX@/etc/llvm
300 + PROJ_includedir := $(PROJ_prefix)/include
301 + PROJ_infodir := $(PROJ_prefix)/info
302 + PROJ_mandir := $(PROJ_prefix)/share/man
303 +diff --git a/Makefile.rules b/Makefile.rules
304 +index e53598b..217f754 100644
305 +--- a/Makefile.rules
306 ++++ b/Makefile.rules
307 +@@ -275,7 +275,7 @@ ifeq ($(ENABLE_OPTIMIZED),1)
308 + BuildMode := Release
309 + # Don't use -fomit-frame-pointer on Darwin or FreeBSD.
310 + ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin Darwin DragonFly FreeBSD GNU/kFreeBSD))
311 +- OmitFramePointer := -fomit-frame-pointer
312 ++ OmitFramePointer :=
313 + endif
314 +
315 + CXX.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
316 +diff --git a/tools/llvm-config/BuildVariables.inc.in b/tools/llvm-config/BuildVariables.inc.in
317 +index fe87afb..fd9f2c6 100644
318 +--- a/tools/llvm-config/BuildVariables.inc.in
319 ++++ b/tools/llvm-config/BuildVariables.inc.in
320 +@@ -25,3 +25,4 @@
321 + #define LLVM_BUILDMODE "@LLVM_BUILDMODE@"
322 + #define LLVM_TARGETS_BUILT "@LLVM_TARGETS_BUILT@"
323 + #define LLVM_SYSTEM_LIBS "@LLVM_SYSTEM_LIBS@"
324 ++#define LLVM_LIBDIR "@LLVM_LIBDIR@"
325 +diff --git a/tools/llvm-config/Makefile b/tools/llvm-config/Makefile
326 +index b20b6bf..fc56781 100644
327 +--- a/tools/llvm-config/Makefile
328 ++++ b/tools/llvm-config/Makefile
329 +@@ -55,6 +55,8 @@ $(ObjDir)/BuildVariables.inc: $(BUILDVARIABLES_SRCPATH) Makefile $(ObjDir)/.dir
330 + >> temp.sed
331 + $(Verb) $(ECHO) 's/@LLVM_TARGETS_BUILT@/$(subst /,\/,$(TARGETS_TO_BUILD))/' \
332 + >> temp.sed
333 ++ $(Verb) $(ECHO) 's/@LLVM_LIBDIR@/$(subst /,\/,$(GENTOO_LIBDIR))/' \
334 ++ >> temp.sed
335 + $(Verb) $(SED) -f temp.sed < $< > $@
336 + $(Verb) $(RM) temp.sed
337 +
338 +diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp
339 +index 3924e2e..f439c60 100644
340 +--- a/tools/llvm-config/llvm-config.cpp
341 ++++ b/tools/llvm-config/llvm-config.cpp
342 +@@ -250,7 +250,7 @@ int main(int argc, char **argv) {
343 + ActivePrefix = CurrentExecPrefix;
344 + ActiveIncludeDir = ActivePrefix + "/include";
345 + ActiveBinDir = ActivePrefix + "/bin";
346 +- ActiveLibDir = ActivePrefix + "/lib";
347 ++ ActiveLibDir = ActivePrefix + "/" LLVM_LIBDIR;
348 + ActiveIncludeOption = "-I" + ActiveIncludeDir;
349 + }
350 +
351 +--
352 +1.8.4.2
353 +
354
355 diff --git a/sys-devel/llvm/files/llvm-3.5-musl-compiler-rt.patch b/sys-devel/llvm/files/llvm-3.5-musl-compiler-rt.patch
356 new file mode 100644
357 index 0000000..b1646b8
358 --- /dev/null
359 +++ b/sys-devel/llvm/files/llvm-3.5-musl-compiler-rt.patch
360 @@ -0,0 +1,58 @@
361 +diff -ur a/llvm-3.5.0.src/projects/compiler-rt/lib/Makefile.mk b/llvm-3.5.0.src/projects/compiler-rt/lib/Makefile.mk
362 +--- a/llvm-3.5.0.src/projects/compiler-rt/lib/Makefile.mk 2014-02-14 10:20:33.000000000 -0100
363 ++++ b/llvm-3.5.0.src/projects/compiler-rt/lib/Makefile.mk 2015-01-07 13:56:00.362944069 -0100
364 +@@ -10,13 +10,13 @@
365 + SubDirs :=
366 +
367 + # Add submodules.
368 +-SubDirs += asan
369 ++#SubDirs += asan
370 + SubDirs += builtins
371 +-SubDirs += dfsan
372 ++#SubDirs += dfsan
373 + SubDirs += interception
374 +-SubDirs += lsan
375 +-SubDirs += msan
376 ++#SubDirs += lsan
377 ++#SubDirs += msan
378 + SubDirs += profile
379 +-SubDirs += sanitizer_common
380 +-SubDirs += tsan
381 +-SubDirs += ubsan
382 ++#SubDirs += sanitizer_common
383 ++#SubDirs += tsan
384 ++#SubDirs += ubsan
385 +diff -ur a/llvm-3.5.0.src/projects/compiler-rt/lib/interception/interception_linux.cc b/llvm-3.5.0.src/projects/compiler-rt/lib/interception/interception_linux.cc
386 +--- a/llvm-3.5.0.src/projects/compiler-rt/lib/interception/interception_linux.cc 2014-02-24 09:37:41.000000000 -0100
387 ++++ b/llvm-3.5.0.src/projects/compiler-rt/lib/interception/interception_linux.cc 2015-01-07 13:56:56.609240893 -0100
388 +@@ -24,12 +24,6 @@
389 + return real == wrapper;
390 + }
391 +
392 +-#if !defined(__ANDROID__) // android does not have dlvsym
393 +-void *GetFuncAddrVer(const char *func_name, const char *ver) {
394 +- return dlvsym(RTLD_NEXT, func_name, ver);
395 +-}
396 +-#endif // !defined(__ANDROID__)
397 +-
398 + } // namespace __interception
399 +
400 +
401 +diff -ur a/llvm-3.5.0.src/projects/compiler-rt/lib/interception/interception_linux.h b/llvm-3.5.0.src/projects/compiler-rt/lib/interception/interception_linux.h
402 +--- a/llvm-3.5.0.src/projects/compiler-rt/lib/interception/interception_linux.h 2014-02-24 09:37:41.000000000 -0100
403 ++++ b/llvm-3.5.0.src/projects/compiler-rt/lib/interception/interception_linux.h 2015-01-07 13:56:41.617428317 -0100
404 +@@ -34,14 +34,8 @@
405 + (::__interception::uptr) & (func), \
406 + (::__interception::uptr) & WRAP(func))
407 +
408 +-#if !defined(__ANDROID__) // android does not have dlvsym
409 +-# define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \
410 +- ::__interception::real_##func = (func##_f)(unsigned long) \
411 +- ::__interception::GetFuncAddrVer(#func, symver)
412 +-#else
413 + # define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \
414 + INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func)
415 +-#endif // !defined(__ANDROID__)
416 +
417 + #endif // INTERCEPTION_LINUX_H
418 + #endif // __linux__ || __FreeBSD__
419
420 diff --git a/sys-devel/llvm/files/llvm-3.5-musl-fixes.patch b/sys-devel/llvm/files/llvm-3.5-musl-fixes.patch
421 new file mode 100644
422 index 0000000..98d6133
423 --- /dev/null
424 +++ b/sys-devel/llvm/files/llvm-3.5-musl-fixes.patch
425 @@ -0,0 +1,77 @@
426 +llvm-musl.patch from alpine linux
427 +
428 +diff -ru llvm-3.5.0.src.orig/include/llvm/Target/TargetLibraryInfo.h llvm-3.5.0.src/include/llvm/Target/TargetLibraryInfo.h
429 +--- llvm-3.5.0.src.orig/include/llvm/Target/TargetLibraryInfo.h 2014-11-13 12:51:53.341455401 +0000
430 ++++ llvm-3.5.0.src/include/llvm/Target/TargetLibraryInfo.h 2014-11-13 12:52:35.078889077 +0000
431 +@@ -13,6 +13,15 @@
432 + #include "llvm/ADT/DenseMap.h"
433 + #include "llvm/Pass.h"
434 +
435 ++#undef fopen64
436 ++#undef fseeko64
437 ++#undef fstat64
438 ++#undef fstatvfs64
439 ++#undef ftello64
440 ++#undef lstat64
441 ++#undef stat64
442 ++#undef tmpfile64
443 ++
444 + namespace llvm {
445 + class Triple;
446 +
447 +diff -ru llvm-3.5.0.src.orig/lib/Support/DynamicLibrary.cpp llvm-3.5.0.src/lib/Support/DynamicLibrary.cpp
448 +--- llvm-3.5.0.src.orig/lib/Support/DynamicLibrary.cpp 2014-11-13 12:51:53.341455401 +0000
449 ++++ llvm-3.5.0.src/lib/Support/DynamicLibrary.cpp 2014-11-13 12:52:07.781720766 +0000
450 +@@ -138,7 +138,7 @@
451 +
452 + // This macro returns the address of a well-known, explicit symbol
453 + #define EXPLICIT_SYMBOL(SYM) \
454 +- if (!strcmp(symbolName, #SYM)) return &SYM
455 ++ if (!strcmp(symbolName, #SYM)) return (void *) &SYM
456 +
457 + // On linux we have a weird situation. The stderr/out/in symbols are both
458 + // macros and global variables because of standards requirements. So, we
459 +diff -ru llvm-3.5.0.src.orig/lib/Support/Unix/Signals.inc llvm-3.5.0.src/lib/Support/Unix/Signals.inc
460 +--- llvm-3.5.0.src.orig/lib/Support/Unix/Signals.inc 2014-11-13 12:51:53.341455401 +0000
461 ++++ llvm-3.5.0.src/lib/Support/Unix/Signals.inc 2014-11-13 12:52:07.781720766 +0000
462 +@@ -266,7 +266,7 @@
463 + // On glibc systems we have the 'backtrace' function, which works nicely, but
464 + // doesn't demangle symbols.
465 + void llvm::sys::PrintStackTrace(FILE *FD) {
466 +-#if defined(HAVE_BACKTRACE) && defined(ENABLE_BACKTRACES)
467 ++#if defined(__GLIBC__) && defined(HAVE_BACKTRACE) && defined(ENABLE_BACKTRACES)
468 + static void* StackTrace[256];
469 + // Use backtrace() to output a backtrace on Linux systems with glibc.
470 + int depth = backtrace(StackTrace,
471 +diff -ru llvm-3.5.0.src.orig/lib/Target/TargetLibraryInfo.cpp llvm-3.5.0.src/lib/Target/TargetLibraryInfo.cpp
472 +--- llvm-3.5.0.src.orig/lib/Target/TargetLibraryInfo.cpp 2014-11-13 12:51:53.341455401 +0000
473 ++++ llvm-3.5.0.src/lib/Target/TargetLibraryInfo.cpp 2014-11-13 12:52:07.785054160 +0000
474 +@@ -653,14 +653,15 @@
475 + }
476 +
477 + // The following functions are available on at least Linux:
478 +- if (!T.isOSLinux()) {
479 ++ if (!T.isOSLinux())
480 ++ TLI.setUnavailable(LibFunc::memalign);
481 ++ if (1 /*!T.isGlibc()*/) {
482 + TLI.setUnavailable(LibFunc::dunder_strdup);
483 + TLI.setUnavailable(LibFunc::dunder_strtok_r);
484 + TLI.setUnavailable(LibFunc::dunder_isoc99_scanf);
485 + TLI.setUnavailable(LibFunc::dunder_isoc99_sscanf);
486 + TLI.setUnavailable(LibFunc::under_IO_getc);
487 + TLI.setUnavailable(LibFunc::under_IO_putc);
488 +- TLI.setUnavailable(LibFunc::memalign);
489 + TLI.setUnavailable(LibFunc::fopen64);
490 + TLI.setUnavailable(LibFunc::fseeko64);
491 + TLI.setUnavailable(LibFunc::fstat64);
492 +diff -ru llvm-3.5.0.src.orig/utils/unittest/googletest/src/gtest.cc llvm-3.5.0.src/utils/unittest/googletest/src/gtest.cc
493 +--- llvm-3.5.0.src.orig/utils/unittest/googletest/src/gtest.cc 2014-11-13 12:51:53.341455401 +0000
494 ++++ llvm-3.5.0.src/utils/unittest/googletest/src/gtest.cc 2014-11-13 12:52:07.785054160 +0000
495 +@@ -120,6 +120,7 @@
496 +
497 + #if GTEST_CAN_STREAM_RESULTS_
498 + # include <arpa/inet.h> // NOLINT
499 ++# include <sys/socket.h> // NOLINT
500 + # include <netdb.h> // NOLINT
501 + #endif
502 +
503
504 diff --git a/sys-devel/llvm/files/llvm-3.5-musl-support.patch b/sys-devel/llvm/files/llvm-3.5-musl-support.patch
505 new file mode 100644
506 index 0000000..be92809
507 --- /dev/null
508 +++ b/sys-devel/llvm/files/llvm-3.5-musl-support.patch
509 @@ -0,0 +1,124 @@
510 +adapted from llvm-alpine-linux.patch from Alpine
511 +
512 +diff -ru llvm-3.5.0.src.orig/include/llvm/ADT/Triple.h llvm-3.5.0.src/include/llvm/ADT/Triple.h
513 +--- llvm-3.5.0.src.orig/include/llvm/ADT/Triple.h 2014-07-18 17:28:19.000000000 -0300
514 ++++ llvm-3.5.0.src/include/llvm/ADT/Triple.h 2014-11-12 14:44:41.738448045 -0200
515 +@@ -149,6 +149,10 @@
516 + EABIHF,
517 + Android,
518 +
519 ++ Musl,
520 ++ MuslEABI,
521 ++ MuslEABIHF,
522 ++
523 + MSVC,
524 + Itanium,
525 + Cygnus,
526 +Only in llvm-3.5.0.src/include/llvm/ADT: Triple.h.orig
527 +diff -ru llvm-3.5.0.src.orig/lib/Support/Triple.cpp llvm-3.5.0.src/lib/Support/Triple.cpp
528 +--- llvm-3.5.0.src.orig/lib/Support/Triple.cpp 2014-07-18 17:28:19.000000000 -0300
529 ++++ llvm-3.5.0.src/lib/Support/Triple.cpp 2014-11-12 14:47:06.565122146 -0200
530 +@@ -168,6 +168,9 @@
531 + case CODE16: return "code16";
532 + case EABI: return "eabi";
533 + case EABIHF: return "eabihf";
534 ++ case Musl: return "musl";
535 ++ case MuslEABI: return "musleabi";
536 ++ case MuslEABIHF: return "musleabihf";
537 + case Android: return "android";
538 + case MSVC: return "msvc";
539 + case Itanium: return "itanium";
540 +@@ -344,6 +347,9 @@
541 + .StartsWith("gnux32", Triple::GNUX32)
542 + .StartsWith("code16", Triple::CODE16)
543 + .StartsWith("gnu", Triple::GNU)
544 ++ .StartsWith("musl", Triple::Musl)
545 ++ .StartsWith("musleabi", Triple::MuslEABI)
546 ++ .StartsWith("musleabihf", Triple::MuslEABIHF)
547 + .StartsWith("android", Triple::Android)
548 + .StartsWith("msvc", Triple::MSVC)
549 + .StartsWith("itanium", Triple::Itanium)
550 +Only in llvm-3.5.0.src/lib/Support: Triple.cpp.orig
551 +diff -ru llvm-3.5.0.src.orig/lib/Target/ARM/ARMSubtarget.cpp llvm-3.5.0.src/lib/Target/ARM/ARMSubtarget.cpp
552 +--- llvm-3.5.0.src.orig/lib/Target/ARM/ARMSubtarget.cpp 2014-07-16 23:13:31.000000000 -0300
553 ++++ llvm-3.5.0.src/lib/Target/ARM/ARMSubtarget.cpp 2014-11-12 14:50:40.025133104 -0200
554 +@@ -273,6 +273,8 @@
555 + case Triple::EABIHF:
556 + case Triple::GNUEABI:
557 + case Triple::GNUEABIHF:
558 ++ case Triple::MuslEABI:
559 ++ case Triple::MuslEABIHF:
560 + TargetABI = ARM_ABI_AAPCS;
561 + break;
562 + default:
563 +diff -ru llvm-3.5.0.src.orig/lib/Target/ARM/ARMSubtarget.h llvm-3.5.0.src/lib/Target/ARM/ARMSubtarget.h
564 +--- llvm-3.5.0.src.orig/lib/Target/ARM/ARMSubtarget.h 2014-07-16 23:13:31.000000000 -0300
565 ++++ llvm-3.5.0.src/lib/Target/ARM/ARMSubtarget.h 2014-11-12 14:53:36.571808822 -0200
566 +@@ -372,8 +372,10 @@
567 + bool isTargetEHABICompatible() const {
568 + return (TargetTriple.getEnvironment() == Triple::EABI ||
569 + TargetTriple.getEnvironment() == Triple::GNUEABI ||
570 ++ TargetTriple.getEnvironment() == Triple::MuslEABI ||
571 + TargetTriple.getEnvironment() == Triple::EABIHF ||
572 + TargetTriple.getEnvironment() == Triple::GNUEABIHF ||
573 ++ TargetTriple.getEnvironment() == Triple::MuslEABIHF ||
574 + TargetTriple.getEnvironment() == Triple::Android) &&
575 + !isTargetDarwin() && !isTargetWindows();
576 + }
577 +diff -ru llvm-3.5.0.src.orig/tools/clang/lib/Driver/Tools.cpp llvm-3.5.0.src/tools/clang/lib/Driver/Tools.cpp
578 +--- llvm-3.5.0.src.orig/tools/clang/lib/Driver/Tools.cpp 2014-08-07 07:51:51.000000000 -0300
579 ++++ llvm-3.5.0.src/tools/clang/lib/Driver/Tools.cpp 2014-11-12 15:11:31.901864030 -0200
580 +@@ -7182,8 +7182,14 @@
581 + return "/system/bin/linker64";
582 + else
583 + return "/system/bin/linker";
584 +- } else if (ToolChain.getArch() == llvm::Triple::x86 ||
585 +- ToolChain.getArch() == llvm::Triple::sparc)
586 ++ } else if (ToolChain.getArch() == llvm::Triple::x86) {
587 ++ switch (ToolChain.getTriple().getEnvironment()) {
588 ++ case llvm::Triple::Musl:
589 ++ return "/lib/ld-musl-i386.so.1";
590 ++ default:
591 ++ return "/lib/ld-linux.so.2";
592 ++ }
593 ++ } else if (ToolChain.getArch() == llvm::Triple::sparc)
594 + return "/lib/ld-linux.so.2";
595 + else if (ToolChain.getArch() == llvm::Triple::aarch64 ||
596 + ToolChain.getArch() == llvm::Triple::arm64)
597 +@@ -7193,10 +7199,17 @@
598 + return "/lib/ld-linux-aarch64_be.so.1";
599 + else if (ToolChain.getArch() == llvm::Triple::arm ||
600 + ToolChain.getArch() == llvm::Triple::thumb) {
601 +- if (ToolChain.getTriple().getEnvironment() == llvm::Triple::GNUEABIHF)
602 ++ switch (ToolChain.getTriple().getEnvironment()) {
603 ++ case llvm::Triple::Musl:
604 ++ case llvm::Triple::MuslEABI:
605 ++ return "/lib/ld-musl-arm.so.3";
606 ++ case llvm::Triple::MuslEABIHF:
607 ++ return "/lib/ld-musl-armhf.so.3";
608 ++ case llvm::Triple::GNUEABIHF:
609 + return "/lib/ld-linux-armhf.so.3";
610 +- else
611 ++ default:
612 + return "/lib/ld-linux.so.3";
613 ++ }
614 + } else if (ToolChain.getArch() == llvm::Triple::armeb ||
615 + ToolChain.getArch() == llvm::Triple::thumbeb) {
616 + if (ToolChain.getTriple().getEnvironment() == llvm::Triple::GNUEABIHF)
617 +@@ -7227,8 +7240,14 @@
618 + else if (ToolChain.getArch() == llvm::Triple::x86_64 &&
619 + ToolChain.getTriple().getEnvironment() == llvm::Triple::GNUX32)
620 + return "/libx32/ld-linux-x32.so.2";
621 +- else
622 +- return "/lib64/ld-linux-x86-64.so.2";
623 ++ else {
624 ++ switch (ToolChain.getTriple().getEnvironment()) {
625 ++ case llvm::Triple::Musl:
626 ++ return "/lib/ld-musl-x86_64.so.1";
627 ++ default:
628 ++ return "/lib64/ld-linux-x86-64.so.2";
629 ++ }
630 ++ }
631 + }
632 +
633 + static void AddRunTimeLibs(const ToolChain &TC, const Driver &D,
634
635 diff --git a/sys-devel/llvm/files/llvm-3.5.0-fix_LLVMExports_cmake.patch b/sys-devel/llvm/files/llvm-3.5.0-fix_LLVMExports_cmake.patch
636 new file mode 100644
637 index 0000000..9fbd7b7
638 --- /dev/null
639 +++ b/sys-devel/llvm/files/llvm-3.5.0-fix_LLVMExports_cmake.patch
640 @@ -0,0 +1,39 @@
641 +Index: cmake/modules/Makefile
642 +===================================================================
643 +--- cmake/modules/Makefile (revision 217451)
644 ++++ cmake/modules/Makefile (working copy)
645 +@@ -33,6 +33,16 @@
646 + LLVM_ENABLE_RTTI := 0
647 + endif
648 +
649 ++LLVM_LIBS_TO_EXPORT := $(subst -l,,$(shell $(LLVM_CONFIG) --libs $(LINK_COMPONENTS) || echo Error))
650 ++
651 ++ifeq ($(LLVM_LIBS_TO_EXPORT),Error)
652 ++$(error llvm-config --libs failed)
653 ++endif
654 ++
655 ++ifndef LLVM_LIBS_TO_EXPORT
656 ++$(error LLVM_LIBS_TO_EXPORT cannot be empty)
657 ++endif
658 ++
659 + OBJMODS := LLVMConfig.cmake LLVMConfigVersion.cmake LLVMExports.cmake
660 +
661 + $(PROJ_OBJ_DIR)/LLVMConfig.cmake: LLVMConfig.cmake.in $(LLVMBuildCMakeFrag)
662 +@@ -45,7 +55,7 @@
663 + -e 's/@LLVM_VERSION_PATCH@/'"$(LLVM_VERSION_PATCH)"'/' \
664 + -e 's/@PACKAGE_VERSION@/'"$(LLVMVersion)"'/' \
665 + -e 's/@LLVM_COMMON_DEPENDS@//' \
666 +- -e 's/@LLVM_AVAILABLE_LIBS@/'"$(subst -l,,$(LLVMConfigLibs))"'/' \
667 ++ -e 's/@LLVM_AVAILABLE_LIBS@/'"$(LLVM_LIBS_TO_EXPORT)"'/' \
668 + -e 's/@LLVM_ALL_TARGETS@/'"$(ALL_TARGETS)"'/' \
669 + -e 's/@LLVM_TARGETS_TO_BUILD@/'"$(TARGETS_TO_BUILD)"'/' \
670 + -e 's/@LLVM_TARGETS_WITH_JIT@/'"$(TARGETS_WITH_JIT)"'/' \
671 +@@ -83,7 +93,7 @@
672 + $(Echo) 'Generating LLVM CMake target exports file'
673 + $(Verb) ( \
674 + echo '# LLVM CMake target exports. Do not include directly.' && \
675 +- for lib in $(subst -l,,$(LLVMConfigLibs)); do \
676 ++ for lib in $(LLVM_LIBS_TO_EXPORT); do \
677 + echo 'add_library('"$$lib"' STATIC IMPORTED)' && \
678 + echo 'set_property(TARGET '"$$lib"' PROPERTY IMPORTED_LOCATION "'"$(PROJ_libdir)/lib$$lib.a"'")' ; \
679 + done && \
680
681 diff --git a/sys-devel/llvm/llvm-3.5.0-r99.ebuild b/sys-devel/llvm/llvm-3.5.0-r99.ebuild
682 new file mode 100644
683 index 0000000..9db3f59
684 --- /dev/null
685 +++ b/sys-devel/llvm/llvm-3.5.0-r99.ebuild
686 @@ -0,0 +1,530 @@
687 +# Copyright 1999-2015 Gentoo Foundation
688 +# Distributed under the terms of the GNU General Public License v2
689 +# $Header: /var/cvsroot/gentoo-x86/sys-devel/llvm/llvm-3.5.0.ebuild,v 1.11 2015/01/01 20:53:32 maekke Exp $
690 +
691 +EAPI=5
692 +
693 +PYTHON_COMPAT=( python2_7 pypy )
694 +
695 +inherit eutils flag-o-matic multibuild multilib \
696 + multilib-minimal python-r1 toolchain-funcs pax-utils check-reqs prefix
697 +
698 +DESCRIPTION="Low Level Virtual Machine"
699 +HOMEPAGE="http://llvm.org/"
700 +SRC_URI="http://llvm.org/releases/${PV}/${P}.src.tar.xz
701 + clang? ( http://llvm.org/releases/${PV}/compiler-rt-${PV}.src.tar.xz
702 + http://llvm.org/releases/${PV}/cfe-${PV}.src.tar.xz
703 + http://llvm.org/releases/${PV}/clang-tools-extra-${PV}.src.tar.xz )
704 + !doc? ( http://dev.gentoo.org/~voyageur/distfiles/${P}-manpages.tar.bz2 )"
705 +
706 +LICENSE="UoI-NCSA"
707 +SLOT="0/3.5"
708 +KEYWORDS="amd64 arm ppc x86"
709 +IUSE="clang debug doc gold libedit +libffi multitarget ncurses ocaml python
710 + +static-analyzer test xml video_cards_radeon
711 + kernel_Darwin kernel_FreeBSD"
712 +
713 +COMMON_DEPEND="
714 + sys-libs/zlib:0=
715 + clang? (
716 + python? ( ${PYTHON_DEPS} )
717 + static-analyzer? (
718 + dev-lang/perl:*
719 + ${PYTHON_DEPS}
720 + )
721 + xml? ( dev-libs/libxml2:2= )
722 + )
723 + gold? ( >=sys-devel/binutils-2.22:*[cxx] )
724 + libedit? ( dev-libs/libedit:0=[${MULTILIB_USEDEP}] )
725 + libffi? ( >=virtual/libffi-3.0.13-r1:0=[${MULTILIB_USEDEP}] )
726 + ncurses? ( >=sys-libs/ncurses-5.9-r3:5=[${MULTILIB_USEDEP}] )
727 + ocaml? ( dev-lang/ocaml:0= )"
728 +# configparser-3.2 breaks the build (3.3 or none at all are fine)
729 +DEPEND="${COMMON_DEPEND}
730 + app-arch/xz-utils
731 + dev-lang/perl
732 + >=sys-devel/make-3.81
733 + >=sys-devel/flex-2.5.4
734 + >=sys-devel/bison-1.875d
735 + || ( >=sys-devel/gcc-3.0 >=sys-devel/gcc-apple-4.2.1
736 + ( >=sys-freebsd/freebsd-lib-9.1-r10 sys-libs/libcxx )
737 + )
738 + || ( >=sys-devel/binutils-2.18 >=sys-devel/binutils-apple-3.2.3 )
739 + clang? ( xml? ( virtual/pkgconfig ) )
740 + doc? ( dev-python/sphinx )
741 + libffi? ( virtual/pkgconfig )
742 + !!<dev-python/configparser-3.3.0.2
743 + ${PYTHON_DEPS}"
744 +RDEPEND="${COMMON_DEPEND}
745 + clang? ( !<=sys-devel/clang-${PV}-r99
746 + !>=sys-devel/clang-9999 )
747 + abi_x86_32? ( !<=app-emulation/emul-linux-x86-baselibs-20130224-r2
748 + !app-emulation/emul-linux-x86-baselibs[-abi_x86_32(-)] )"
749 +PDEPEND="clang? ( =sys-devel/clang-${PV}-r100 )"
750 +
751 +# pypy gives me around 1700 unresolved tests due to open file limit
752 +# being exceeded. probably GC does not close them fast enough.
753 +REQUIRED_USE="${PYTHON_REQUIRED_USE}
754 + test? ( || ( $(python_gen_useflags 'python*') ) )"
755 +
756 +S=${WORKDIR}/${P}.src
757 +
758 +# Some people actually override that in make.conf. That sucks since
759 +# we need to run install per-directory, and ninja can't do that...
760 +# so why did it call itself ninja in the first place?
761 +CMAKE_MAKEFILE_GENERATOR=emake
762 +
763 +pkg_pretend() {
764 + # in megs
765 + # !clang !debug !multitarget -O2 400
766 + # !clang !debug multitarget -O2 550
767 + # clang !debug !multitarget -O2 950
768 + # clang !debug multitarget -O2 1200
769 + # !clang debug multitarget -O2 5G
770 + # clang !debug multitarget -O0 -g 12G
771 + # clang debug multitarget -O2 16G
772 + # clang debug multitarget -O0 -g 14G
773 +
774 + local build_size=550
775 + use clang && build_size=1200
776 +
777 + if use debug; then
778 + ewarn "USE=debug is known to increase the size of package considerably"
779 + ewarn "and cause the tests to fail."
780 + ewarn
781 +
782 + (( build_size *= 14 ))
783 + elif is-flagq -g || is-flagq -ggdb; then
784 + ewarn "The C++ compiler -g option is known to increase the size of the package"
785 + ewarn "considerably. If you run out of space, please consider removing it."
786 + ewarn
787 +
788 + (( build_size *= 10 ))
789 + fi
790 +
791 + # Multiply by number of ABIs :).
792 + local abis=( $(multilib_get_enabled_abis) )
793 + (( build_size *= ${#abis[@]} ))
794 +
795 + local CHECKREQS_DISK_BUILD=${build_size}M
796 + check-reqs_pkg_pretend
797 +
798 + if [[ ${MERGE_TYPE} != binary ]]; then
799 + echo 'int main() {return 0;}' > "${T}"/test.cxx || die
800 + ebegin "Trying to build a C++11 test program"
801 + if ! $(tc-getCXX) -std=c++11 -o /dev/null "${T}"/test.cxx; then
802 + eerror "LLVM-${PV} requires C++11-capable C++ compiler. Your current compiler"
803 + eerror "does not seem to support -std=c++11 option. Please upgrade your compiler"
804 + eerror "to gcc-4.7 or an equivalent version supporting C++11."
805 + die "Currently active compiler does not support -std=c++11"
806 + fi
807 + eend ${?}
808 + fi
809 +}
810 +
811 +pkg_setup() {
812 + pkg_pretend
813 +}
814 +
815 +src_unpack() {
816 + default
817 +
818 + rm -f "${S}"/tools/clang "${S}"/projects/compiler-rt \
819 + || die "symlinks removal failed"
820 +
821 + if use clang; then
822 + mv "${WORKDIR}"/cfe-${PV}.src "${S}"/tools/clang \
823 + || die "clang source directory move failed"
824 + mv "${WORKDIR}"/compiler-rt-${PV}.src "${S}"/projects/compiler-rt \
825 + || die "compiler-rt source directory move failed"
826 + mv "${WORKDIR}"/clang-tools-extra-${PV}.src "${S}"/tools/clang/tools/extra \
827 + || die "clang-tools-extra source directory move failed"
828 + fi
829 +}
830 +
831 +src_prepare() {
832 + epatch "${FILESDIR}"/${PN}-3.2-nodoctargz.patch
833 + epatch "${FILESDIR}"/${PN}-3.5-gcc-4.9.patch
834 + epatch "${FILESDIR}"/${PN}-3.5-gentoo-install.patch
835 +
836 + epatch "${FILESDIR}"/${PN}-3.5-musl-fixes.patch
837 + epatch "${FILESDIR}"/${PN}-3.5-musl-support.patch
838 + epatch "${FILESDIR}"/${PN}-3.5-musl-compiler-rt.patch
839 +
840 + epatch "${FILESDIR}"/${P}-fix_LLVMExports_cmake.patch
841 +
842 + if use clang; then
843 + # Automatically select active system GCC's libraries, bugs #406163 and #417913
844 + epatch "${FILESDIR}"/clang-3.5-gentoo-runtime-gcc-detection-v3.patch
845 +
846 + epatch "${FILESDIR}"/clang-3.5-gentoo-install.patch
847 + epatch "${FILESDIR}"/clang-3.4-darwin_prefix-include-paths.patch
848 + eprefixify tools/clang/lib/Frontend/InitHeaderSearch.cpp
849 + fi
850 +
851 + if use prefix && use clang; then
852 + sed -i -e "/^CFLAGS /s@-Werror@-I${EPREFIX}/usr/include@" \
853 + projects/compiler-rt/make/platform/clang_*.mk || die
854 + fi
855 +
856 + local sub_files=(
857 + Makefile.config.in
858 + Makefile.rules
859 + tools/llvm-config/llvm-config.cpp
860 + )
861 + use clang && sub_files+=(
862 + tools/clang/lib/Driver/Tools.cpp
863 + tools/clang/tools/scan-build/scan-build
864 + )
865 +
866 + # unfortunately ./configure won't listen to --mandir and the-like, so take
867 + # care of this.
868 + # note: we're setting the main libdir intentionally.
869 + # where per-ABI is appropriate, we use $(GENTOO_LIBDIR) make.
870 + einfo "Fixing install dirs"
871 + sed -e "s,@libdir@,$(get_libdir),g" \
872 + -e "s,@PF@,${PF},g" \
873 + -e "s,@EPREFIX@,${EPREFIX},g" \
874 + -i "${sub_files[@]}" \
875 + || die "install paths sed failed"
876 +
877 + if use clang; then
878 + # constantly fails for a long time, likely due to our patches
879 + rm tools/clang/test/Driver/cross-linux.c || die
880 + fi
881 +
882 + # User patches
883 + epatch_user
884 +
885 + python_setup
886 +}
887 +
888 +multilib_src_configure() {
889 + # disable timestamps since they confuse ccache
890 + local conf_flags=(
891 + --disable-timestamps
892 + --enable-keep-symbols
893 + --enable-shared
894 + --with-optimize-option=
895 + $(tc-is-static-only && echo --disable-shared)
896 + $(use_enable !debug optimized)
897 + $(use_enable debug assertions)
898 + $(use_enable debug expensive-checks)
899 + $(use_enable libedit)
900 + $(use_enable ncurses terminfo)
901 + $(use_enable libffi)
902 + )
903 +
904 + # well, it's used only by clang executable c-index-test
905 + if multilib_is_native_abi && use clang && use xml; then
906 + conf_flags+=( XML2CONFIG="$(tc-getPKG_CONFIG) libxml-2.0" )
907 + else
908 + conf_flags+=( ac_cv_prog_XML2CONFIG="" )
909 + fi
910 +
911 + local targets bindings
912 + if use multitarget; then
913 + targets='all'
914 + else
915 + targets='host,cpp'
916 + use video_cards_radeon && targets+=',r600'
917 + fi
918 + conf_flags+=( --enable-targets=${targets} )
919 +
920 + if multilib_is_native_abi; then
921 + use gold && conf_flags+=( --with-binutils-include="${EPREFIX}"/usr/include/ )
922 + # extra commas don't hurt
923 + use ocaml && bindings+=',ocaml'
924 + fi
925 +
926 + [[ ${bindings} ]] || bindings='none'
927 + conf_flags+=( --enable-bindings=${bindings} )
928 +
929 + if use libffi; then
930 + local CPPFLAGS=${CPPFLAGS}
931 + append-cppflags "$(pkg-config --cflags libffi)"
932 + fi
933 +
934 + # llvm prefers clang over gcc, so we may need to force that
935 + tc-export CC CXX
936 +
937 + ECONF_SOURCE=${S} \
938 + econf "${conf_flags[@]}"
939 +}
940 +
941 +set_makeargs() {
942 + MAKEARGS=(
943 + VERBOSE=1
944 + REQUIRES_RTTI=1
945 + GENTOO_LIBDIR=$(get_libdir)
946 + )
947 +
948 + # for tests, we want it all! otherwise, we may use a little filtering...
949 + # adding ONLY_TOOLS also disables unittest building...
950 + if [[ ${EBUILD_PHASE_FUNC} != src_test ]]; then
951 + local tools=( llvm-config )
952 + use clang && tools+=( clang )
953 +
954 + if multilib_is_native_abi; then
955 + tools+=(
956 + opt llvm-as llvm-dis llc llvm-ar llvm-nm llvm-link lli
957 + llvm-extract llvm-mc llvm-bcanalyzer llvm-diff macho-dump
958 + llvm-objdump llvm-readobj llvm-rtdyld llvm-dwarfdump llvm-cov
959 + llvm-size llvm-stress llvm-mcmarkup llvm-profdata
960 + llvm-symbolizer obj2yaml yaml2obj lto bugpoint
961 + )
962 +
963 + # the build system runs explicitly specified tools in parallel,
964 + # so we need to split it into two runs
965 + if [[ ${1} != -1 ]]; then
966 + # those require lto
967 + tools+=( llvm-lto )
968 + use gold && tools+=( gold )
969 +
970 + # those require clang :)
971 + # we need to explicitly specify all its tools
972 + # since we're passing BUILD_CLANG_ONLY
973 + use clang && tools+=(
974 + clang/tools/{clang-check,clang-format,extra}
975 + )
976 + fi
977 + fi
978 +
979 + MAKEARGS+=(
980 + # filter tools + disable unittests implicitly
981 + ONLY_TOOLS="${tools[*]}"
982 +
983 + # this disables unittests & docs from clang
984 + BUILD_CLANG_ONLY=YES
985 + )
986 + fi
987 +}
988 +
989 +multilib_src_compile() {
990 + local MAKEARGS
991 + set_makeargs -1
992 + emake "${MAKEARGS[@]}"
993 +
994 + if multilib_is_native_abi; then
995 + set_makeargs
996 + emake -C tools "${MAKEARGS[@]}"
997 +
998 + if use doc; then
999 + emake -C "${S}"/docs -f Makefile.sphinx man
1000 + use clang && emake -C "${S}"/tools/clang/docs/tools \
1001 + BUILD_FOR_WEBSITE=1 DST_MAN_DIR="${T}"/ man
1002 + emake -C "${S}"/docs -f Makefile.sphinx html
1003 + fi
1004 + fi
1005 +
1006 + if use debug; then
1007 + pax-mark m Debug+Asserts+Checks/bin/llvm-rtdyld
1008 + pax-mark m Debug+Asserts+Checks/bin/lli
1009 + pax-mark m Debug+Asserts+Checks/bin/lli-child-target
1010 + else
1011 + pax-mark m Release/bin/llvm-rtdyld
1012 + pax-mark m Release/bin/lli
1013 + pax-mark m Release/bin/lli-child-target
1014 + fi
1015 +}
1016 +
1017 +multilib_src_test() {
1018 + local MAKEARGS
1019 + set_makeargs
1020 +
1021 + # build the remaining tools & unittests
1022 + emake "${MAKEARGS[@]}"
1023 +
1024 + pax-mark m unittests/ExecutionEngine/JIT/Release/JITTests
1025 + pax-mark m unittests/ExecutionEngine/MCJIT/Release/MCJITTests
1026 + pax-mark m unittests/Support/Release/SupportTests
1027 +
1028 + # respect TMPDIR!
1029 + local -x LIT_PRESERVES_TMP=1
1030 + emake "${MAKEARGS[@]}" check
1031 + use clang && emake "${MAKEARGS[@]}" -C tools/clang test
1032 +}
1033 +
1034 +src_install() {
1035 + local MULTILIB_CHOST_TOOLS=(
1036 + /usr/bin/llvm-config
1037 + )
1038 +
1039 + local MULTILIB_WRAPPED_HEADERS=(
1040 + /usr/include/llvm/Config/config.h
1041 + /usr/include/llvm/Config/llvm-config.h
1042 + )
1043 +
1044 + if use clang; then
1045 + # note: magic applied below
1046 + MULTILIB_CHOST_TOOLS+=(
1047 + /usr/bin/clang
1048 + /usr/bin/clang++
1049 + /usr/bin/clang-${PV}
1050 + /usr/bin/clang++-${PV}
1051 + )
1052 +
1053 + MULTILIB_WRAPPED_HEADERS+=(
1054 + /usr/include/clang/Config/config.h
1055 + )
1056 + fi
1057 +
1058 + multilib-minimal_src_install
1059 +
1060 + # Remove unnecessary headers on FreeBSD, bug #417171
1061 + use kernel_FreeBSD && use clang && rm "${ED}"usr/lib/clang/${PV}/include/{std,float,iso,limits,tgmath,varargs}*.h
1062 +}
1063 +
1064 +multilib_src_install() {
1065 + local MAKEARGS
1066 + set_makeargs
1067 +
1068 + local root=${D}/_${ABI}
1069 +
1070 + emake "${MAKEARGS[@]}" DESTDIR="${root}" install
1071 + multibuild_merge_root "${root}" "${D}"
1072 +
1073 + if ! multilib_is_native_abi; then
1074 + # Backwards compat, will be happily removed someday.
1075 + dosym "${CHOST}"-llvm-config /usr/bin/llvm-config.${ABI}
1076 + else
1077 + # Install docs.
1078 + if use doc; then
1079 + doman "${S}"/docs/_build/man/*.1
1080 + use clang && doman "${T}"/clang.1
1081 + dohtml -r "${S}"/docs/_build/html/
1082 + else
1083 + if ! use clang; then
1084 + rm "${WORKDIR}"/${P}-manpages/clang.1 || die
1085 + fi
1086 + doman "${WORKDIR}"/${P}-manpages/*.1
1087 + fi
1088 +
1089 + # Symlink the gold plugin.
1090 + if use gold; then
1091 + dodir /usr/${CHOST}/binutils-bin/lib/bfd-plugins
1092 + dosym ../../../../$(get_libdir)/LLVMgold.so \
1093 + /usr/${CHOST}/binutils-bin/lib/bfd-plugins/LLVMgold.so
1094 + fi
1095 + fi
1096 +
1097 + # apply CHOST and PV to clang executables
1098 + # they're statically linked so we don't have to worry about the lib
1099 + if use clang; then
1100 + local clang_tools=( clang clang++ )
1101 + local i
1102 +
1103 + # append ${PV} and symlink back
1104 + # TODO: use alternatives.eclass? does that make any sense?
1105 + # maybe with USE=-clang on :0 and USE=clang on older
1106 + for i in "${clang_tools[@]}"; do
1107 + mv "${ED%/}/usr/bin/${i}"{,-${PV}} || die
1108 + dosym "${i}"-${PV} /usr/bin/${i}
1109 + done
1110 +
1111 + # now prepend ${CHOST} and let the multilib-build.eclass symlink it
1112 + if ! multilib_is_native_abi; then
1113 + # non-native? let's replace it with a simple wrapper
1114 + for i in "${clang_tools[@]}"; do
1115 + rm "${ED%/}/usr/bin/${i}-${PV}" || die
1116 + cat > "${T}"/wrapper.tmp <<-_EOF_
1117 + #!${EPREFIX}/bin/sh
1118 + exec "${i}-${PV}" $(get_abi_CFLAGS) "\${@}"
1119 + _EOF_
1120 + newbin "${T}"/wrapper.tmp "${i}-${PV}"
1121 + done
1122 + fi
1123 + fi
1124 +
1125 + # Fix install_names on Darwin. The build system is too complicated
1126 + # to just fix this, so we correct it post-install
1127 + local lib= f= odylib= ndylib= libpv=${PV}
1128 + if [[ ${CHOST} == *-darwin* ]] ; then
1129 + eval $(grep PACKAGE_VERSION= configure)
1130 + [[ -n ${PACKAGE_VERSION} ]] && libpv=${PACKAGE_VERSION}
1131 + for lib in lib{EnhancedDisassembly,LLVM-${libpv},LTO,profile_rt,clang}.dylib LLVMHello.dylib clang/${libpv}/lib/darwin/libclang_rt.asan_osx_dynamic.dylib; do
1132 + # libEnhancedDisassembly is Darwin10 only, so non-fatal
1133 + # + omit clang libs if not enabled
1134 + [[ -f ${ED}/usr/lib/${lib} ]] || continue
1135 +
1136 + ebegin "fixing install_name of $lib"
1137 + install_name_tool \
1138 + -id "${EPREFIX}"/usr/lib/${lib} \
1139 + "${ED}"/usr/lib/${lib}
1140 + eend $?
1141 + done
1142 + for f in "${ED}"/usr/bin/* "${ED}"/usr/lib/lib*.dylib "${ED}"/usr/lib/clang/${libpv}/lib/darwin/*.dylib ; do
1143 + # omit clang libs if not enabled
1144 + [[ -f ${ED}/usr/lib/${lib} ]] || continue
1145 +
1146 + scanmacho -BF'%n#f' "${f}" | tr ',' '\n' | \
1147 + while read odylib ; do
1148 + ndylib=
1149 + case ${odylib} in
1150 + */libclang.dylib)
1151 + ndylib="${EPREFIX}"/usr/lib/libclang.dylib
1152 + ;;
1153 + */libLLVM-${libpv}.dylib)
1154 + ndylib="${EPREFIX}"/usr/lib/libLLVM-${libpv}.dylib
1155 + ;;
1156 + */libLTO.dylib)
1157 + ndylib="${EPREFIX}"/usr/lib/libLTO.dylib
1158 + ;;
1159 + esac
1160 + if [[ -n ${ndylib} ]] ; then
1161 + ebegin "fixing install_name reference to ${odylib} of ${f##*/}"
1162 + install_name_tool \
1163 + -change "${odylib}" "${ndylib}" \
1164 + "${f}"
1165 + eend $?
1166 + fi
1167 + done
1168 + done
1169 + fi
1170 +}
1171 +
1172 +multilib_src_install_all() {
1173 + insinto /usr/share/vim/vimfiles/syntax
1174 + doins utils/vim/*.vim
1175 +
1176 + if use clang; then
1177 + cd tools/clang || die
1178 +
1179 + if use static-analyzer ; then
1180 + dobin tools/scan-build/ccc-analyzer
1181 + dosym ccc-analyzer /usr/bin/c++-analyzer
1182 + dobin tools/scan-build/scan-build
1183 +
1184 + insinto /usr/share/${PN}
1185 + doins tools/scan-build/scanview.css
1186 + doins tools/scan-build/sorttable.js
1187 + fi
1188 +
1189 + python_inst() {
1190 + if use static-analyzer ; then
1191 + pushd tools/scan-view >/dev/null || die
1192 +
1193 + python_doscript scan-view
1194 +
1195 + touch __init__.py || die
1196 + python_moduleinto clang
1197 + python_domodule __init__.py Reporter.py Resources ScanView.py startfile.py
1198 +
1199 + popd >/dev/null || die
1200 + fi
1201 +
1202 + if use python ; then
1203 + pushd bindings/python/clang >/dev/null || die
1204 +
1205 + python_moduleinto clang
1206 + python_domodule __init__.py cindex.py enumerations.py
1207 +
1208 + popd >/dev/null || die
1209 + fi
1210 +
1211 + # AddressSanitizer symbolizer (currently separate)
1212 + python_doscript "${S}"/projects/compiler-rt/lib/asan/scripts/asan_symbolize.py
1213 + }
1214 + python_foreach_impl python_inst
1215 + fi
1216 +}
1217
1218 diff --git a/sys-devel/llvm/metadata.xml b/sys-devel/llvm/metadata.xml
1219 new file mode 100644
1220 index 0000000..1a63066
1221 --- /dev/null
1222 +++ b/sys-devel/llvm/metadata.xml
1223 @@ -0,0 +1,28 @@
1224 +<?xml version="1.0" encoding="UTF-8"?>
1225 +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
1226 +<pkgmetadata>
1227 + <maintainer>
1228 + <email>voyageur@g.o</email>
1229 + <name>Bernard Cafarelli</name>
1230 + </maintainer>
1231 + <maintainer>
1232 + <email>mgorny@g.o</email>
1233 + <name>Michał Górny</name>
1234 + </maintainer>
1235 + <longdescription>Low Level Virtual Machine (LLVM) is:
1236 + 1. A compilation strategy designed to enable effective program optimization across the entire lifetime of a program. LLVM supports effective optimization at compile time, link-time (particularly interprocedural), run-time and offline (i.e., after software is installed), while remaining transparent to developers and maintaining compatibility with existing build scripts.
1237 + 2. A virtual instruction set - LLVM is a low-level object code representation that uses simple RISC-like instructions, but provides rich, language-independent, type information and dataflow (SSA) information about operands. This combination enables sophisticated transformations on object code, while remaining light-weight enough to be attached to the executable. This combination is key to allowing link-time, run-time, and offline transformations.
1238 + 3. A compiler infrastructure - LLVM is also a collection of source code that implements the language and compilation strategy. The primary components of the LLVM infrastructure are a GCC-based C and C++ front-end, a link-time optimization framework with a growing set of global and interprocedural analyses and transformations, static back-ends for many popular (and some obscure) architectures, a back-end which emits portable C code, and a Just-In-Time compilers for several architectures.
1239 + 4. LLVM does not imply things that you would expect from a high-level virtual machine. It does not require garbage collection or run-time code generation (In fact, LLVM makes a great static compiler!). Note that optional LLVM components can be used to build high-level virtual machines and other systems that need these services.</longdescription>
1240 + <use>
1241 + <flag name='clang'>Build the clang C/C++ compiler</flag>
1242 + <flag name='cmake'>Enable cmake support (experimental)</flag>
1243 + <flag name='doc'>Build and install the HTML documentation and regenerate the man pages</flag>
1244 + <flag name='gold'>Build the gold linker plugin</flag>
1245 + <flag name='llvm-gcc'>Build LLVM with <pkg>sys-devel/llvm-gcc</pkg></flag>
1246 + <flag name='multitarget'>Build all host targets (default: host only)</flag>
1247 + <flag name='ncurses'>Support querying terminal properties using ncurses' terminfo</flag>
1248 + <flag name='static-analyzer'>Install the Clang static analyzer (requires USE=clang)</flag>
1249 + <flag name='udis86'>Enable support for <pkg>dev-libs/udis86</pkg> disassembler library</flag>
1250 + </use>
1251 +</pkgmetadata>