1 |
commit: 8517679a0aac8bc07793b6781d2249b71dc23daf |
2 |
Author: Lei Zhang <zhanglei.april <AT> gmail <DOT> com> |
3 |
AuthorDate: Tue Jul 19 09:53:38 2016 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Aug 1 21:49:26 2016 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8517679a |
7 |
|
8 |
sys-devel/llvm: musl & default runtime lib switches, #589352 |
9 |
|
10 |
- add support for building llvm against musl |
11 |
- enable clang to build binaries against musl |
12 |
- introduce USE flag "sanitize" to control the building of compiler-rt's |
13 |
sanitizers (they cause problem on musl) |
14 |
- be able to override default values of -stdlib and -rtlib for clang |
15 |
* USE="default-libcxx" implies -stdlib=libc++ (originally libstdc++) |
16 |
* USE="default-compiler-rt" implies -rtlib=compiler-rt (originally libgcc) |
17 |
|
18 |
profiles/package.mask | 6 + |
19 |
sys-devel/llvm/files/clang-3.8-default-libs.patch | 106 ++++ |
20 |
sys-devel/llvm/files/clang-3.8-musl-support.patch | 108 +++++ |
21 |
sys-devel/llvm/files/llvm-3.8-musl-fixes.patch | 33 ++ |
22 |
sys-devel/llvm/files/llvm-3.8-musl-support.patch | 164 +++++++ |
23 |
sys-devel/llvm/llvm-3.8.1-r1.ebuild | 560 ++++++++++++++++++++++ |
24 |
sys-devel/llvm/metadata.xml | 3 + |
25 |
7 files changed, 980 insertions(+) |
26 |
|
27 |
diff --git a/profiles/package.mask b/profiles/package.mask |
28 |
index a66b5ae..3fe3d37 100644 |
29 |
--- a/profiles/package.mask |
30 |
+++ b/profiles/package.mask |
31 |
@@ -30,6 +30,12 @@ |
32 |
|
33 |
#--- END OF EXAMPLES --- |
34 |
|
35 |
+# Michał Górny <mgorny@g.o> (1 Aug 2016) |
36 |
+# Masked for testing, handling keywords and collecting more changes |
37 |
+# before unleashing the huge rebuild on all users. Has gotten musl |
38 |
+# support and switches to control the default rtlib and C++ library. |
39 |
+=sys-devel/llvm-3.8.1-r1 |
40 |
+ |
41 |
# Johannes Huber <johu@g.o> (1 Aug 2016) |
42 |
# Masked for removal in 30 days. Dead by upstream. Last release |
43 |
# with 15.08. Exported to kde-sunset overlay. |
44 |
|
45 |
diff --git a/sys-devel/llvm/files/clang-3.8-default-libs.patch b/sys-devel/llvm/files/clang-3.8-default-libs.patch |
46 |
new file mode 100644 |
47 |
index 0000000..8d172f7 |
48 |
--- /dev/null |
49 |
+++ b/sys-devel/llvm/files/clang-3.8-default-libs.patch |
50 |
@@ -0,0 +1,106 @@ |
51 |
+diff --git a/CMakeLists.txt b/CMakeLists.txt |
52 |
+index ad2ac42..18dcfbe 100644 |
53 |
+--- a/CMakeLists.txt |
54 |
++++ b/CMakeLists.txt |
55 |
+@@ -196,6 +196,24 @@ set(GCC_INSTALL_PREFIX "" CACHE PATH "Directory where gcc is installed." ) |
56 |
+ set(DEFAULT_SYSROOT "" CACHE PATH |
57 |
+ "Default <path> to all compiler invocations for --sysroot=<path>." ) |
58 |
+ |
59 |
++set(CLANG_DEFAULT_CXX_STDLIB "" CACHE STRING |
60 |
++ "Default C++ stdlib to use (libstdc++ or libc++)") |
61 |
++if (NOT(CLANG_DEFAULT_CXX_STDLIB STREQUAL "" OR |
62 |
++ CLANG_DEFAULT_CXX_STDLIB STREQUAL "libstdc++" OR |
63 |
++ CLANG_DEFAULT_CXX_STDLIB STREQUAL "libc++")) |
64 |
++ message(WARNING "Resetting default C++ stdlib to use platform default") |
65 |
++ set(CLANG_DEFAULT_CXX_STDLIB "") |
66 |
++endif() |
67 |
++ |
68 |
++set(CLANG_DEFAULT_RTLIB "" CACHE STRING |
69 |
++ "Default runtime library to use (libgcc or compiler-rt)") |
70 |
++if (NOT(CLANG_DEFAULT_RTLIB STREQUAL "" OR |
71 |
++ CLANG_DEFAULT_RTLIB STREQUAL "libgcc" OR |
72 |
++ CLANG_DEFAULT_RTLIB STREQUAL "compiler-rt")) |
73 |
++ message(WARNING "Resetting default rtlib to use platform default") |
74 |
++ set(CLANG_DEFAULT_RTLIB "") |
75 |
++endif() |
76 |
++ |
77 |
+ set(CLANG_DEFAULT_OPENMP_RUNTIME "libomp" CACHE STRING |
78 |
+ "Default OpenMP runtime used by -fopenmp.") |
79 |
+ |
80 |
+diff --git a/include/clang/Config/config.h.cmake b/include/clang/Config/config.h.cmake |
81 |
+index b7486f3..eb8aa27 100644 |
82 |
+--- a/include/clang/Config/config.h.cmake |
83 |
++++ b/include/clang/Config/config.h.cmake |
84 |
+@@ -8,6 +8,12 @@ |
85 |
+ /* Bug report URL. */ |
86 |
+ #define BUG_REPORT_URL "${BUG_REPORT_URL}" |
87 |
+ |
88 |
++/* Default C++ stdlib to use. */ |
89 |
++#define CLANG_DEFAULT_CXX_STDLIB "${CLANG_DEFAULT_CXX_STDLIB}" |
90 |
++ |
91 |
++/* Default runtime library to use. */ |
92 |
++#define CLANG_DEFAULT_RTLIB "${CLANG_DEFAULT_RTLIB}" |
93 |
++ |
94 |
+ /* Default OpenMP runtime used by -fopenmp. */ |
95 |
+ #define CLANG_DEFAULT_OPENMP_RUNTIME "${CLANG_DEFAULT_OPENMP_RUNTIME}" |
96 |
+ |
97 |
+diff --git a/lib/Driver/ToolChain.cpp b/lib/Driver/ToolChain.cpp |
98 |
+index cbbd485..3af7f8a 100644 |
99 |
+--- a/lib/Driver/ToolChain.cpp |
100 |
++++ b/lib/Driver/ToolChain.cpp |
101 |
+@@ -9,6 +9,7 @@ |
102 |
+ |
103 |
+ #include "Tools.h" |
104 |
+ #include "clang/Basic/ObjCRuntime.h" |
105 |
++#include "clang/Config/config.h" |
106 |
+ #include "clang/Driver/Action.h" |
107 |
+ #include "clang/Driver/Driver.h" |
108 |
+ #include "clang/Driver/DriverDiagnostic.h" |
109 |
+@@ -520,29 +521,29 @@ void ToolChain::addProfileRTLibs(const llvm::opt::ArgList &Args, |
110 |
+ |
111 |
+ ToolChain::RuntimeLibType ToolChain::GetRuntimeLibType( |
112 |
+ const ArgList &Args) const { |
113 |
+- if (Arg *A = Args.getLastArg(options::OPT_rtlib_EQ)) { |
114 |
+- StringRef Value = A->getValue(); |
115 |
+- if (Value == "compiler-rt") |
116 |
+- return ToolChain::RLT_CompilerRT; |
117 |
+- if (Value == "libgcc") |
118 |
+- return ToolChain::RLT_Libgcc; |
119 |
+- getDriver().Diag(diag::err_drv_invalid_rtlib_name) |
120 |
+- << A->getAsString(Args); |
121 |
+- } |
122 |
++ const Arg* A = Args.getLastArg(options::OPT_rtlib_EQ); |
123 |
++ StringRef LibName = A ? A->getValue() : CLANG_DEFAULT_RTLIB; |
124 |
++ |
125 |
++ if (LibName == "compiler-rt") |
126 |
++ return ToolChain::RLT_CompilerRT; |
127 |
++ if (LibName == "libgcc") |
128 |
++ return ToolChain::RLT_Libgcc; |
129 |
++ if (A) |
130 |
++ getDriver().Diag(diag::err_drv_invalid_rtlib_name) << A->getAsString(Args); |
131 |
+ |
132 |
+ return GetDefaultRuntimeLibType(); |
133 |
+ } |
134 |
+ |
135 |
+ ToolChain::CXXStdlibType ToolChain::GetCXXStdlibType(const ArgList &Args) const{ |
136 |
+- if (Arg *A = Args.getLastArg(options::OPT_stdlib_EQ)) { |
137 |
+- StringRef Value = A->getValue(); |
138 |
+- if (Value == "libc++") |
139 |
+- return ToolChain::CST_Libcxx; |
140 |
+- if (Value == "libstdc++") |
141 |
+- return ToolChain::CST_Libstdcxx; |
142 |
+- getDriver().Diag(diag::err_drv_invalid_stdlib_name) |
143 |
+- << A->getAsString(Args); |
144 |
+- } |
145 |
++ const Arg* A = Args.getLastArg(options::OPT_stdlib_EQ); |
146 |
++ StringRef LibName = A ? A->getValue() : CLANG_DEFAULT_CXX_STDLIB; |
147 |
++ |
148 |
++ if (LibName == "libc++") |
149 |
++ return ToolChain::CST_Libcxx; |
150 |
++ if (LibName == "libstdc++") |
151 |
++ return ToolChain::CST_Libstdcxx; |
152 |
++ if (A) |
153 |
++ getDriver().Diag(diag::err_drv_invalid_stdlib_name) << A->getAsString(Args); |
154 |
+ |
155 |
+ return ToolChain::CST_Libstdcxx; |
156 |
+ } |
157 |
|
158 |
diff --git a/sys-devel/llvm/files/clang-3.8-musl-support.patch b/sys-devel/llvm/files/clang-3.8-musl-support.patch |
159 |
new file mode 100644 |
160 |
index 0000000..8a234e6 |
161 |
--- /dev/null |
162 |
+++ b/sys-devel/llvm/files/clang-3.8-musl-support.patch |
163 |
@@ -0,0 +1,108 @@ |
164 |
+diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp |
165 |
+index 9c6eaff..92872ab 100644 |
166 |
+--- a/lib/Basic/Targets.cpp |
167 |
++++ b/lib/Basic/Targets.cpp |
168 |
+@@ -4513,6 +4513,8 @@ public: |
169 |
+ case llvm::Triple::Android: |
170 |
+ case llvm::Triple::GNUEABI: |
171 |
+ case llvm::Triple::GNUEABIHF: |
172 |
++ case llvm::Triple::MuslEABI: |
173 |
++ case llvm::Triple::MuslEABIHF: |
174 |
+ setABI("aapcs-linux"); |
175 |
+ break; |
176 |
+ case llvm::Triple::EABIHF: |
177 |
+diff --git a/lib/CodeGen/TargetInfo.cpp b/lib/CodeGen/TargetInfo.cpp |
178 |
+index 04edc0c..298b2cc 100644 |
179 |
+--- a/lib/CodeGen/TargetInfo.cpp |
180 |
++++ b/lib/CodeGen/TargetInfo.cpp |
181 |
+@@ -4811,6 +4811,8 @@ public: |
182 |
+ case llvm::Triple::EABIHF: |
183 |
+ case llvm::Triple::GNUEABI: |
184 |
+ case llvm::Triple::GNUEABIHF: |
185 |
++ case llvm::Triple::MuslEABI: |
186 |
++ case llvm::Triple::MuslEABIHF: |
187 |
+ return true; |
188 |
+ default: |
189 |
+ return false; |
190 |
+@@ -4821,6 +4823,7 @@ public: |
191 |
+ switch (getTarget().getTriple().getEnvironment()) { |
192 |
+ case llvm::Triple::EABIHF: |
193 |
+ case llvm::Triple::GNUEABIHF: |
194 |
++ case llvm::Triple::MuslEABIHF: |
195 |
+ return true; |
196 |
+ default: |
197 |
+ return false; |
198 |
+@@ -7548,7 +7551,8 @@ const TargetCodeGenInfo &CodeGenModule::getTargetCodeGenInfo() { |
199 |
+ Kind = ARMABIInfo::AAPCS16_VFP; |
200 |
+ else if (CodeGenOpts.FloatABI == "hard" || |
201 |
+ (CodeGenOpts.FloatABI != "soft" && |
202 |
+- Triple.getEnvironment() == llvm::Triple::GNUEABIHF)) |
203 |
++ (Triple.getEnvironment() == llvm::Triple::GNUEABIHF || |
204 |
++ Triple.getEnvironment() == llvm::Triple::MuslEABIHF))) |
205 |
+ Kind = ARMABIInfo::AAPCS_VFP; |
206 |
+ |
207 |
+ return *(TheTargetCodeGenInfo = new ARMTargetCodeGenInfo(Types, Kind)); |
208 |
+diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp |
209 |
+index b7ac24f..2a529fb 100644 |
210 |
+--- a/lib/Driver/Tools.cpp |
211 |
++++ b/lib/Driver/Tools.cpp |
212 |
+@@ -724,13 +724,19 @@ arm::FloatABI arm::getARMFloatABI(const ToolChain &TC, const ArgList &Args) { |
213 |
+ default: |
214 |
+ switch (Triple.getEnvironment()) { |
215 |
+ case llvm::Triple::GNUEABIHF: |
216 |
++ case llvm::Triple::MuslEABIHF: |
217 |
+ case llvm::Triple::EABIHF: |
218 |
+ ABI = FloatABI::Hard; |
219 |
+ break; |
220 |
+ case llvm::Triple::GNUEABI: |
221 |
++ case llvm::Triple::MuslEABI: |
222 |
+ case llvm::Triple::EABI: |
223 |
+ // EABI is always AAPCS, and if it was not marked 'hard', it's softfp |
224 |
+- ABI = FloatABI::SoftFP; |
225 |
++ // |
226 |
++ // Also consider triples like armv7a-hardfloat-linux-eabi, where 'hard' |
227 |
++ // is marked in the vender field. |
228 |
++ ABI = (Triple.getVendorName() == "hardfloat") ? |
229 |
++ FloatABI::Hard : FloatABI::SoftFP; |
230 |
+ break; |
231 |
+ case llvm::Triple::Android: |
232 |
+ ABI = (SubArch == 7) ? FloatABI::SoftFP : FloatABI::Soft; |
233 |
+@@ -968,6 +974,8 @@ void Clang::AddARMTargetArgs(const llvm::Triple &Triple, const ArgList &Args, |
234 |
+ case llvm::Triple::Android: |
235 |
+ case llvm::Triple::GNUEABI: |
236 |
+ case llvm::Triple::GNUEABIHF: |
237 |
++ case llvm::Triple::MuslEABI: |
238 |
++ case llvm::Triple::MuslEABIHF: |
239 |
+ ABIName = "aapcs-linux"; |
240 |
+ break; |
241 |
+ case llvm::Triple::EABIHF: |
242 |
+@@ -8632,6 +8640,29 @@ static std::string getLinuxDynamicLinker(const ArgList &Args, |
243 |
+ return "/system/bin/linker64"; |
244 |
+ else |
245 |
+ return "/system/bin/linker"; |
246 |
++ } else if (ToolChain.getTriple().isMusl()) { |
247 |
++ std::string ArchName; |
248 |
++ bool IsArm = false; |
249 |
++ switch (Arch) { |
250 |
++ case llvm::Triple::arm: |
251 |
++ case llvm::Triple::thumb: |
252 |
++ ArchName = "arm"; |
253 |
++ IsArm = true; |
254 |
++ break; |
255 |
++ case llvm::Triple::armeb: |
256 |
++ case llvm::Triple::thumbeb: |
257 |
++ ArchName = "armeb"; |
258 |
++ IsArm = true; |
259 |
++ break; |
260 |
++ default: |
261 |
++ ArchName = ToolChain.getTriple().getArchName().str(); |
262 |
++ } |
263 |
++ if (IsArm && |
264 |
++ (ToolChain.getTriple().getEnvironment() == llvm::Triple::MuslEABIHF || |
265 |
++ arm::getARMFloatABI(ToolChain, Args) == arm::FloatABI::Hard)) |
266 |
++ ArchName += "hf"; |
267 |
++ |
268 |
++ return "/lib/ld-musl-" + ArchName + ".so.1"; |
269 |
+ } else if (Arch == llvm::Triple::x86 || Arch == llvm::Triple::sparc || |
270 |
+ Arch == llvm::Triple::sparcel) |
271 |
+ return "/lib/ld-linux.so.2"; |
272 |
|
273 |
diff --git a/sys-devel/llvm/files/llvm-3.8-musl-fixes.patch b/sys-devel/llvm/files/llvm-3.8-musl-fixes.patch |
274 |
new file mode 100644 |
275 |
index 0000000..5c51653 |
276 |
--- /dev/null |
277 |
+++ b/sys-devel/llvm/files/llvm-3.8-musl-fixes.patch |
278 |
@@ -0,0 +1,33 @@ |
279 |
+diff --git a/include/llvm/Analysis/TargetLibraryInfo.def b/include/llvm/Analysis/TargetLibraryInfo.def |
280 |
+index 7798e3c..ade2b96 100644 |
281 |
+--- a/include/llvm/Analysis/TargetLibraryInfo.def |
282 |
++++ b/include/llvm/Analysis/TargetLibraryInfo.def |
283 |
+@@ -27,6 +27,15 @@ |
284 |
+ #define TLI_DEFINE_STRING_INTERNAL(string_repr) string_repr, |
285 |
+ #endif |
286 |
+ |
287 |
++// avoid name conflicts with musl-libc |
288 |
++#undef fopen64 |
289 |
++#undef fseeko64 |
290 |
++#undef ftello64 |
291 |
++#undef fstat64 |
292 |
++#undef lstat64 |
293 |
++#undef stat64 |
294 |
++#undef tmpfile64 |
295 |
++ |
296 |
+ /// void *new(unsigned int); |
297 |
+ TLI_DEFINE_ENUM_INTERNAL(msvc_new_int) |
298 |
+ TLI_DEFINE_STRING_INTERNAL("??2@YAPAXI@Z") |
299 |
+diff --git a/lib/Support/DynamicLibrary.cpp b/lib/Support/DynamicLibrary.cpp |
300 |
+index 9a7aeb5..e98ad80 100644 |
301 |
+--- a/lib/Support/DynamicLibrary.cpp |
302 |
++++ b/lib/Support/DynamicLibrary.cpp |
303 |
+@@ -143,7 +143,7 @@ void* DynamicLibrary::SearchForAddressOfSymbol(const char *symbolName) { |
304 |
+ // On linux we have a weird situation. The stderr/out/in symbols are both |
305 |
+ // macros and global variables because of standards requirements. So, we |
306 |
+ // boldly use the EXPLICIT_SYMBOL macro without checking for a #define first. |
307 |
+-#if defined(__linux__) and !defined(__ANDROID__) |
308 |
++#if defined(__linux__) && defined(__GLIBC__) |
309 |
+ { |
310 |
+ EXPLICIT_SYMBOL(stderr); |
311 |
+ EXPLICIT_SYMBOL(stdout); |
312 |
|
313 |
diff --git a/sys-devel/llvm/files/llvm-3.8-musl-support.patch b/sys-devel/llvm/files/llvm-3.8-musl-support.patch |
314 |
new file mode 100644 |
315 |
index 0000000..8de660d |
316 |
--- /dev/null |
317 |
+++ b/sys-devel/llvm/files/llvm-3.8-musl-support.patch |
318 |
@@ -0,0 +1,164 @@ |
319 |
+diff --git a/include/llvm/ADT/Triple.h b/include/llvm/ADT/Triple.h |
320 |
+index e01db0a..bf9361a 100644 |
321 |
+--- a/include/llvm/ADT/Triple.h |
322 |
++++ b/include/llvm/ADT/Triple.h |
323 |
+@@ -173,6 +173,9 @@ public: |
324 |
+ EABI, |
325 |
+ EABIHF, |
326 |
+ Android, |
327 |
++ Musl, |
328 |
++ MuslEABI, |
329 |
++ MuslEABIHF, |
330 |
+ |
331 |
+ MSVC, |
332 |
+ Itanium, |
333 |
+@@ -544,6 +547,13 @@ public: |
334 |
+ /// Tests whether the target is Android |
335 |
+ bool isAndroid() const { return getEnvironment() == Triple::Android; } |
336 |
+ |
337 |
++ /// Tests whether the environment is musl-libc |
338 |
++ bool isMusl() const { |
339 |
++ return getEnvironment() == Triple::Musl || |
340 |
++ getEnvironment() == Triple::MuslEABI || |
341 |
++ getEnvironment() == Triple::MuslEABIHF; |
342 |
++ } |
343 |
++ |
344 |
+ /// @} |
345 |
+ /// @name Mutators |
346 |
+ /// @{ |
347 |
+diff --git a/lib/Support/Triple.cpp b/lib/Support/Triple.cpp |
348 |
+index 11afcf7..ad9cffd 100644 |
349 |
+--- a/lib/Support/Triple.cpp |
350 |
++++ b/lib/Support/Triple.cpp |
351 |
+@@ -200,6 +200,9 @@ const char *Triple::getEnvironmentTypeName(EnvironmentType Kind) { |
352 |
+ case EABI: return "eabi"; |
353 |
+ case EABIHF: return "eabihf"; |
354 |
+ case Android: return "android"; |
355 |
++ case Musl: return "musl"; |
356 |
++ case MuslEABI: return "musleabi"; |
357 |
++ case MuslEABIHF: return "musleabihf"; |
358 |
+ case MSVC: return "msvc"; |
359 |
+ case Itanium: return "itanium"; |
360 |
+ case Cygnus: return "cygnus"; |
361 |
+@@ -454,6 +457,9 @@ static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) { |
362 |
+ .StartsWith("code16", Triple::CODE16) |
363 |
+ .StartsWith("gnu", Triple::GNU) |
364 |
+ .StartsWith("android", Triple::Android) |
365 |
++ .StartsWith("musleabihf", Triple::MuslEABIHF) |
366 |
++ .StartsWith("musleabi", Triple::MuslEABI) |
367 |
++ .StartsWith("musl", Triple::Musl) |
368 |
+ .StartsWith("msvc", Triple::MSVC) |
369 |
+ .StartsWith("itanium", Triple::Itanium) |
370 |
+ .StartsWith("cygnus", Triple::Cygnus) |
371 |
+@@ -1431,6 +1437,7 @@ StringRef Triple::getARMCPUForArch(StringRef MArch) const { |
372 |
+ switch (getEnvironment()) { |
373 |
+ case llvm::Triple::EABIHF: |
374 |
+ case llvm::Triple::GNUEABIHF: |
375 |
++ case llvm::Triple::MuslEABIHF: |
376 |
+ return "arm1176jzf-s"; |
377 |
+ default: |
378 |
+ return "arm7tdmi"; |
379 |
+diff --git a/lib/Target/ARM/ARMAsmPrinter.cpp b/lib/Target/ARM/ARMAsmPrinter.cpp |
380 |
+index f3813c8..45e8c4a 100644 |
381 |
+--- a/lib/Target/ARM/ARMAsmPrinter.cpp |
382 |
++++ b/lib/Target/ARM/ARMAsmPrinter.cpp |
383 |
+@@ -541,7 +541,8 @@ void ARMAsmPrinter::EmitEndOfAsmFile(Module &M) { |
384 |
+ ARMTargetStreamer &ATS = static_cast<ARMTargetStreamer &>(TS); |
385 |
+ |
386 |
+ if (OptimizationGoals > 0 && |
387 |
+- (Subtarget->isTargetAEABI() || Subtarget->isTargetGNUAEABI())) |
388 |
++ (Subtarget->isTargetAEABI() || Subtarget->isTargetGNUAEABI() || |
389 |
++ Subtarget->isTargetMuslAEABI())) |
390 |
+ ATS.emitAttribute(ARMBuildAttrs::ABI_optimization_goals, OptimizationGoals); |
391 |
+ OptimizationGoals = -1; |
392 |
+ |
393 |
+diff --git a/lib/Target/ARM/ARMISelLowering.cpp b/lib/Target/ARM/ARMISelLowering.cpp |
394 |
+index a2daa89..3b2c0bb 100644 |
395 |
+--- a/lib/Target/ARM/ARMISelLowering.cpp |
396 |
++++ b/lib/Target/ARM/ARMISelLowering.cpp |
397 |
+@@ -254,7 +254,7 @@ ARMTargetLowering::ARMTargetLowering(const TargetMachine &TM, |
398 |
+ // RTLIB |
399 |
+ if (Subtarget->isAAPCS_ABI() && |
400 |
+ (Subtarget->isTargetAEABI() || Subtarget->isTargetGNUAEABI() || |
401 |
+- Subtarget->isTargetAndroid())) { |
402 |
++ Subtarget->isTargetMuslAEABI() || Subtarget->isTargetAndroid())) { |
403 |
+ static const struct { |
404 |
+ const RTLIB::Libcall Op; |
405 |
+ const char * const Name; |
406 |
+@@ -787,7 +787,8 @@ ARMTargetLowering::ARMTargetLowering(const TargetMachine &TM, |
407 |
+ setOperationAction(ISD::SREM, MVT::i32, Expand); |
408 |
+ setOperationAction(ISD::UREM, MVT::i32, Expand); |
409 |
+ // Register based DivRem for AEABI (RTABI 4.2) |
410 |
+- if (Subtarget->isTargetAEABI() || Subtarget->isTargetAndroid()) { |
411 |
++ if (Subtarget->isTargetAEABI() || Subtarget->isTargetAndroid() || |
412 |
++ Subtarget->isTargetMuslAEABI()) { |
413 |
+ setOperationAction(ISD::SREM, MVT::i64, Custom); |
414 |
+ setOperationAction(ISD::UREM, MVT::i64, Custom); |
415 |
+ |
416 |
+@@ -11651,7 +11652,8 @@ static TargetLowering::ArgListTy getDivRemArgList( |
417 |
+ } |
418 |
+ |
419 |
+ SDValue ARMTargetLowering::LowerDivRem(SDValue Op, SelectionDAG &DAG) const { |
420 |
+- assert((Subtarget->isTargetAEABI() || Subtarget->isTargetAndroid()) && |
421 |
++ assert((Subtarget->isTargetAEABI() || Subtarget->isTargetAndroid() || |
422 |
++ Subtarget->isTargetMuslAEABI()) && |
423 |
+ "Register-based DivRem lowering only"); |
424 |
+ unsigned Opcode = Op->getOpcode(); |
425 |
+ assert((Opcode == ISD::SDIVREM || Opcode == ISD::UDIVREM) && |
426 |
+diff --git a/lib/Target/ARM/ARMSubtarget.h b/lib/Target/ARM/ARMSubtarget.h |
427 |
+index 4d54e57..fa1c516 100644 |
428 |
+--- a/lib/Target/ARM/ARMSubtarget.h |
429 |
++++ b/lib/Target/ARM/ARMSubtarget.h |
430 |
+@@ -399,14 +399,21 @@ public: |
431 |
+ TargetTriple.getEnvironment() == Triple::GNUEABIHF) && |
432 |
+ !isTargetDarwin() && !isTargetWindows(); |
433 |
+ } |
434 |
++ bool isTargetMuslAEABI() const { |
435 |
++ return (TargetTriple.getEnvironment() == Triple::MuslEABI || |
436 |
++ TargetTriple.getEnvironment() == Triple::MuslEABIHF) && |
437 |
++ !isTargetDarwin() && !isTargetWindows(); |
438 |
++ } |
439 |
+ |
440 |
+ // ARM Targets that support EHABI exception handling standard |
441 |
+ // Darwin uses SjLj. Other targets might need more checks. |
442 |
+ bool isTargetEHABICompatible() const { |
443 |
+ return (TargetTriple.getEnvironment() == Triple::EABI || |
444 |
+ TargetTriple.getEnvironment() == Triple::GNUEABI || |
445 |
++ TargetTriple.getEnvironment() == Triple::MuslEABI || |
446 |
+ TargetTriple.getEnvironment() == Triple::EABIHF || |
447 |
+ TargetTriple.getEnvironment() == Triple::GNUEABIHF || |
448 |
++ TargetTriple.getEnvironment() == Triple::MuslEABIHF || |
449 |
+ isTargetAndroid()) && |
450 |
+ !isTargetDarwin() && !isTargetWindows(); |
451 |
+ } |
452 |
+@@ -414,6 +421,7 @@ public: |
453 |
+ bool isTargetHardFloat() const { |
454 |
+ // FIXME: this is invalid for WindowsCE |
455 |
+ return TargetTriple.getEnvironment() == Triple::GNUEABIHF || |
456 |
++ TargetTriple.getEnvironment() == Triple::MuslEABIHF || |
457 |
+ TargetTriple.getEnvironment() == Triple::EABIHF || |
458 |
+ isTargetWindows() || isAAPCS16_ABI(); |
459 |
+ } |
460 |
+diff --git a/lib/Target/ARM/ARMTargetMachine.cpp b/lib/Target/ARM/ARMTargetMachine.cpp |
461 |
+index fca1901..a96b1f9 100644 |
462 |
+--- a/lib/Target/ARM/ARMTargetMachine.cpp |
463 |
++++ b/lib/Target/ARM/ARMTargetMachine.cpp |
464 |
+@@ -99,6 +99,8 @@ computeTargetABI(const Triple &TT, StringRef CPU, |
465 |
+ case llvm::Triple::Android: |
466 |
+ case llvm::Triple::GNUEABI: |
467 |
+ case llvm::Triple::GNUEABIHF: |
468 |
++ case llvm::Triple::MuslEABI: |
469 |
++ case llvm::Triple::MuslEABIHF: |
470 |
+ case llvm::Triple::EABIHF: |
471 |
+ case llvm::Triple::EABI: |
472 |
+ TargetABI = ARMBaseTargetMachine::ARM_ABI_AAPCS; |
473 |
+@@ -192,7 +194,8 @@ ARMBaseTargetMachine::ARMBaseTargetMachine(const Target &T, const Triple &TT, |
474 |
+ // Default to triple-appropriate EABI |
475 |
+ if (Options.EABIVersion == EABI::Default || |
476 |
+ Options.EABIVersion == EABI::Unknown) { |
477 |
+- if (Subtarget.isTargetGNUAEABI()) |
478 |
++ // musl is compatible with glibc with regard to EABI version |
479 |
++ if (Subtarget.isTargetGNUAEABI() || Subtarget.isTargetMuslAEABI()) |
480 |
+ this->Options.EABIVersion = EABI::GNU; |
481 |
+ else |
482 |
+ this->Options.EABIVersion = EABI::EABI5; |
483 |
|
484 |
diff --git a/sys-devel/llvm/llvm-3.8.1-r1.ebuild b/sys-devel/llvm/llvm-3.8.1-r1.ebuild |
485 |
new file mode 100644 |
486 |
index 0000000..60e6d5e |
487 |
--- /dev/null |
488 |
+++ b/sys-devel/llvm/llvm-3.8.1-r1.ebuild |
489 |
@@ -0,0 +1,560 @@ |
490 |
+# Copyright 1999-2016 Gentoo Foundation |
491 |
+# Distributed under the terms of the GNU General Public License v2 |
492 |
+# $Id$ |
493 |
+ |
494 |
+EAPI=6 |
495 |
+ |
496 |
+: ${CMAKE_MAKEFILE_GENERATOR:=ninja} |
497 |
+PYTHON_COMPAT=( python2_7 ) |
498 |
+ |
499 |
+inherit check-reqs cmake-utils eutils flag-o-matic multilib \ |
500 |
+ multilib-minimal python-single-r1 toolchain-funcs pax-utils prefix |
501 |
+ |
502 |
+DESCRIPTION="Low Level Virtual Machine" |
503 |
+HOMEPAGE="http://llvm.org/" |
504 |
+SRC_URI="http://llvm.org/releases/${PV}/${P}.src.tar.xz |
505 |
+ clang? ( http://llvm.org/releases/${PV}/compiler-rt-${PV}.src.tar.xz |
506 |
+ http://llvm.org/releases/${PV}/cfe-${PV}.src.tar.xz |
507 |
+ http://llvm.org/releases/${PV}/clang-tools-extra-${PV}.src.tar.xz ) |
508 |
+ lldb? ( http://llvm.org/releases/${PV}/lldb-${PV}.src.tar.xz ) |
509 |
+ !doc? ( http://dev.gentoo.org/~voyageur/distfiles/${PN}-3.8.0-manpages.tar.bz2 )" |
510 |
+ |
511 |
+LICENSE="UoI-NCSA" |
512 |
+SLOT="0/3.8.0" |
513 |
+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" |
514 |
+IUSE="clang debug default-compiler-rt default-libcxx doc gold libedit +libffi |
515 |
+ lldb multitarget ncurses ocaml python +sanitize +static-analyzer test xml |
516 |
+ video_cards_radeon elibc_musl kernel_Darwin kernel_FreeBSD" |
517 |
+ |
518 |
+COMMON_DEPEND=" |
519 |
+ sys-libs/zlib:0= |
520 |
+ clang? ( |
521 |
+ python? ( ${PYTHON_DEPS} ) |
522 |
+ static-analyzer? ( |
523 |
+ dev-lang/perl:* |
524 |
+ ${PYTHON_DEPS} |
525 |
+ ) |
526 |
+ xml? ( dev-libs/libxml2:2=[${MULTILIB_USEDEP}] ) |
527 |
+ ) |
528 |
+ gold? ( >=sys-devel/binutils-2.22:*[cxx] ) |
529 |
+ libedit? ( dev-libs/libedit:0=[${MULTILIB_USEDEP}] ) |
530 |
+ libffi? ( >=virtual/libffi-3.0.13-r1:0=[${MULTILIB_USEDEP}] ) |
531 |
+ lldb? ( dev-python/six[${PYTHON_USEDEP}] ) |
532 |
+ ncurses? ( >=sys-libs/ncurses-5.9-r3:0=[${MULTILIB_USEDEP}] ) |
533 |
+ ocaml? ( |
534 |
+ >=dev-lang/ocaml-4.00.0:0= |
535 |
+ dev-ml/findlib |
536 |
+ dev-ml/ocaml-ctypes |
537 |
+ !!<=sys-devel/llvm-3.7.0-r1[ocaml] )" |
538 |
+# configparser-3.2 breaks the build (3.3 or none at all are fine) |
539 |
+DEPEND="${COMMON_DEPEND} |
540 |
+ dev-lang/perl |
541 |
+ >=sys-devel/make-3.81 |
542 |
+ >=sys-devel/flex-2.5.4 |
543 |
+ >=sys-devel/bison-1.875d |
544 |
+ || ( >=sys-devel/gcc-3.0 >=sys-devel/llvm-3.5 |
545 |
+ ( >=sys-freebsd/freebsd-lib-9.1-r10 sys-libs/libcxx ) |
546 |
+ ) |
547 |
+ || ( >=sys-devel/binutils-2.18 >=sys-devel/binutils-apple-5.1 ) |
548 |
+ kernel_Darwin? ( <sys-libs/libcxx-${PV%_rc*}.9999 ) |
549 |
+ clang? ( xml? ( virtual/pkgconfig ) ) |
550 |
+ doc? ( dev-python/sphinx ) |
551 |
+ gold? ( sys-libs/binutils-libs ) |
552 |
+ libffi? ( virtual/pkgconfig ) |
553 |
+ lldb? ( dev-lang/swig ) |
554 |
+ !!<dev-python/configparser-3.3.0.2 |
555 |
+ ocaml? ( test? ( dev-ml/ounit ) ) |
556 |
+ ${PYTHON_DEPS}" |
557 |
+RDEPEND="${COMMON_DEPEND} |
558 |
+ clang? ( !<=sys-devel/clang-${PV}-r99 ) |
559 |
+ default-libcxx? ( sys-libs/libcxx ) |
560 |
+ abi_x86_32? ( !<=app-emulation/emul-linux-x86-baselibs-20130224-r2 |
561 |
+ !app-emulation/emul-linux-x86-baselibs[-abi_x86_32(-)] )" |
562 |
+PDEPEND="clang? ( =sys-devel/clang-${PV}-r100 )" |
563 |
+ |
564 |
+# pypy gives me around 1700 unresolved tests due to open file limit |
565 |
+# being exceeded. probably GC does not close them fast enough. |
566 |
+REQUIRED_USE="${PYTHON_REQUIRED_USE} |
567 |
+ lldb? ( clang xml )" |
568 |
+ |
569 |
+S=${WORKDIR}/${P/_}.src |
570 |
+ |
571 |
+pkg_pretend() { |
572 |
+ # in megs |
573 |
+ # !clang !debug !multitarget -O2 400 |
574 |
+ # !clang !debug multitarget -O2 550 |
575 |
+ # clang !debug !multitarget -O2 950 |
576 |
+ # clang !debug multitarget -O2 1200 |
577 |
+ # !clang debug multitarget -O2 5G |
578 |
+ # clang !debug multitarget -O0 -g 12G |
579 |
+ # clang debug multitarget -O2 16G |
580 |
+ # clang debug multitarget -O0 -g 14G |
581 |
+ |
582 |
+ local build_size=550 |
583 |
+ use clang && build_size=1200 |
584 |
+ |
585 |
+ if use debug; then |
586 |
+ ewarn "USE=debug is known to increase the size of package considerably" |
587 |
+ ewarn "and cause the tests to fail." |
588 |
+ ewarn |
589 |
+ |
590 |
+ (( build_size *= 14 )) |
591 |
+ elif is-flagq '-g?(gdb)?([1-9])'; then |
592 |
+ ewarn "The C++ compiler -g option is known to increase the size of the package" |
593 |
+ ewarn "considerably. If you run out of space, please consider removing it." |
594 |
+ ewarn |
595 |
+ |
596 |
+ (( build_size *= 10 )) |
597 |
+ fi |
598 |
+ |
599 |
+ # Multiply by number of ABIs :). |
600 |
+ local abis=( $(multilib_get_enabled_abis) ) |
601 |
+ (( build_size *= ${#abis[@]} )) |
602 |
+ |
603 |
+ local CHECKREQS_DISK_BUILD=${build_size}M |
604 |
+ check-reqs_pkg_pretend |
605 |
+} |
606 |
+ |
607 |
+pkg_setup() { |
608 |
+ pkg_pretend |
609 |
+} |
610 |
+ |
611 |
+src_unpack() { |
612 |
+ default |
613 |
+ |
614 |
+ if use clang; then |
615 |
+ mv "${WORKDIR}"/cfe-${PV/_}.src "${S}"/tools/clang \ |
616 |
+ || die "clang source directory move failed" |
617 |
+ mv "${WORKDIR}"/compiler-rt-${PV/_}.src "${S}"/projects/compiler-rt \ |
618 |
+ || die "compiler-rt source directory move failed" |
619 |
+ mv "${WORKDIR}"/clang-tools-extra-${PV/_}.src "${S}"/tools/clang/tools/extra \ |
620 |
+ || die "clang-tools-extra source directory move failed" |
621 |
+ fi |
622 |
+ |
623 |
+ if use lldb; then |
624 |
+ mv "${WORKDIR}"/lldb-${PV/_}.src "${S}"/tools/lldb \ |
625 |
+ || die "lldb source directory move failed" |
626 |
+ fi |
627 |
+} |
628 |
+ |
629 |
+src_prepare() { |
630 |
+ python_setup |
631 |
+ |
632 |
+ # Make ocaml warnings non-fatal, bug #537308 |
633 |
+ sed -e "/RUN/s/-warn-error A//" -i test/Bindings/OCaml/*ml || die |
634 |
+ # Fix libdir for ocaml bindings install, bug #559134 |
635 |
+ eapply "${FILESDIR}"/cmake/${PN}-3.7.0-ocaml-multilib.patch |
636 |
+ # Do not build/install ocaml docs with USE=-doc, bug #562008 |
637 |
+ eapply "${FILESDIR}"/cmake/${PN}-3.7.0-ocaml-build_doc.patch |
638 |
+ |
639 |
+ # Make it possible to override Sphinx HTML install dirs |
640 |
+ # https://llvm.org/bugs/show_bug.cgi?id=23780 |
641 |
+ eapply "${FILESDIR}"/cmake/0002-cmake-Support-overriding-Sphinx-HTML-doc-install-dir.patch |
642 |
+ |
643 |
+ # Prevent race conditions with parallel Sphinx runs |
644 |
+ # https://llvm.org/bugs/show_bug.cgi?id=23781 |
645 |
+ eapply "${FILESDIR}"/cmake/0003-cmake-Add-an-ordering-dep-between-HTML-man-Sphinx-ta.patch |
646 |
+ |
647 |
+ # Prevent installing libgtest |
648 |
+ # https://llvm.org/bugs/show_bug.cgi?id=18341 |
649 |
+ eapply "${FILESDIR}"/cmake/0004-cmake-Do-not-install-libgtest.patch |
650 |
+ |
651 |
+ # Allow custom cmake build types (like 'Gentoo') |
652 |
+ eapply "${FILESDIR}"/cmake/${PN}-3.8-allow_custom_cmake_build_types.patch |
653 |
+ |
654 |
+ # Fix llvm-config for shared linking and sane flags |
655 |
+ # https://bugs.gentoo.org/show_bug.cgi?id=565358 |
656 |
+ eapply "${FILESDIR}"/llvm-3.8-llvm-config.patch |
657 |
+ |
658 |
+ # Restore SOVERSIONs for shared libraries |
659 |
+ # https://bugs.gentoo.org/show_bug.cgi?id=578392 |
660 |
+ eapply "${FILESDIR}"/llvm-3.8-soversion.patch |
661 |
+ |
662 |
+ # support building llvm against musl-libc |
663 |
+ use elibc_musl && eapply "${FILESDIR}"/llvm-3.8-musl-fixes.patch |
664 |
+ |
665 |
+ # support "musl" as a valid environment type in llvm |
666 |
+ eapply "${FILESDIR}"/llvm-3.8-musl-support.patch |
667 |
+ |
668 |
+ # disable use of SDK on OSX, bug #568758 |
669 |
+ sed -i -e 's/xcrun/false/' utils/lit/lit/util.py || die |
670 |
+ |
671 |
+ # Workaround, can be compiled with gcc on Gentoo/FreeBSD, bug #578064 |
672 |
+ use kernel_FreeBSD && tc-is-gcc && append-cppflags "-D_GLIBCXX_USE_C99" |
673 |
+ |
674 |
+ if use clang; then |
675 |
+ # Automatically select active system GCC's libraries, bugs #406163 and #417913 |
676 |
+ eapply "${FILESDIR}"/clang-3.5-gentoo-runtime-gcc-detection-v3.patch |
677 |
+ |
678 |
+ # Support gcc4.9 search paths |
679 |
+ # https://github.com/llvm-mirror/clang/commit/af4db76e059c1a3 |
680 |
+ eapply "${FILESDIR}"/clang-3.8-gcc4.9-search-path.patch |
681 |
+ |
682 |
+ eapply "${FILESDIR}"/clang-3.4-darwin_prefix-include-paths.patch |
683 |
+ eprefixify tools/clang/lib/Frontend/InitHeaderSearch.cpp |
684 |
+ |
685 |
+ pushd "${S}"/tools/clang >/dev/null || die |
686 |
+ # be able to specify default values for -stdlib and -rtlib at build time |
687 |
+ eapply "${FILESDIR}"/clang-3.8-default-libs.patch |
688 |
+ |
689 |
+ # enable clang to recognize musl-libc |
690 |
+ eapply "${FILESDIR}"/clang-3.8-musl-support.patch |
691 |
+ popd >/dev/null || die |
692 |
+ |
693 |
+ sed -i -e "s^@EPREFIX@^${EPREFIX}^" \ |
694 |
+ tools/clang/tools/scan-build/bin/scan-build || die |
695 |
+ |
696 |
+ # Install clang runtime into /usr/lib/clang |
697 |
+ # https://llvm.org/bugs/show_bug.cgi?id=23792 |
698 |
+ eapply "${FILESDIR}"/cmake/clang-0001-Install-clang-runtime-into-usr-lib-without-suffix-3.8.patch |
699 |
+ eapply "${FILESDIR}"/cmake/compiler-rt-0001-cmake-Install-compiler-rt-into-usr-lib-without-suffi.patch |
700 |
+ |
701 |
+ # Do not force -march flags on arm platforms |
702 |
+ # https://bugs.gentoo.org/show_bug.cgi?id=562706 |
703 |
+ eapply "${FILESDIR}"/cmake/${PN}-3.8.0-compiler_rt_arm_march_flags.patch |
704 |
+ |
705 |
+ # Make it possible to override CLANG_LIBDIR_SUFFIX |
706 |
+ # (that is used only to find LLVMgold.so) |
707 |
+ # https://llvm.org/bugs/show_bug.cgi?id=23793 |
708 |
+ eapply "${FILESDIR}"/cmake/clang-0002-cmake-Make-CLANG_LIBDIR_SUFFIX-overridable.patch |
709 |
+ |
710 |
+ # Fix git-clang-format shebang, bug #562688 |
711 |
+ python_fix_shebang tools/clang/tools/clang-format/git-clang-format |
712 |
+ |
713 |
+ # Fix 'stdarg.h' file not found on Gentoo/FreeBSD, bug #578064 |
714 |
+ # https://llvm.org/bugs/show_bug.cgi?id=26651 |
715 |
+ eapply "${FILESDIR}"/clang-3.8-compiler-rt-fbsd.patch |
716 |
+ |
717 |
+ pushd projects/compiler-rt >/dev/null || die |
718 |
+ |
719 |
+ # Fix WX sections, bug #421527 |
720 |
+ find lib/builtins -type f -name '*.S' -exec sed \ |
721 |
+ -e '$a\\n#if defined(__linux__) && defined(__ELF__)\n.section .note.GNU-stack,"",%progbits\n#endif' \ |
722 |
+ -i {} + || die |
723 |
+ |
724 |
+ popd >/dev/null || die |
725 |
+ fi |
726 |
+ |
727 |
+ if use lldb; then |
728 |
+ # Do not install dummy readline.so module from |
729 |
+ # https://llvm.org/bugs/show_bug.cgi?id=18841 |
730 |
+ sed -e 's/add_subdirectory(readline)/#&/' \ |
731 |
+ -i tools/lldb/scripts/Python/modules/CMakeLists.txt || die |
732 |
+ # Do not install bundled six module |
733 |
+ eapply "${FILESDIR}"/${PN}-3.8-lldb_six.patch |
734 |
+ fi |
735 |
+ |
736 |
+ # User patches |
737 |
+ eapply_user |
738 |
+ |
739 |
+ # Native libdir is used to hold LLVMgold.so |
740 |
+ NATIVE_LIBDIR=$(get_libdir) |
741 |
+} |
742 |
+ |
743 |
+multilib_src_configure() { |
744 |
+ local targets |
745 |
+ if use multitarget; then |
746 |
+ targets=all |
747 |
+ else |
748 |
+ targets='host;BPF;CppBackend' |
749 |
+ use video_cards_radeon && targets+=';AMDGPU' |
750 |
+ fi |
751 |
+ |
752 |
+ local ffi_cflags ffi_ldflags |
753 |
+ if use libffi; then |
754 |
+ ffi_cflags=$(pkg-config --cflags-only-I libffi) |
755 |
+ ffi_ldflags=$(pkg-config --libs-only-L libffi) |
756 |
+ fi |
757 |
+ |
758 |
+ local libdir=$(get_libdir) |
759 |
+ local mycmakeargs=( |
760 |
+ -DLLVM_LIBDIR_SUFFIX=${libdir#lib} |
761 |
+ |
762 |
+ -DBUILD_SHARED_LIBS=ON |
763 |
+ -DLLVM_ENABLE_TIMESTAMPS=OFF |
764 |
+ -DLLVM_TARGETS_TO_BUILD="${targets}" |
765 |
+ -DLLVM_BUILD_TESTS=$(usex test) |
766 |
+ |
767 |
+ -DLLVM_ENABLE_FFI=$(usex libffi) |
768 |
+ -DLLVM_ENABLE_TERMINFO=$(usex ncurses) |
769 |
+ -DLLVM_ENABLE_ASSERTIONS=$(usex debug) |
770 |
+ -DLLVM_ENABLE_EH=ON |
771 |
+ -DLLVM_ENABLE_RTTI=ON |
772 |
+ |
773 |
+ -DWITH_POLLY=OFF # TODO |
774 |
+ |
775 |
+ -DLLVM_HOST_TRIPLE="${CHOST}" |
776 |
+ |
777 |
+ -DFFI_INCLUDE_DIR="${ffi_cflags#-I}" |
778 |
+ -DFFI_LIBRARY_DIR="${ffi_ldflags#-L}" |
779 |
+ |
780 |
+ -DHAVE_HISTEDIT_H=$(usex libedit) |
781 |
+ ) |
782 |
+ |
783 |
+ if use clang; then |
784 |
+ mycmakeargs+=( |
785 |
+ -DCMAKE_DISABLE_FIND_PACKAGE_LibXml2=$(usex !xml) |
786 |
+ # libgomp support fails to find headers without explicit -I |
787 |
+ # furthermore, it provides only syntax checking |
788 |
+ -DCLANG_DEFAULT_OPENMP_RUNTIME=libomp |
789 |
+ |
790 |
+ # override default stdlib and rtlib |
791 |
+ -DCLANG_DEFAULT_CXX_STDLIB=$(usex default-libcxx libc++ "") |
792 |
+ -DCLANG_DEFAULT_RTLIB=$(usex default-compiler-rt compiler-rt "") |
793 |
+ |
794 |
+ # compiler-rt's test cases depend on sanitizer |
795 |
+ -DCOMPILER_RT_BUILD_SANITIZERS=$(usex sanitize) |
796 |
+ -DCOMPILER_RT_INCLUDE_TESTS=$(usex sanitize) |
797 |
+ ) |
798 |
+ fi |
799 |
+ |
800 |
+ if use lldb; then |
801 |
+ mycmakeargs+=( |
802 |
+ -DLLDB_DISABLE_LIBEDIT=$(usex !libedit) |
803 |
+ -DLLDB_DISABLE_CURSES=$(usex !ncurses) |
804 |
+ -DLLDB_ENABLE_TERMINFO=$(usex ncurses) |
805 |
+ ) |
806 |
+ fi |
807 |
+ |
808 |
+ if ! multilib_is_native_abi || ! use ocaml; then |
809 |
+ mycmakeargs+=( |
810 |
+ -DOCAMLFIND=NO |
811 |
+ ) |
812 |
+ fi |
813 |
+# Note: go bindings have no CMake rules at the moment |
814 |
+# but let's kill the check in case they are introduced |
815 |
+# if ! multilib_is_native_abi || ! use go; then |
816 |
+ mycmakeargs+=( |
817 |
+ -DGO_EXECUTABLE=GO_EXECUTABLE-NOTFOUND |
818 |
+ ) |
819 |
+# fi |
820 |
+ |
821 |
+ if multilib_is_native_abi; then |
822 |
+ mycmakeargs+=( |
823 |
+ -DLLVM_BUILD_DOCS=$(usex doc) |
824 |
+ -DLLVM_ENABLE_SPHINX=$(usex doc) |
825 |
+ -DLLVM_ENABLE_DOXYGEN=OFF |
826 |
+ -DLLVM_INSTALL_HTML="${EPREFIX}/usr/share/doc/${PF}/html" |
827 |
+ -DSPHINX_WARNINGS_AS_ERRORS=OFF |
828 |
+ -DLLVM_INSTALL_UTILS=ON |
829 |
+ ) |
830 |
+ |
831 |
+ if use clang; then |
832 |
+ mycmakeargs+=( |
833 |
+ -DCLANG_INSTALL_HTML="${EPREFIX}/usr/share/doc/${PF}/clang" |
834 |
+ ) |
835 |
+ fi |
836 |
+ |
837 |
+ if use gold; then |
838 |
+ mycmakeargs+=( |
839 |
+ -DLLVM_BINUTILS_INCDIR="${EPREFIX}"/usr/include |
840 |
+ ) |
841 |
+ fi |
842 |
+ |
843 |
+ if use lldb; then |
844 |
+ mycmakeargs+=( |
845 |
+ -DLLDB_DISABLE_PYTHON=$(usex !python) |
846 |
+ ) |
847 |
+ fi |
848 |
+ |
849 |
+ else |
850 |
+ if use clang; then |
851 |
+ mycmakeargs+=( |
852 |
+ # disable compiler-rt on non-native ABI because: |
853 |
+ # 1. it fails to configure because of -m32 |
854 |
+ # 2. it is shared between ABIs so no point building |
855 |
+ # it multiple times |
856 |
+ -DLLVM_EXTERNAL_COMPILER_RT_BUILD=OFF |
857 |
+ -DLLVM_EXTERNAL_CLANG_TOOLS_EXTRA_BUILD=OFF |
858 |
+ ) |
859 |
+ fi |
860 |
+ if use lldb; then |
861 |
+ mycmakeargs+=( |
862 |
+ # only run swig on native abi |
863 |
+ -DLLDB_DISABLE_PYTHON=ON |
864 |
+ ) |
865 |
+ fi |
866 |
+ fi |
867 |
+ |
868 |
+ if use clang; then |
869 |
+ mycmakeargs+=( |
870 |
+ -DCLANG_ENABLE_ARCMT=$(usex static-analyzer) |
871 |
+ -DCLANG_ENABLE_STATIC_ANALYZER=$(usex static-analyzer) |
872 |
+ -DCLANG_LIBDIR_SUFFIX="${NATIVE_LIBDIR#lib}" |
873 |
+ ) |
874 |
+ |
875 |
+ # -- not needed when compiler-rt is built with host compiler -- |
876 |
+ # cmake passes host C*FLAGS to compiler-rt build |
877 |
+ # which is performed using clang, so we need to filter out |
878 |
+ # some flags clang does not support |
879 |
+ # (if you know some more flags that don't work, let us know) |
880 |
+ #filter-flags -msahf -frecord-gcc-switches |
881 |
+ fi |
882 |
+ |
883 |
+ if tc-is-cross-compiler; then |
884 |
+ [[ -x "/usr/bin/llvm-tblgen" ]] \ |
885 |
+ || die "/usr/bin/llvm-tblgen not found or usable" |
886 |
+ mycmakeargs+=( |
887 |
+ -DCMAKE_CROSSCOMPILING=ON |
888 |
+ -DLLVM_TABLEGEN=/usr/bin/llvm-tblgen |
889 |
+ ) |
890 |
+ |
891 |
+ if use clang; then |
892 |
+ [[ -x "/usr/bin/clang-tblgen" ]] \ |
893 |
+ || die "/usr/bin/clang-tblgen not found or usable" |
894 |
+ mycmakeargs+=( |
895 |
+ -DCLANG_TABLEGEN=/usr/bin/clang-tblgen |
896 |
+ ) |
897 |
+ fi |
898 |
+ fi |
899 |
+ |
900 |
+ cmake-utils_src_configure |
901 |
+} |
902 |
+ |
903 |
+multilib_src_compile() { |
904 |
+ cmake-utils_src_compile |
905 |
+ # TODO: not sure why this target is not correctly called |
906 |
+ multilib_is_native_abi && use doc && use ocaml && cmake-utils_src_make docs/ocaml_doc |
907 |
+ |
908 |
+ pax-mark m "${BUILD_DIR}"/bin/llvm-rtdyld |
909 |
+ pax-mark m "${BUILD_DIR}"/bin/lli |
910 |
+ pax-mark m "${BUILD_DIR}"/bin/lli-child-target |
911 |
+ |
912 |
+ if use test; then |
913 |
+ pax-mark m "${BUILD_DIR}"/unittests/ExecutionEngine/Orc/OrcJITTests |
914 |
+ pax-mark m "${BUILD_DIR}"/unittests/ExecutionEngine/MCJIT/MCJITTests |
915 |
+ pax-mark m "${BUILD_DIR}"/unittests/Support/SupportTests |
916 |
+ fi |
917 |
+} |
918 |
+ |
919 |
+multilib_src_test() { |
920 |
+ # respect TMPDIR! |
921 |
+ local -x LIT_PRESERVES_TMP=1 |
922 |
+ local test_targets=( check ) |
923 |
+ # clang tests won't work on non-native ABI because we skip compiler-rt |
924 |
+ multilib_is_native_abi && use clang && test_targets+=( check-clang ) |
925 |
+ cmake-utils_src_make "${test_targets[@]}" |
926 |
+} |
927 |
+ |
928 |
+src_install() { |
929 |
+ local MULTILIB_CHOST_TOOLS=( |
930 |
+ /usr/bin/llvm-config |
931 |
+ ) |
932 |
+ |
933 |
+ local MULTILIB_WRAPPED_HEADERS=( |
934 |
+ /usr/include/llvm/Config/config.h |
935 |
+ /usr/include/llvm/Config/llvm-config.h |
936 |
+ ) |
937 |
+ |
938 |
+ if use clang; then |
939 |
+ # note: magic applied in multilib_src_install()! |
940 |
+ CLANG_VERSION=${PV%.*} |
941 |
+ |
942 |
+ MULTILIB_CHOST_TOOLS+=( |
943 |
+ /usr/bin/clang |
944 |
+ /usr/bin/clang++ |
945 |
+ /usr/bin/clang-cl |
946 |
+ /usr/bin/clang-${CLANG_VERSION} |
947 |
+ /usr/bin/clang++-${CLANG_VERSION} |
948 |
+ /usr/bin/clang-cl-${CLANG_VERSION} |
949 |
+ ) |
950 |
+ |
951 |
+ MULTILIB_WRAPPED_HEADERS+=( |
952 |
+ /usr/include/clang/Config/config.h |
953 |
+ ) |
954 |
+ fi |
955 |
+ |
956 |
+ multilib-minimal_src_install |
957 |
+ |
958 |
+ # Remove unnecessary headers on FreeBSD, bug #417171 |
959 |
+ if use kernel_FreeBSD && use clang; then |
960 |
+ rm "${ED}"usr/lib/clang/${PV}/include/{std,float,iso,limits,tgmath,varargs}*.h || die |
961 |
+ fi |
962 |
+} |
963 |
+ |
964 |
+multilib_src_install() { |
965 |
+ cmake-utils_src_install |
966 |
+ |
967 |
+ if multilib_is_native_abi; then |
968 |
+ # Install man pages. |
969 |
+ use doc || doman "${WORKDIR}"/${PN}-3.8.0-manpages/*.1 |
970 |
+ |
971 |
+ # Symlink the gold plugin. |
972 |
+ if use gold; then |
973 |
+ dodir "/usr/${CHOST}/binutils-bin/lib/bfd-plugins" |
974 |
+ dosym "../../../../$(get_libdir)/LLVMgold.so" \ |
975 |
+ "/usr/${CHOST}/binutils-bin/lib/bfd-plugins/LLVMgold.so" |
976 |
+ fi |
977 |
+ fi |
978 |
+ |
979 |
+ # apply CHOST and CLANG_VERSION to clang executables |
980 |
+ # they're statically linked so we don't have to worry about the lib |
981 |
+ if use clang; then |
982 |
+ local clang_tools=( clang clang++ clang-cl ) |
983 |
+ local i |
984 |
+ |
985 |
+ # cmake gives us: |
986 |
+ # - clang-X.Y |
987 |
+ # - clang -> clang-X.Y |
988 |
+ # - clang++, clang-cl -> clang |
989 |
+ # we want to have: |
990 |
+ # - clang-X.Y |
991 |
+ # - clang++-X.Y, clang-cl-X.Y -> clang-X.Y |
992 |
+ # - clang, clang++, clang-cl -> clang*-X.Y |
993 |
+ # so we need to fix the two tools |
994 |
+ for i in "${clang_tools[@]:1}"; do |
995 |
+ rm "${ED%/}/usr/bin/${i}" || die |
996 |
+ dosym "clang-${CLANG_VERSION}" "/usr/bin/${i}-${CLANG_VERSION}" |
997 |
+ dosym "${i}-${CLANG_VERSION}" "/usr/bin/${i}" |
998 |
+ done |
999 |
+ |
1000 |
+ # now prepend ${CHOST} and let the multilib-build.eclass symlink it |
1001 |
+ if ! multilib_is_native_abi; then |
1002 |
+ # non-native? let's replace it with a simple wrapper |
1003 |
+ for i in "${clang_tools[@]}"; do |
1004 |
+ rm "${ED%/}/usr/bin/${i}-${CLANG_VERSION}" || die |
1005 |
+ cat > "${T}"/wrapper.tmp <<-_EOF_ |
1006 |
+ #!${EPREFIX}/bin/sh |
1007 |
+ exec "${i}-${CLANG_VERSION}" $(get_abi_CFLAGS) "\${@}" |
1008 |
+ _EOF_ |
1009 |
+ newbin "${T}"/wrapper.tmp "${i}-${CLANG_VERSION}" |
1010 |
+ done |
1011 |
+ fi |
1012 |
+ fi |
1013 |
+} |
1014 |
+ |
1015 |
+multilib_src_install_all() { |
1016 |
+ insinto /usr/share/vim/vimfiles |
1017 |
+ doins -r utils/vim/*/. |
1018 |
+ # some users may find it useful |
1019 |
+ dodoc utils/vim/vimrc |
1020 |
+ |
1021 |
+ if use clang; then |
1022 |
+ pushd tools/clang >/dev/null || die |
1023 |
+ |
1024 |
+ if use python ; then |
1025 |
+ pushd bindings/python/clang >/dev/null || die |
1026 |
+ |
1027 |
+ python_moduleinto clang |
1028 |
+ python_domodule *.py |
1029 |
+ |
1030 |
+ popd >/dev/null || die |
1031 |
+ fi |
1032 |
+ |
1033 |
+ # AddressSanitizer symbolizer (currently separate) |
1034 |
+ dobin "${S}"/projects/compiler-rt/lib/asan/scripts/asan_symbolize.py |
1035 |
+ |
1036 |
+ popd >/dev/null || die |
1037 |
+ |
1038 |
+ python_fix_shebang "${ED}" |
1039 |
+ if use static-analyzer; then |
1040 |
+ python_optimize "${ED}"usr/share/scan-view |
1041 |
+ fi |
1042 |
+ fi |
1043 |
+} |
1044 |
+ |
1045 |
+pkg_postinst() { |
1046 |
+ if use clang && ! has_version 'sys-libs/libomp'; then |
1047 |
+ elog "To enable OpenMP support in clang, install sys-libs/libomp." |
1048 |
+ fi |
1049 |
+} |
1050 |
|
1051 |
diff --git a/sys-devel/llvm/metadata.xml b/sys-devel/llvm/metadata.xml |
1052 |
index 7371a1f..09156e2 100644 |
1053 |
--- a/sys-devel/llvm/metadata.xml |
1054 |
+++ b/sys-devel/llvm/metadata.xml |
1055 |
@@ -20,11 +20,14 @@ |
1056 |
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> |
1057 |
<use> |
1058 |
<flag name="clang">Build the clang C/C++ compiler</flag> |
1059 |
+ <flag name="default-compiler-rt">Use compiler-rt instead of libgcc as the default rtlib for clang</flag> |
1060 |
+ <flag name="default-libcxx">Use libc++ instead of libstdc++ as the default stdlib for clang</flag> |
1061 |
<flag name="doc">Build and install the HTML documentation and regenerate the man pages</flag> |
1062 |
<flag name="gold">Build the gold linker plugin</flag> |
1063 |
<flag name="lldb">Build the lldb debugger</flag> |
1064 |
<flag name="multitarget">Build all host targets (default: host only)</flag> |
1065 |
<flag name="ncurses">Support querying terminal properties using ncurses' terminfo</flag> |
1066 |
+ <flag name="sanitize">Build compiler-rt's sanitizers</flag> |
1067 |
<flag name="static-analyzer">Install the Clang static analyzer (requires USE=clang)</flag> |
1068 |
</use> |
1069 |
</pkgmetadata> |