Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-devel/llvm/files/3.8.1/clang/, sys-devel/llvm/files/3.8.1/, ...
Date: Sat, 03 Jun 2017 10:28:06
Message-Id: 1496485670.213b03205a77eae33b0ce31a8b176775125f8ab4.mgorny@gentoo
1 commit: 213b03205a77eae33b0ce31a8b176775125f8ab4
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Sat Jun 3 09:30:59 2017 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Sat Jun 3 10:27:50 2017 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=213b0320
7
8 sys-devel/llvm: Move 3.8.1 patchset to tarball
9
10 sys-devel/llvm/Manifest | 1 +
11 ...n-ordering-dep-between-HTML-man-Sphinx-ta.patch | 33 -
12 .../3.8.1/0005-cmake-Do-not-install-libgtest.patch | 30 -
13 ...ke-Restore-SOVERSIONs-on-shared-libraries.patch | 28 -
14 .../3.8.1/clang/abi-tag-support-mangler.patch | 1230 --------------------
15 .../files/3.8.1/clang/abi-tag-support-sema.patch | 419 -------
16 .../llvm/files/3.8.1/clang/default-libs.patch | 106 --
17 .../files/3.8.1/clang/gcc4.9-search-path.patch | 70 --
18 .../clang/gentoo-runtime-gcc-detection-v3.patch | 42 -
19 .../llvm/files/3.8.1/clang/musl-support.patch | 108 --
20 ...ll-compiler-rt-into-usr-lib-without-suffi.patch | 25 -
21 .../files/3.8.1/compiler-rt/arm_march_flags.patch | 17 -
22 .../3.8.1/compiler-rt/darwin-default-sysroot.patch | 14 -
23 sys-devel/llvm/files/3.8.1/compiler-rt/fbsd.patch | 20 -
24 sys-devel/llvm/files/3.8.1/llvm-config.patch | 114 --
25 sys-devel/llvm/files/3.8.1/musl-env-support.patch | 164 ---
26 sys-devel/llvm/llvm-3.8.1-r2.ebuild | 51 +-
27 17 files changed, 27 insertions(+), 2445 deletions(-)
28
29 diff --git a/sys-devel/llvm/Manifest b/sys-devel/llvm/Manifest
30 index e91c605e22e..88cc2b1dd23 100644
31 --- a/sys-devel/llvm/Manifest
32 +++ b/sys-devel/llvm/Manifest
33 @@ -29,6 +29,7 @@ DIST llvm-3.7.0-manpages.tar.bz2 38095 SHA256 8597fa532464c6336aefbbef0b1ce452aa
34 DIST llvm-3.7.1-patchset.tar.gz 17234 SHA256 3add3f23c0eae09f52ac055362234a116da4fc1e5a7772cd9a90519549e9f096 SHA512 030dc7f72d11fcd53307f707d5dde321054feb0f0977601c3e188a37f2be6c14bfd05482d1c1e5f435aaf32ca7c7e3701cf5f1375fbd0cf83cf8afbad7f4f6be WHIRLPOOL fa5d3464ac6315dabac895b753918b0dbe301ef6d8e45a75934ba6b0ba947e30763d0522bd95b79ae4a714b1234bb08e654c0a9987fd74e692eeb2afe16694e8
35 DIST llvm-3.7.1.src.tar.xz 14592544 SHA256 be7794ed0cec42d6c682ca8e3517535b54555a3defabec83554dbc74db545ad5 SHA512 ac521debc02f6deba96ef975d6a546b0c5c77299c1dbf5e1b87a7974ff5e7fd715bd7e384b92d9adf572ce47130bdbf6d3c648eb0d7f72f16f976292e4909e90 WHIRLPOOL 788ce0907b906ebee595c766713bec5067563c8aba7460211f5830e116df7c830de84704834c0df2f2f2c90354d75521e4a4aff57e769a2d8ab590778c1e4a70
36 DIST llvm-3.8.0-manpages.tar.bz2 37889 SHA256 4dda7f69f9412e0fb50d32631df34d6ea7f93c945c9a59cb050a99f1d2d0508b SHA512 a93ed7a25b75c237a0967ba7a501c71af3e7e9292ebabf69733bc637e9a4534dcaee539c6b1f6b2df7a87103c2371b1cf130fac05b88047100988c814e89ab0f WHIRLPOOL 9790a576fd4db798c2339bb4ea1dc973f1057177364770a104be7916998a1ad824e6b4eee296066ddd32eb5e6c57ffd5716457cecbd8ca9fe1b317d0d5ed2676
37 +DIST llvm-3.8.1-patchset.tar.xz 24260 SHA256 4a1677b5aff3a4ca8ccdbcc45e286e44d23867cbaa48a39cffc0fc2a8765ed6c SHA512 1e4ec68c56cc72a89afb573ad0c3cada10be7ec02e0af033a6c5cf8ce46ed7bf40389543c2f1b11e7080dba49962c57b4ea9f9bc971c4647eb3fd945c0cf0529 WHIRLPOOL 38c16b23f995818a6ca292e89d28f85ae6d19327bc0efe72270611077a7b76bca99b2e1f11b8653550bddee4123f2611621b86c4b81cdb8f96edc1cd4c5cfc4f
38 DIST llvm-3.8.1.src.tar.xz 16551472 SHA256 6e82ce4adb54ff3afc18053d6981b6aed1406751b8742582ed50f04b5ab475f9 SHA512 99bbb2cc5f337fd5edf1621f8028c8cb74011aa4af2531018dc05409b27f7b8d0c2f76a00115f677f7c013029d5d9f55d085a5b40433409aac4e9161d53bd366 WHIRLPOOL a99cef164a0e05e5237b840bee776d48fe0bde460cb4536f03a5e4eb0cc630deeb96f76bdd42f912a4b2dab08133bd9137ea16be1b9582d375f0f5841dd40234
39 DIST llvm-3.9.0_rc3-manpages.tar.bz2 80007 SHA256 991f5238d23c0aee2fd303d1adecd6045c42ed066f42f0d58f62c3a25c197140 SHA512 f96c340021de3f096ec3ad7d51a6af2c7a84974122d1df15729a39d4f9d65452f063a85ab38adb064288dc14220d9cc679b31ee19b48424d3d7cde621ff37597 WHIRLPOOL d3f24a2faaa5aa909519373532262c342acf517048ac543f303b6ddb539f5ece876a338c8efc445f4ada6f723a4e65e35bd5f2f9b4f52ef96ef832000259ab20
40 DIST llvm-3.9.1.src.tar.xz 18130436 SHA256 1fd90354b9cf19232e8f168faf2220e79be555df3aa743242700879e8fd329ee SHA512 50cbe8ee911080f586e77861c442348701bd02e2de0c090c54c34f82ac275ecfcd712af0f41e387c33b4a6057778a4258a27554292fe68ab4af3fd9dd6d90683 WHIRLPOOL 1cd1a25befcb178bec4a4aace4367167f3838d32edbe9db9de8c6e558c01c1fcf123f6d6f80b7ec9ff32b3d6dcf2de2f4eb4201d417c3d17a5c8a69934832903
41
42 diff --git a/sys-devel/llvm/files/3.8.1/0004-cmake-Add-an-ordering-dep-between-HTML-man-Sphinx-ta.patch b/sys-devel/llvm/files/3.8.1/0004-cmake-Add-an-ordering-dep-between-HTML-man-Sphinx-ta.patch
43 deleted file mode 100644
44 index 94a81574d6e..00000000000
45 --- a/sys-devel/llvm/files/3.8.1/0004-cmake-Add-an-ordering-dep-between-HTML-man-Sphinx-ta.patch
46 +++ /dev/null
47 @@ -1,33 +0,0 @@
48 -From 2f798e87c10a93235a00e95c38e736f9ff7e991b Mon Sep 17 00:00:00 2001
49 -From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@g.o>
50 -Date: Mon, 8 Jun 2015 14:29:03 +0200
51 -Subject: [PATCH 04/10] cmake: Add an ordering dep between HTML & man Sphinx
52 - targets
53 -
54 -Add a dependency between HTML & manpage Sphinx targets to prevent two
55 -instances of Sphinx from running in parallel, and therefore solves race
56 -conditions reusing the same doctree directory.
57 -
58 -Bug: https://llvm.org/bugs/show_bug.cgi?id=23781
59 -Patch: https://reviews.llvm.org/D23755
60 ----
61 - docs/CMakeLists.txt | 3 +++
62 - 1 file changed, 3 insertions(+)
63 -
64 -diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt
65 -index f2cd7e9..179a65b 100644
66 ---- a/docs/CMakeLists.txt
67 -+++ b/docs/CMakeLists.txt
68 -@@ -109,6 +109,9 @@ if (LLVM_ENABLE_SPHINX)
69 -
70 - if (${SPHINX_OUTPUT_MAN})
71 - add_sphinx_target(man llvm)
72 -+ if (${SPHINX_OUTPUT_HTML})
73 -+ add_dependencies(docs-llvm-html docs-llvm-man)
74 -+ endif()
75 - endif()
76 -
77 - endif()
78 ---
79 -2.9.3
80 -
81
82 diff --git a/sys-devel/llvm/files/3.8.1/0005-cmake-Do-not-install-libgtest.patch b/sys-devel/llvm/files/3.8.1/0005-cmake-Do-not-install-libgtest.patch
83 deleted file mode 100644
84 index a24977c0314..00000000000
85 --- a/sys-devel/llvm/files/3.8.1/0005-cmake-Do-not-install-libgtest.patch
86 +++ /dev/null
87 @@ -1,30 +0,0 @@
88 -From 1303993b5b9a4195ebe4930a8cd345c875e7f25c Mon Sep 17 00:00:00 2001
89 -From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@g.o>
90 -Date: Tue, 9 Jun 2015 11:58:52 +0200
91 -Subject: [PATCH 05/10] cmake: Do not install libgtest
92 -
93 -libgtest is an internal test dependency, and should not be installed to
94 -the live system as a part of LLVM.
95 -
96 -Bug: http://llvm.org/bugs/show_bug.cgi?id=18341
97 ----
98 - utils/unittest/CMakeLists.txt | 3 +++
99 - 1 file changed, 3 insertions(+)
100 -
101 -diff --git a/utils/unittest/CMakeLists.txt b/utils/unittest/CMakeLists.txt
102 -index c9a2cdd..bb4f667 100644
103 ---- a/utils/unittest/CMakeLists.txt
104 -+++ b/utils/unittest/CMakeLists.txt
105 -@@ -37,6 +37,9 @@ if (PTHREAD_LIBRARY_PATH)
106 - list(APPEND LIBS pthread)
107 - endif()
108 -
109 -+# Delay building until the tests pull it in, and avoid installing it
110 -+set(EXCLUDE_FROM_ALL ON)
111 -+
112 - add_llvm_library(gtest
113 - googletest/src/gtest-all.cc
114 -
115 ---
116 -2.9.3
117 -
118
119 diff --git a/sys-devel/llvm/files/3.8.1/0008-cmake-Restore-SOVERSIONs-on-shared-libraries.patch b/sys-devel/llvm/files/3.8.1/0008-cmake-Restore-SOVERSIONs-on-shared-libraries.patch
120 deleted file mode 100644
121 index c333bc4b962..00000000000
122 --- a/sys-devel/llvm/files/3.8.1/0008-cmake-Restore-SOVERSIONs-on-shared-libraries.patch
123 +++ /dev/null
124 @@ -1,28 +0,0 @@
125 -From 597ebcc28580a8532f6634e2a723901c3448b9ff Mon Sep 17 00:00:00 2001
126 -From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@g.o>
127 -Date: Mon, 28 Mar 2016 22:21:19 +0200
128 -Subject: [PATCH 08/10] cmake: Restore SOVERSIONs on shared libraries
129 -
130 ----
131 - cmake/modules/AddLLVM.cmake | 5 +++++
132 - 1 file changed, 5 insertions(+)
133 -
134 -diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake
135 -index 9590a1b..83a2359 100644
136 ---- a/cmake/modules/AddLLVM.cmake
137 -+++ b/cmake/modules/AddLLVM.cmake
138 -@@ -445,6 +445,11 @@ function(llvm_add_library name)
139 - PREFIX ""
140 - )
141 - endif()
142 -+
143 -+ set_target_properties(${name}
144 -+ PROPERTIES
145 -+ SOVERSION ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}
146 -+ VERSION ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}${LLVM_VERSION_SUFFIX})
147 - endif()
148 -
149 - if(ARG_MODULE OR ARG_SHARED)
150 ---
151 -2.9.3
152 -
153
154 diff --git a/sys-devel/llvm/files/3.8.1/clang/abi-tag-support-mangler.patch b/sys-devel/llvm/files/3.8.1/clang/abi-tag-support-mangler.patch
155 deleted file mode 100644
156 index d259757372f..00000000000
157 --- a/sys-devel/llvm/files/3.8.1/clang/abi-tag-support-mangler.patch
158 +++ /dev/null
159 @@ -1,1230 +0,0 @@
160 -diff -Nuar llvm-3.8.0.src.orig/tools/clang/lib/AST/ItaniumMangle.cpp llvm-3.8.0.src/tools/clang/lib/AST/ItaniumMangle.cpp
161 ---- llvm-3.8.0.src.orig/tools/clang/lib/AST/ItaniumMangle.cpp 2016-01-09 13:53:17.000000000 +0100
162 -+++ llvm-3.8.0.src/tools/clang/lib/AST/ItaniumMangle.cpp 2016-07-10 23:59:08.412719561 +0200
163 -@@ -212,6 +212,12 @@
164 - class CXXNameMangler {
165 - ItaniumMangleContextImpl &Context;
166 - raw_ostream &Out;
167 -+ bool NullOut = false;
168 -+ /// In the "DisableDerivedAbiTags" mode derived ABI tags are not calculated.
169 -+ /// This mode is used when mangler creates another mangler recursively to
170 -+ /// calculate ABI tags for the function return value or the variable type.
171 -+ /// Also it is required to avoid infinite recursion in some cases.
172 -+ bool DisableDerivedAbiTags = false;
173 -
174 - /// The "structor" is the top-level declaration being mangled, if
175 - /// that's not a template specialization; otherwise it's the pattern
176 -@@ -261,15 +267,131 @@
177 -
178 - } FunctionTypeDepth;
179 -
180 -+ // abi_tag is a gcc attribute, taking one or more strings called "tags".
181 -+ // The goal is to annotate against which version of a library an object was
182 -+ // built and to be able to provide backwards compatibility ("dual abi").
183 -+ // For more information see docs/ItaniumMangleAbiTags.rst.
184 -+ typedef SmallVector<StringRef, 4> AbiTagList;
185 -+ typedef llvm::SmallSetVector<StringRef, 4> AbiTagSet;
186 -+
187 -+ // State to gather all implicit and explicit tags used in a mangled name.
188 -+ // Must always have an instance of this while emitting any name to keep
189 -+ // track.
190 -+ class AbiTagState final {
191 -+ //! All abi tags used implicitly or explicitly
192 -+ AbiTagSet UsedAbiTags;
193 -+ //! All explicit abi tags (i.e. not from namespace)
194 -+ AbiTagSet EmittedAbiTags;
195 -+
196 -+ AbiTagState *&LinkHead;
197 -+ AbiTagState *Parent = nullptr;
198 -+
199 -+ bool LinkActive = false;
200 -+
201 -+ public:
202 -+ explicit AbiTagState(AbiTagState *&Head) : LinkHead(Head) {
203 -+ Parent = LinkHead;
204 -+ LinkHead = this;
205 -+ LinkActive = true;
206 -+ }
207 -+
208 -+ // no copy, no move
209 -+ AbiTagState(const AbiTagState &) = delete;
210 -+ AbiTagState &operator=(const AbiTagState &) = delete;
211 -+
212 -+ ~AbiTagState() { pop(); }
213 -+
214 -+ void pop() {
215 -+ if (!LinkActive)
216 -+ return;
217 -+
218 -+ assert(LinkHead == this &&
219 -+ "abi tag link head must point to us on destruction");
220 -+ LinkActive = false;
221 -+ if (Parent) {
222 -+ Parent->UsedAbiTags.insert(UsedAbiTags.begin(), UsedAbiTags.end());
223 -+ Parent->EmittedAbiTags.insert(EmittedAbiTags.begin(),
224 -+ EmittedAbiTags.end());
225 -+ }
226 -+ LinkHead = Parent;
227 -+ }
228 -+
229 -+ void write(raw_ostream &Out, const NamedDecl *ND,
230 -+ const AbiTagList *AdditionalAbiTags) {
231 -+ ND = cast<NamedDecl>(ND->getCanonicalDecl());
232 -+
233 -+ if (!isa<FunctionDecl>(ND) && !isa<VarDecl>(ND)) {
234 -+ assert(
235 -+ !AdditionalAbiTags &&
236 -+ "only function and variables need a list of additional abi tags");
237 -+ if (const auto *NS = dyn_cast<NamespaceDecl>(ND)) {
238 -+ if (const auto *AbiTag = NS->getAttr<AbiTagAttr>()) {
239 -+ for (const auto &Tag : AbiTag->tags()) {
240 -+ UsedAbiTags.insert(Tag);
241 -+ }
242 -+ }
243 -+ // Don't emit abi tags for namespaces.
244 -+ return;
245 -+ }
246 -+ }
247 -+
248 -+ AbiTagList TagList;
249 -+ if (const auto *AbiTag = ND->getAttr<AbiTagAttr>()) {
250 -+ for (const auto &Tag : AbiTag->tags()) {
251 -+ UsedAbiTags.insert(Tag);
252 -+ // AbiTag->tags() is sorted and has no duplicates
253 -+ TagList.push_back(Tag);
254 -+ }
255 -+ }
256 -+
257 -+ if (AdditionalAbiTags) {
258 -+ for (const auto &Tag : *AdditionalAbiTags) {
259 -+ UsedAbiTags.insert(Tag);
260 -+ if (std::find(TagList.begin(), TagList.end(), Tag) == TagList.end()) {
261 -+ // don't insert duplicates
262 -+ TagList.push_back(Tag);
263 -+ }
264 -+ }
265 -+ // AbiTag->tags() are already sorted; only add if we had additional tags
266 -+ std::sort(TagList.begin(), TagList.end());
267 -+ }
268 -+
269 -+ writeSortedUniqueAbiTags(Out, TagList);
270 -+ }
271 -+
272 -+ const AbiTagSet &getUsedAbiTags() const { return UsedAbiTags; }
273 -+ void setUsedAbiTags(const AbiTagSet &AbiTags) {
274 -+ UsedAbiTags = AbiTags;
275 -+ }
276 -+
277 -+ const AbiTagSet &getEmittedAbiTags() const {
278 -+ return EmittedAbiTags;
279 -+ }
280 -+
281 -+ private:
282 -+ template <typename TagList>
283 -+ void writeSortedUniqueAbiTags(raw_ostream &Out, TagList const &AbiTags) {
284 -+ for (const auto &Tag : AbiTags) {
285 -+ EmittedAbiTags.insert(Tag);
286 -+ Out << "B";
287 -+ Out << Tag.size();
288 -+ Out << Tag;
289 -+ }
290 -+ }
291 -+ };
292 -+
293 -+ AbiTagState *AbiTags = nullptr;
294 -+ AbiTagState AbiTagsRoot;
295 -+
296 - llvm::DenseMap<uintptr_t, unsigned> Substitutions;
297 -
298 - ASTContext &getASTContext() const { return Context.getASTContext(); }
299 -
300 - public:
301 - CXXNameMangler(ItaniumMangleContextImpl &C, raw_ostream &Out_,
302 -- const NamedDecl *D = nullptr)
303 -- : Context(C), Out(Out_), Structor(getStructor(D)), StructorType(0),
304 -- SeqID(0) {
305 -+ const NamedDecl *D = nullptr, bool NullOut_ = false)
306 -+ : Context(C), Out(Out_), NullOut(NullOut_), Structor(getStructor(D)),
307 -+ StructorType(0), SeqID(0), AbiTagsRoot(AbiTags) {
308 - // These can't be mangled without a ctor type or dtor type.
309 - assert(!D || (!isa<CXXDestructorDecl>(D) &&
310 - !isa<CXXConstructorDecl>(D)));
311 -@@ -277,11 +399,16 @@
312 - CXXNameMangler(ItaniumMangleContextImpl &C, raw_ostream &Out_,
313 - const CXXConstructorDecl *D, CXXCtorType Type)
314 - : Context(C), Out(Out_), Structor(getStructor(D)), StructorType(Type),
315 -- SeqID(0) { }
316 -+ SeqID(0), AbiTagsRoot(AbiTags) { }
317 - CXXNameMangler(ItaniumMangleContextImpl &C, raw_ostream &Out_,
318 - const CXXDestructorDecl *D, CXXDtorType Type)
319 - : Context(C), Out(Out_), Structor(getStructor(D)), StructorType(Type),
320 -- SeqID(0) { }
321 -+ SeqID(0), AbiTagsRoot(AbiTags) { }
322 -+
323 -+ CXXNameMangler(CXXNameMangler &Outer, llvm::raw_null_ostream &Out_)
324 -+ : Context(Outer.Context), Out(Out_), NullOut(true),
325 -+ Structor(Outer.Structor), StructorType(Outer.StructorType),
326 -+ SeqID(Outer.SeqID), AbiTagsRoot(AbiTags) {}
327 -
328 - #if MANGLE_CHECKER
329 - ~CXXNameMangler() {
330 -@@ -296,14 +423,18 @@
331 - #endif
332 - raw_ostream &getStream() { return Out; }
333 -
334 -+ void disableDerivedAbiTags() { DisableDerivedAbiTags = true; }
335 -+ static bool shouldHaveAbiTags(ItaniumMangleContextImpl &C, const VarDecl *VD);
336 -+
337 - void mangle(const NamedDecl *D);
338 - void mangleCallOffset(int64_t NonVirtual, int64_t Virtual);
339 - void mangleNumber(const llvm::APSInt &I);
340 - void mangleNumber(int64_t Number);
341 - void mangleFloat(const llvm::APFloat &F);
342 -- void mangleFunctionEncoding(const FunctionDecl *FD);
343 -+ void mangleFunctionEncoding(const FunctionDecl *FD,
344 -+ bool ExcludeUnqualifiedName = false);
345 - void mangleSeqID(unsigned SeqID);
346 -- void mangleName(const NamedDecl *ND);
347 -+ void mangleName(const NamedDecl *ND, bool ExcludeUnqualifiedName = false);
348 - void mangleType(QualType T);
349 - void mangleNameOrStandardSubstitution(const NamedDecl *ND);
350 -
351 -@@ -334,31 +465,53 @@
352 - DeclarationName name,
353 - unsigned KnownArity = UnknownArity);
354 -
355 -- void mangleName(const TemplateDecl *TD,
356 -- const TemplateArgument *TemplateArgs,
357 -- unsigned NumTemplateArgs);
358 -- void mangleUnqualifiedName(const NamedDecl *ND) {
359 -- mangleUnqualifiedName(ND, ND->getDeclName(), UnknownArity);
360 -+ void mangleFunctionEncodingBareType(const FunctionDecl *FD);
361 -+
362 -+ void mangleNameWithAbiTags(const NamedDecl *ND,
363 -+ const AbiTagList *AdditionalAbiTags,
364 -+ bool ExcludeUnqualifiedName);
365 -+ void mangleTemplateName(const TemplateDecl *TD,
366 -+ const AbiTagList *AdditionalAbiTags,
367 -+ bool ExcludeUnqualifiedName,
368 -+ const TemplateArgument *TemplateArgs,
369 -+ unsigned NumTemplateArgs);
370 -+ void mangleUnqualifiedName(const NamedDecl *ND,
371 -+ const AbiTagList *AdditionalAbiTags) {
372 -+ mangleUnqualifiedName(ND, ND->getDeclName(), UnknownArity,
373 -+ AdditionalAbiTags);
374 - }
375 - void mangleUnqualifiedName(const NamedDecl *ND, DeclarationName Name,
376 -- unsigned KnownArity);
377 -- void mangleUnscopedName(const NamedDecl *ND);
378 -- void mangleUnscopedTemplateName(const TemplateDecl *ND);
379 -- void mangleUnscopedTemplateName(TemplateName);
380 -+ unsigned KnownArity,
381 -+ const AbiTagList *AdditionalAbiTags);
382 -+ void mangleUnscopedName(const NamedDecl *ND,
383 -+ const AbiTagList *AdditionalAbiTags);
384 -+ void mangleUnscopedTemplateName(const TemplateDecl *ND,
385 -+ const AbiTagList *AdditionalAbiTags);
386 -+ void mangleUnscopedTemplateName(TemplateName,
387 -+ const AbiTagList *AdditionalAbiTags);
388 - void mangleSourceName(const IdentifierInfo *II);
389 -- void mangleLocalName(const Decl *D);
390 -+ void mangleLocalName(const Decl *D,
391 -+ const AbiTagList *AdditionalAbiTags,
392 -+ bool ExcludeUnqualifiedName);
393 - void mangleBlockForPrefix(const BlockDecl *Block);
394 - void mangleUnqualifiedBlock(const BlockDecl *Block);
395 - void mangleLambda(const CXXRecordDecl *Lambda);
396 - void mangleNestedName(const NamedDecl *ND, const DeclContext *DC,
397 -- bool NoFunction=false);
398 -+ const AbiTagList *AdditionalAbiTags,
399 -+ bool NoFunction,
400 -+ bool ExcludeUnqualifiedName);
401 - void mangleNestedName(const TemplateDecl *TD,
402 -+ const AbiTagList *AdditionalAbiTags,
403 -+ bool ExcludeUnqualifiedName,
404 - const TemplateArgument *TemplateArgs,
405 - unsigned NumTemplateArgs);
406 - void manglePrefix(NestedNameSpecifier *qualifier);
407 - void manglePrefix(const DeclContext *DC, bool NoFunction=false);
408 - void manglePrefix(QualType type);
409 -- void mangleTemplatePrefix(const TemplateDecl *ND, bool NoFunction=false);
410 -+ void mangleTemplatePrefix(const TemplateDecl *ND,
411 -+ const AbiTagList *AdditionalAbiTags,
412 -+ bool NoFunction = false,
413 -+ bool ExcludeUnqualifiedName = false);
414 - void mangleTemplatePrefix(TemplateName Template);
415 - bool mangleUnresolvedTypeOrSimpleId(QualType DestroyedType,
416 - StringRef Prefix = "");
417 -@@ -405,6 +558,13 @@
418 - void mangleTemplateParameter(unsigned Index);
419 -
420 - void mangleFunctionParam(const ParmVarDecl *parm);
421 -+
422 -+ void writeAbiTags(const NamedDecl *ND,
423 -+ const AbiTagList *AdditionalAbiTags = nullptr);
424 -+
425 -+ AbiTagSet getTagsFromPrefixAndTemplateArguments(const NamedDecl *ND);
426 -+ AbiTagList makeAdditionalTagsForFunction(const FunctionDecl *FD);
427 -+ AbiTagList makeAdditionalTagsForVariable(const VarDecl *VD);
428 - };
429 -
430 - }
431 -@@ -448,6 +608,7 @@
432 - while (!DC->isNamespace() && !DC->isTranslationUnit())
433 - DC = getEffectiveParentContext(DC);
434 - if (DC->isTranslationUnit() && D->getFormalLinkage() != InternalLinkage &&
435 -+ !CXXNameMangler::shouldHaveAbiTags(*this, VD) &&
436 - !isa<VarTemplateSpecializationDecl>(D))
437 - return false;
438 - }
439 -@@ -455,6 +616,12 @@
440 - return true;
441 - }
442 -
443 -+void CXXNameMangler::writeAbiTags(const NamedDecl *ND,
444 -+ const AbiTagList *AdditionalAbiTags) {
445 -+ assert(AbiTags && "require AbiTagState");
446 -+ AbiTags->write(Out, ND, DisableDerivedAbiTags ? nullptr : AdditionalAbiTags);
447 -+}
448 -+
449 - void CXXNameMangler::mangle(const NamedDecl *D) {
450 - // <mangled-name> ::= _Z <encoding>
451 - // ::= <data name>
452 -@@ -470,14 +637,31 @@
453 - mangleName(cast<FieldDecl>(D));
454 - }
455 -
456 --void CXXNameMangler::mangleFunctionEncoding(const FunctionDecl *FD) {
457 -- // <encoding> ::= <function name> <bare-function-type>
458 -- mangleName(FD);
459 --
460 -+void CXXNameMangler::mangleFunctionEncoding(const FunctionDecl *FD,
461 -+ bool ExcludeUnqualifiedName) {
462 - // Don't mangle in the type if this isn't a decl we should typically mangle.
463 -- if (!Context.shouldMangleDeclName(FD))
464 -+ if (!Context.shouldMangleDeclName(FD)) {
465 -+ mangleNameWithAbiTags(FD, /* AdditionalAbiTags */ nullptr,
466 -+ ExcludeUnqualifiedName);
467 - return;
468 -+ }
469 -+
470 -+ // <encoding> ::= <function name> <bare-function-type>
471 -+
472 -+ if (ExcludeUnqualifiedName) {
473 -+ // running makeAdditionalTagsForFunction would loop, don't need it here
474 -+ // anyway
475 -+ mangleNameWithAbiTags(FD, /* AdditionalAbiTags */ nullptr,
476 -+ ExcludeUnqualifiedName);
477 -+ } else {
478 -+ AbiTagList AdditionalAbiTags = makeAdditionalTagsForFunction(FD);
479 -+ mangleNameWithAbiTags(FD, &AdditionalAbiTags, ExcludeUnqualifiedName);
480 -+ }
481 -
482 -+ mangleFunctionEncodingBareType(FD);
483 -+}
484 -+
485 -+void CXXNameMangler::mangleFunctionEncodingBareType(const FunctionDecl *FD) {
486 - if (FD->hasAttr<EnableIfAttr>()) {
487 - FunctionTypeDepthState Saved = FunctionTypeDepth.push();
488 - Out << "Ua9enable_ifI";
489 -@@ -581,7 +765,24 @@
490 - return nullptr;
491 - }
492 -
493 --void CXXNameMangler::mangleName(const NamedDecl *ND) {
494 -+// Must not be run from mangleLocalName for the <entity name> as it would loop
495 -+// otherwise.
496 -+void CXXNameMangler::mangleName(const NamedDecl *ND,
497 -+ bool ExcludeUnqualifiedName) {
498 -+ if (!ExcludeUnqualifiedName) {
499 -+ if (const auto *VD = dyn_cast<VarDecl>(ND)) {
500 -+ AbiTagList VariableAdditionalAbiTags = makeAdditionalTagsForVariable(VD);
501 -+ mangleNameWithAbiTags(VD, &VariableAdditionalAbiTags,
502 -+ ExcludeUnqualifiedName);
503 -+ return;
504 -+ }
505 -+ }
506 -+ mangleNameWithAbiTags(ND, nullptr, ExcludeUnqualifiedName);
507 -+}
508 -+
509 -+void CXXNameMangler::mangleNameWithAbiTags(const NamedDecl *ND,
510 -+ const AbiTagList *AdditionalAbiTags,
511 -+ bool ExcludeUnqualifiedName) {
512 - // <name> ::= <nested-name>
513 - // ::= <unscoped-name>
514 - // ::= <unscoped-template-name> <template-args>
515 -@@ -597,7 +798,7 @@
516 - while (!DC->isNamespace() && !DC->isTranslationUnit())
517 - DC = getEffectiveParentContext(DC);
518 - else if (GetLocalClassDecl(ND)) {
519 -- mangleLocalName(ND);
520 -+ mangleLocalName(ND, AdditionalAbiTags, ExcludeUnqualifiedName);
521 - return;
522 - }
523 -
524 -@@ -607,76 +808,93 @@
525 - // Check if we have a template.
526 - const TemplateArgumentList *TemplateArgs = nullptr;
527 - if (const TemplateDecl *TD = isTemplate(ND, TemplateArgs)) {
528 -- mangleUnscopedTemplateName(TD);
529 -+ if (!ExcludeUnqualifiedName)
530 -+ mangleUnscopedTemplateName(TD, AdditionalAbiTags);
531 - mangleTemplateArgs(*TemplateArgs);
532 - return;
533 - }
534 -
535 -- mangleUnscopedName(ND);
536 -+ if (!ExcludeUnqualifiedName)
537 -+ mangleUnscopedName(ND, AdditionalAbiTags);
538 - return;
539 - }
540 -
541 - if (isLocalContainerContext(DC)) {
542 -- mangleLocalName(ND);
543 -+ mangleLocalName(ND, AdditionalAbiTags, ExcludeUnqualifiedName);
544 - return;
545 - }
546 -
547 -- mangleNestedName(ND, DC);
548 -+ mangleNestedName(ND, DC, AdditionalAbiTags, /* NoFunction */ false,
549 -+ ExcludeUnqualifiedName);
550 - }
551 --void CXXNameMangler::mangleName(const TemplateDecl *TD,
552 -- const TemplateArgument *TemplateArgs,
553 -- unsigned NumTemplateArgs) {
554 -+
555 -+void CXXNameMangler::mangleTemplateName(const TemplateDecl *TD,
556 -+ const AbiTagList *AdditionalAbiTags,
557 -+ bool ExcludeUnqualifiedName,
558 -+ const TemplateArgument *TemplateArgs,
559 -+ unsigned NumTemplateArgs) {
560 - const DeclContext *DC = IgnoreLinkageSpecDecls(getEffectiveDeclContext(TD));
561 -
562 - if (DC->isTranslationUnit() || isStdNamespace(DC)) {
563 -- mangleUnscopedTemplateName(TD);
564 -+ if (!ExcludeUnqualifiedName)
565 -+ mangleUnscopedTemplateName(TD, AdditionalAbiTags);
566 - mangleTemplateArgs(TemplateArgs, NumTemplateArgs);
567 - } else {
568 -- mangleNestedName(TD, TemplateArgs, NumTemplateArgs);
569 -+ mangleNestedName(TD, AdditionalAbiTags, ExcludeUnqualifiedName,
570 -+ TemplateArgs, NumTemplateArgs);
571 - }
572 - }
573 -
574 --void CXXNameMangler::mangleUnscopedName(const NamedDecl *ND) {
575 -+void CXXNameMangler::mangleUnscopedName(const NamedDecl *ND,
576 -+ const AbiTagList *AdditionalAbiTags) {
577 - // <unscoped-name> ::= <unqualified-name>
578 - // ::= St <unqualified-name> # ::std::
579 -
580 - if (isStdNamespace(IgnoreLinkageSpecDecls(getEffectiveDeclContext(ND))))
581 - Out << "St";
582 -
583 -- mangleUnqualifiedName(ND);
584 -+ mangleUnqualifiedName(ND, AdditionalAbiTags);
585 - }
586 -
587 --void CXXNameMangler::mangleUnscopedTemplateName(const TemplateDecl *ND) {
588 -+void CXXNameMangler::mangleUnscopedTemplateName(
589 -+ const TemplateDecl *ND, const AbiTagList *AdditionalAbiTags) {
590 - // <unscoped-template-name> ::= <unscoped-name>
591 - // ::= <substitution>
592 - if (mangleSubstitution(ND))
593 - return;
594 -
595 - // <template-template-param> ::= <template-param>
596 -- if (const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(ND))
597 -+ if (const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(ND)) {
598 -+ assert(!AdditionalAbiTags &&
599 -+ "template template param cannot have abi tags");
600 - mangleTemplateParameter(TTP->getIndex());
601 -- else
602 -- mangleUnscopedName(ND->getTemplatedDecl());
603 -+ } else {
604 -+ mangleUnscopedName(ND->getTemplatedDecl(), AdditionalAbiTags);
605 -+ }
606 -
607 - addSubstitution(ND);
608 - }
609 -
610 --void CXXNameMangler::mangleUnscopedTemplateName(TemplateName Template) {
611 -+void CXXNameMangler::mangleUnscopedTemplateName(
612 -+ TemplateName Template, const AbiTagList *AdditionalAbiTags) {
613 - // <unscoped-template-name> ::= <unscoped-name>
614 - // ::= <substitution>
615 - if (TemplateDecl *TD = Template.getAsTemplateDecl())
616 -- return mangleUnscopedTemplateName(TD);
617 -+ return mangleUnscopedTemplateName(TD, AdditionalAbiTags);
618 -
619 - if (mangleSubstitution(Template))
620 - return;
621 -
622 -+ assert(!AdditionalAbiTags &&
623 -+ "dependent template name cannot have abi tags");
624 -+
625 - DependentTemplateName *Dependent = Template.getAsDependentTemplateName();
626 - assert(Dependent && "Not a dependent template name?");
627 - if (const IdentifierInfo *Id = Dependent->getIdentifier())
628 - mangleSourceName(Id);
629 - else
630 - mangleOperatorName(Dependent->getOperator(), UnknownArity);
631 --
632 -+
633 - addSubstitution(Template);
634 - }
635 -
636 -@@ -835,6 +1053,7 @@
637 - else
638 - Out << "sr";
639 - mangleSourceName(qualifier->getAsNamespace()->getIdentifier());
640 -+ writeAbiTags(qualifier->getAsNamespace());
641 - break;
642 - case NestedNameSpecifier::NamespaceAlias:
643 - if (qualifier->getPrefix())
644 -@@ -843,6 +1062,7 @@
645 - else
646 - Out << "sr";
647 - mangleSourceName(qualifier->getAsNamespaceAlias()->getIdentifier());
648 -+ writeAbiTags(qualifier->getAsNamespaceAlias());
649 - break;
650 -
651 - case NestedNameSpecifier::TypeSpec:
652 -@@ -877,6 +1097,7 @@
653 - Out << "sr";
654 -
655 - mangleSourceName(qualifier->getAsIdentifier());
656 -+ // an Identifier has no type information, so we can't emit abi tags for it
657 - break;
658 - }
659 -
660 -@@ -922,7 +1143,8 @@
661 -
662 - void CXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND,
663 - DeclarationName Name,
664 -- unsigned KnownArity) {
665 -+ unsigned KnownArity,
666 -+ const AbiTagList *AdditionalAbiTags) {
667 - unsigned Arity = KnownArity;
668 - // <unqualified-name> ::= <operator-name>
669 - // ::= <ctor-dtor-name>
670 -@@ -941,6 +1163,7 @@
671 - Out << 'L';
672 -
673 - mangleSourceName(II);
674 -+ writeAbiTags(ND, AdditionalAbiTags);
675 - break;
676 - }
677 -
678 -@@ -980,6 +1203,7 @@
679 - assert(FD->getIdentifier() && "Data member name isn't an identifier!");
680 -
681 - mangleSourceName(FD->getIdentifier());
682 -+ // Not emitting abi tags: internal name anyway
683 - break;
684 - }
685 -
686 -@@ -1000,6 +1224,10 @@
687 - assert(D->getDeclName().getAsIdentifierInfo() &&
688 - "Typedef was not named!");
689 - mangleSourceName(D->getDeclName().getAsIdentifierInfo());
690 -+ assert(!AdditionalAbiTags && "Type cannot have additional abi tags");
691 -+ // explicit abi tags are still possible; take from underlying type, not
692 -+ // from typedef.
693 -+ writeAbiTags(TD, nullptr);
694 - break;
695 - }
696 -
697 -@@ -1009,6 +1237,8 @@
698 - // <lambda-sig> ::= <parameter-type>+ # Parameter types or 'v' for 'void'.
699 - if (const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(TD)) {
700 - if (Record->isLambda() && Record->getLambdaManglingNumber()) {
701 -+ assert(!AdditionalAbiTags &&
702 -+ "Lambda type cannot have additional abi tags");
703 - mangleLambda(Record);
704 - break;
705 - }
706 -@@ -1020,11 +1250,13 @@
707 - if (UnnamedMangle > 1)
708 - Out << UnnamedMangle - 2;
709 - Out << '_';
710 -+ writeAbiTags(TD, AdditionalAbiTags);
711 - break;
712 - }
713 -
714 -- // Get a unique id for the anonymous struct.
715 -- unsigned AnonStructId = Context.getAnonymousStructId(TD);
716 -+ // Get a unique id for the anonymous struct. If it is not a real output
717 -+ // ID doesn't matter so use fake one.
718 -+ unsigned AnonStructId = NullOut ? 0 : Context.getAnonymousStructId(TD);
719 -
720 - // Mangle it as a source name in the form
721 - // [n] $_<id>
722 -@@ -1052,6 +1284,7 @@
723 - // Otherwise, use the complete constructor name. This is relevant if a
724 - // class with a constructor is declared within a constructor.
725 - mangleCXXCtorType(Ctor_Complete);
726 -+ writeAbiTags(ND, AdditionalAbiTags);
727 - break;
728 -
729 - case DeclarationName::CXXDestructorName:
730 -@@ -1063,6 +1296,7 @@
731 - // Otherwise, use the complete destructor name. This is relevant if a
732 - // class with a destructor is declared within a destructor.
733 - mangleCXXDtorType(Dtor_Complete);
734 -+ writeAbiTags(ND, AdditionalAbiTags);
735 - break;
736 -
737 - case DeclarationName::CXXOperatorName:
738 -@@ -1078,6 +1312,7 @@
739 - case DeclarationName::CXXConversionFunctionName:
740 - case DeclarationName::CXXLiteralOperatorName:
741 - mangleOperatorName(Name, Arity);
742 -+ writeAbiTags(ND, AdditionalAbiTags);
743 - break;
744 -
745 - case DeclarationName::CXXUsingDirective:
746 -@@ -1094,7 +1329,9 @@
747 -
748 - void CXXNameMangler::mangleNestedName(const NamedDecl *ND,
749 - const DeclContext *DC,
750 -- bool NoFunction) {
751 -+ const AbiTagList *AdditionalAbiTags,
752 -+ bool NoFunction,
753 -+ bool ExcludeUnqualifiedName) {
754 - // <nested-name>
755 - // ::= N [<CV-qualifiers>] [<ref-qualifier>] <prefix> <unqualified-name> E
756 - // ::= N [<CV-qualifiers>] [<ref-qualifier>] <template-prefix>
757 -@@ -1114,30 +1351,36 @@
758 - // Check if we have a template.
759 - const TemplateArgumentList *TemplateArgs = nullptr;
760 - if (const TemplateDecl *TD = isTemplate(ND, TemplateArgs)) {
761 -- mangleTemplatePrefix(TD, NoFunction);
762 -+ mangleTemplatePrefix(TD, AdditionalAbiTags, NoFunction,
763 -+ ExcludeUnqualifiedName);
764 - mangleTemplateArgs(*TemplateArgs);
765 - }
766 - else {
767 - manglePrefix(DC, NoFunction);
768 -- mangleUnqualifiedName(ND);
769 -+ if (!ExcludeUnqualifiedName)
770 -+ mangleUnqualifiedName(ND, AdditionalAbiTags);
771 - }
772 -
773 - Out << 'E';
774 - }
775 - void CXXNameMangler::mangleNestedName(const TemplateDecl *TD,
776 -+ const AbiTagList *AdditionalAbiTags,
777 -+ bool ExcludeUnqualifiedName,
778 - const TemplateArgument *TemplateArgs,
779 - unsigned NumTemplateArgs) {
780 - // <nested-name> ::= N [<CV-qualifiers>] <template-prefix> <template-args> E
781 -
782 - Out << 'N';
783 -
784 -- mangleTemplatePrefix(TD);
785 -+ mangleTemplatePrefix(TD, AdditionalAbiTags, ExcludeUnqualifiedName);
786 - mangleTemplateArgs(TemplateArgs, NumTemplateArgs);
787 -
788 - Out << 'E';
789 - }
790 -
791 --void CXXNameMangler::mangleLocalName(const Decl *D) {
792 -+void CXXNameMangler::mangleLocalName(const Decl *D,
793 -+ const AbiTagList *AdditionalAbiTags,
794 -+ bool ExcludeUnqualifiedName) {
795 - // <local-name> := Z <function encoding> E <entity name> [<discriminator>]
796 - // := Z <function encoding> E s [<discriminator>]
797 - // <local-name> := Z <function encoding> E d [ <parameter number> ]
798 -@@ -1149,15 +1392,26 @@
799 -
800 - Out << 'Z';
801 -
802 -- if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(DC))
803 -- mangleObjCMethodName(MD);
804 -- else if (const BlockDecl *BD = dyn_cast<BlockDecl>(DC))
805 -- mangleBlockForPrefix(BD);
806 -- else
807 -- mangleFunctionEncoding(cast<FunctionDecl>(DC));
808 -+ {
809 -+ AbiTagState LocalAbiTags(AbiTags);
810 -+
811 -+ if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(DC))
812 -+ mangleObjCMethodName(MD);
813 -+ else if (const BlockDecl *BD = dyn_cast<BlockDecl>(DC))
814 -+ mangleBlockForPrefix(BD);
815 -+ else
816 -+ mangleFunctionEncoding(cast<FunctionDecl>(DC));
817 -+
818 -+ // Implicit ABI tags (from namespace) are not available in the following
819 -+ // entity; reset to actually emitted tags, which are available.
820 -+ LocalAbiTags.setUsedAbiTags(LocalAbiTags.getEmittedAbiTags());
821 -+ }
822 -
823 - Out << 'E';
824 -
825 -+ // GCC 5.3.0 doesn't emit derived ABI tags for local names but that seems to
826 -+ // be a bug that is fixed in trunk.
827 -+
828 - if (RD) {
829 - // The parameter number is omitted for the last parameter, 0 for the
830 - // second-to-last parameter, 1 for the third-to-last parameter, etc. The
831 -@@ -1182,13 +1436,17 @@
832 - // Mangle the name relative to the closest enclosing function.
833 - // equality ok because RD derived from ND above
834 - if (D == RD) {
835 -- mangleUnqualifiedName(RD);
836 -+ if (!ExcludeUnqualifiedName)
837 -+ mangleUnqualifiedName(RD, AdditionalAbiTags);
838 - } else if (const BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
839 - manglePrefix(getEffectiveDeclContext(BD), true /*NoFunction*/);
840 -- mangleUnqualifiedBlock(BD);
841 -+ assert(!AdditionalAbiTags && "Block cannot have additional abi tags");
842 -+ if (!ExcludeUnqualifiedName)
843 -+ mangleUnqualifiedBlock(BD);
844 - } else {
845 - const NamedDecl *ND = cast<NamedDecl>(D);
846 -- mangleNestedName(ND, getEffectiveDeclContext(ND), true /*NoFunction*/);
847 -+ mangleNestedName(ND, getEffectiveDeclContext(ND), AdditionalAbiTags,
848 -+ true /*NoFunction*/, ExcludeUnqualifiedName);
849 - }
850 - } else if (const BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
851 - // Mangle a block in a default parameter; see above explanation for
852 -@@ -1205,30 +1463,37 @@
853 - }
854 - }
855 -
856 -- mangleUnqualifiedBlock(BD);
857 -+ assert(!AdditionalAbiTags && "Block cannot have additional abi tags");
858 -+ if (!ExcludeUnqualifiedName)
859 -+ mangleUnqualifiedBlock(BD);
860 - } else {
861 -- mangleUnqualifiedName(cast<NamedDecl>(D));
862 -+ if (!ExcludeUnqualifiedName)
863 -+ mangleUnqualifiedName(cast<NamedDecl>(D), AdditionalAbiTags);
864 - }
865 -
866 -- if (const NamedDecl *ND = dyn_cast<NamedDecl>(RD ? RD : D)) {
867 -- unsigned disc;
868 -- if (Context.getNextDiscriminator(ND, disc)) {
869 -- if (disc < 10)
870 -- Out << '_' << disc;
871 -- else
872 -- Out << "__" << disc << '_';
873 -+ if (!ExcludeUnqualifiedName) {
874 -+ if (const NamedDecl *ND = dyn_cast<NamedDecl>(RD ? RD : D)) {
875 -+ unsigned disc;
876 -+ if (Context.getNextDiscriminator(ND, disc)) {
877 -+ if (disc < 10)
878 -+ Out << '_' << disc;
879 -+ else
880 -+ Out << "__" << disc << '_';
881 -+ }
882 - }
883 - }
884 - }
885 -
886 - void CXXNameMangler::mangleBlockForPrefix(const BlockDecl *Block) {
887 - if (GetLocalClassDecl(Block)) {
888 -- mangleLocalName(Block);
889 -+ mangleLocalName(Block, /* AdditionalAbiTags */ nullptr,
890 -+ /* ExcludeUnqualifiedName */ false);
891 - return;
892 - }
893 - const DeclContext *DC = getEffectiveDeclContext(Block);
894 - if (isLocalContainerContext(DC)) {
895 -- mangleLocalName(Block);
896 -+ mangleLocalName(Block, /* AdditionalAbiTags */ nullptr,
897 -+ /* ExcludeUnqualifiedName */ false);
898 - return;
899 - }
900 - manglePrefix(getEffectiveDeclContext(Block));
901 -@@ -1239,10 +1504,11 @@
902 - if (Decl *Context = Block->getBlockManglingContextDecl()) {
903 - if ((isa<VarDecl>(Context) || isa<FieldDecl>(Context)) &&
904 - Context->getDeclContext()->isRecord()) {
905 -- if (const IdentifierInfo *Name
906 -- = cast<NamedDecl>(Context)->getIdentifier()) {
907 -+ const auto *ND = cast<NamedDecl>(Context);
908 -+ if (const IdentifierInfo *Name = ND->getIdentifier()) {
909 - mangleSourceName(Name);
910 -- Out << 'M';
911 -+ writeAbiTags(ND, /* AdditionalAbiTags */ nullptr);
912 -+ Out << 'M';
913 - }
914 - }
915 - }
916 -@@ -1275,7 +1541,7 @@
917 - if (const IdentifierInfo *Name
918 - = cast<NamedDecl>(Context)->getIdentifier()) {
919 - mangleSourceName(Name);
920 -- Out << 'M';
921 -+ Out << 'M';
922 - }
923 - }
924 - }
925 -@@ -1358,11 +1624,11 @@
926 - // Check if we have a template.
927 - const TemplateArgumentList *TemplateArgs = nullptr;
928 - if (const TemplateDecl *TD = isTemplate(ND, TemplateArgs)) {
929 -- mangleTemplatePrefix(TD);
930 -+ mangleTemplatePrefix(TD, /* AdditionalAbiTags */ nullptr);
931 - mangleTemplateArgs(*TemplateArgs);
932 - } else {
933 - manglePrefix(getEffectiveDeclContext(ND), NoFunction);
934 -- mangleUnqualifiedName(ND);
935 -+ mangleUnqualifiedName(ND, /* AdditionalAbiTags */ nullptr);
936 - }
937 -
938 - addSubstitution(ND);
939 -@@ -1373,27 +1639,30 @@
940 - // ::= <template-param>
941 - // ::= <substitution>
942 - if (TemplateDecl *TD = Template.getAsTemplateDecl())
943 -- return mangleTemplatePrefix(TD);
944 -+ return mangleTemplatePrefix(TD, /* AdditionalAbiTags */ nullptr);
945 -
946 - if (QualifiedTemplateName *Qualified = Template.getAsQualifiedTemplateName())
947 - manglePrefix(Qualified->getQualifier());
948 --
949 -+
950 - if (OverloadedTemplateStorage *Overloaded
951 - = Template.getAsOverloadedTemplate()) {
952 - mangleUnqualifiedName(nullptr, (*Overloaded->begin())->getDeclName(),
953 -- UnknownArity);
954 -+ UnknownArity,
955 -+ /* AdditionalAbiTags */ nullptr);
956 - return;
957 - }
958 --
959 -+
960 - DependentTemplateName *Dependent = Template.getAsDependentTemplateName();
961 - assert(Dependent && "Unknown template name kind?");
962 - if (NestedNameSpecifier *Qualifier = Dependent->getQualifier())
963 - manglePrefix(Qualifier);
964 -- mangleUnscopedTemplateName(Template);
965 -+ mangleUnscopedTemplateName(Template, /* AdditionalAbiTags */ nullptr);
966 - }
967 -
968 - void CXXNameMangler::mangleTemplatePrefix(const TemplateDecl *ND,
969 -- bool NoFunction) {
970 -+ const AbiTagList *AdditionalAbiTags,
971 -+ bool NoFunction,
972 -+ bool ExcludeUnqualifiedName) {
973 - // <template-prefix> ::= <prefix> <template unqualified-name>
974 - // ::= <template-param>
975 - // ::= <substitution>
976 -@@ -1408,7 +1677,8 @@
977 - mangleTemplateParameter(TTP->getIndex());
978 - } else {
979 - manglePrefix(getEffectiveDeclContext(ND), NoFunction);
980 -- mangleUnqualifiedName(ND->getTemplatedDecl());
981 -+ if (!ExcludeUnqualifiedName)
982 -+ mangleUnqualifiedName(ND->getTemplatedDecl(), AdditionalAbiTags);
983 - }
984 -
985 - addSubstitution(ND);
986 -@@ -1452,6 +1722,7 @@
987 - // <name> ::= <nested-name>
988 - mangleUnresolvedPrefix(Dependent->getQualifier());
989 - mangleSourceName(Dependent->getIdentifier());
990 -+ // writeAbiTags(Dependent);
991 - break;
992 - }
993 -
994 -@@ -1544,16 +1815,19 @@
995 -
996 - case Type::Typedef:
997 - mangleSourceName(cast<TypedefType>(Ty)->getDecl()->getIdentifier());
998 -+ writeAbiTags(cast<TypedefType>(Ty)->getDecl());
999 - break;
1000 -
1001 - case Type::UnresolvedUsing:
1002 - mangleSourceName(
1003 - cast<UnresolvedUsingType>(Ty)->getDecl()->getIdentifier());
1004 -+ writeAbiTags(cast<UnresolvedUsingType>(Ty)->getDecl());
1005 - break;
1006 -
1007 - case Type::Enum:
1008 - case Type::Record:
1009 - mangleSourceName(cast<TagType>(Ty)->getDecl()->getIdentifier());
1010 -+ writeAbiTags(cast<TagType>(Ty)->getDecl());
1011 - break;
1012 -
1013 - case Type::TemplateSpecialization: {
1014 -@@ -1572,6 +1846,7 @@
1015 - goto unresolvedType;
1016 -
1017 - mangleSourceName(TD->getIdentifier());
1018 -+ writeAbiTags(TD);
1019 - break;
1020 - }
1021 -
1022 -@@ -1603,16 +1878,19 @@
1023 - case Type::InjectedClassName:
1024 - mangleSourceName(
1025 - cast<InjectedClassNameType>(Ty)->getDecl()->getIdentifier());
1026 -+ writeAbiTags(cast<InjectedClassNameType>(Ty)->getDecl());
1027 - break;
1028 -
1029 - case Type::DependentName:
1030 - mangleSourceName(cast<DependentNameType>(Ty)->getIdentifier());
1031 -+ // writeAbiTags(cast<DependentNameType>(Ty));
1032 - break;
1033 -
1034 - case Type::DependentTemplateSpecialization: {
1035 - const DependentTemplateSpecializationType *DTST =
1036 - cast<DependentTemplateSpecializationType>(Ty);
1037 - mangleSourceName(DTST->getIdentifier());
1038 -+ // writeAbiTags(DTST);
1039 - mangleTemplateArgs(DTST->getArgs(), DTST->getNumArgs());
1040 - break;
1041 - }
1042 -@@ -2070,7 +2348,9 @@
1043 - case BuiltinType::Id:
1044 - #include "clang/AST/BuiltinTypes.def"
1045 - case BuiltinType::Dependent:
1046 -- llvm_unreachable("mangling a placeholder type");
1047 -+ if (!NullOut)
1048 -+ llvm_unreachable("mangling a placeholder type");
1049 -+ break;
1050 - case BuiltinType::ObjCId:
1051 - Out << "11objc_object";
1052 - break;
1053 -@@ -2546,7 +2826,11 @@
1054 -
1055 - void CXXNameMangler::mangleType(const TemplateSpecializationType *T) {
1056 - if (TemplateDecl *TD = T->getTemplateName().getAsTemplateDecl()) {
1057 -- mangleName(TD, T->getArgs(), T->getNumArgs());
1058 -+ // types only have explicit abi tags, no addition tags
1059 -+ mangleTemplateName(TD,
1060 -+ /* AdditionalAbiTags */ nullptr,
1061 -+ /* ExcludeUnqualifiedName */ false,
1062 -+ T->getArgs(), T->getNumArgs());
1063 - } else {
1064 - if (mangleSubstitution(QualType(T, 0)))
1065 - return;
1066 -@@ -2872,12 +3156,14 @@
1067 - case Expr::PseudoObjectExprClass:
1068 - case Expr::AtomicExprClass:
1069 - {
1070 -- // As bad as this diagnostic is, it's better than crashing.
1071 -- DiagnosticsEngine &Diags = Context.getDiags();
1072 -- unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
1073 -- "cannot yet mangle expression type %0");
1074 -- Diags.Report(E->getExprLoc(), DiagID)
1075 -- << E->getStmtClassName() << E->getSourceRange();
1076 -+ if (!NullOut) {
1077 -+ // As bad as this diagnostic is, it's better than crashing.
1078 -+ DiagnosticsEngine &Diags = Context.getDiags();
1079 -+ unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
1080 -+ "cannot yet mangle expression type %0");
1081 -+ Diags.Report(E->getExprLoc(), DiagID)
1082 -+ << E->getStmtClassName() << E->getSourceRange();
1083 -+ }
1084 - break;
1085 - }
1086 -
1087 -@@ -4020,6 +4306,97 @@
1088 - Substitutions[Ptr] = SeqID++;
1089 - }
1090 -
1091 -+CXXNameMangler::AbiTagSet
1092 -+CXXNameMangler::getTagsFromPrefixAndTemplateArguments(const NamedDecl *ND) {
1093 -+ llvm::raw_null_ostream NullOutStream;
1094 -+ CXXNameMangler TrackPrefixAndTemplateArguments(*this, NullOutStream);
1095 -+
1096 -+ if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) {
1097 -+ TrackPrefixAndTemplateArguments.mangleFunctionEncoding(
1098 -+ FD, /* ExcludeUnqualifiedName */ true);
1099 -+ } else {
1100 -+ TrackPrefixAndTemplateArguments.mangleName(
1101 -+ ND, /* ExcludeUnqualifiedName */ true);
1102 -+ }
1103 -+
1104 -+ return std::move(
1105 -+ TrackPrefixAndTemplateArguments.AbiTagsRoot.getUsedAbiTags());
1106 -+}
1107 -+
1108 -+CXXNameMangler::AbiTagList
1109 -+CXXNameMangler::makeAdditionalTagsForFunction(const FunctionDecl *FD) {
1110 -+ // when derived abi tags are disabled there is no need to make any list
1111 -+ if (DisableDerivedAbiTags)
1112 -+ return AbiTagList();
1113 -+
1114 -+ AbiTagSet ImplicitlyAvailableTags =
1115 -+ getTagsFromPrefixAndTemplateArguments(FD);
1116 -+ AbiTagSet ReturnTypeTags;
1117 -+
1118 -+ {
1119 -+ llvm::raw_null_ostream NullOutStream;
1120 -+ CXXNameMangler TrackReturnTypeTags(*this, NullOutStream);
1121 -+ TrackReturnTypeTags.disableDerivedAbiTags();
1122 -+
1123 -+ const FunctionProtoType *Proto =
1124 -+ cast<FunctionProtoType>(FD->getType()->getAs<FunctionType>());
1125 -+ TrackReturnTypeTags.FunctionTypeDepth.enterResultType();
1126 -+ TrackReturnTypeTags.mangleType(Proto->getReturnType());
1127 -+ TrackReturnTypeTags.FunctionTypeDepth.leaveResultType();
1128 -+
1129 -+ ReturnTypeTags =
1130 -+ std::move(TrackReturnTypeTags.AbiTagsRoot.getUsedAbiTags());
1131 -+ }
1132 -+
1133 -+ AbiTagList AdditionalAbiTags;
1134 -+
1135 -+ for (const auto &Tag : ReturnTypeTags) {
1136 -+ if (ImplicitlyAvailableTags.count(Tag) == 0)
1137 -+ AdditionalAbiTags.push_back(Tag);
1138 -+ }
1139 -+
1140 -+ return AdditionalAbiTags;
1141 -+}
1142 -+
1143 -+CXXNameMangler::AbiTagList
1144 -+CXXNameMangler::makeAdditionalTagsForVariable(const VarDecl *VD) {
1145 -+ // when derived abi tags are disabled there is no need to make any list
1146 -+ if (DisableDerivedAbiTags)
1147 -+ return AbiTagList();
1148 -+
1149 -+ AbiTagSet ImplicitlyAvailableTags =
1150 -+ getTagsFromPrefixAndTemplateArguments(VD);
1151 -+ AbiTagSet VariableTypeTags;
1152 -+
1153 -+ {
1154 -+ llvm::raw_null_ostream NullOutStream;
1155 -+ CXXNameMangler TrackVariableType(*this, NullOutStream);
1156 -+ TrackVariableType.disableDerivedAbiTags();
1157 -+
1158 -+ TrackVariableType.mangleType(VD->getType());
1159 -+
1160 -+ VariableTypeTags =
1161 -+ std::move(TrackVariableType.AbiTagsRoot.getUsedAbiTags());
1162 -+ }
1163 -+
1164 -+ AbiTagList AdditionalAbiTags;
1165 -+
1166 -+ for (const auto &Tag : VariableTypeTags) {
1167 -+ if (ImplicitlyAvailableTags.count(Tag) == 0)
1168 -+ AdditionalAbiTags.push_back(Tag);
1169 -+ }
1170 -+
1171 -+ return AdditionalAbiTags;
1172 -+}
1173 -+
1174 -+bool CXXNameMangler::shouldHaveAbiTags(ItaniumMangleContextImpl &C,
1175 -+ const VarDecl *VD) {
1176 -+ llvm::raw_null_ostream NullOutStream;
1177 -+ CXXNameMangler TrackAbiTags(C, NullOutStream, nullptr, true);
1178 -+ TrackAbiTags.mangle(VD);
1179 -+ return TrackAbiTags.AbiTagsRoot.getUsedAbiTags().size();
1180 -+}
1181 -+
1182 - //
1183 -
1184 - /// Mangles the name of the declaration D and emits that name to the given
1185 -@@ -4121,6 +4498,8 @@
1186 - // <special-name> ::= GV <object name> # Guard variable for one-time
1187 - // # initialization
1188 - CXXNameMangler Mangler(*this, Out);
1189 -+ // GCC 5.3.0 doesn't emit derived ABI tags for local names but that seems to
1190 -+ // be a bug that is fixed in trunk.
1191 - Mangler.getStream() << "_ZGV";
1192 - Mangler.mangleName(D);
1193 - }
1194 -diff -Nuar llvm-3.8.0.src.orig/tools/clang/lib/Sema/SemaDeclAttr.cpp llvm-3.8.0.src/tools/clang/lib/Sema/SemaDeclAttr.cpp
1195 ---- llvm-3.8.0.src.orig/tools/clang/lib/Sema/SemaDeclAttr.cpp 2016-07-10 23:56:02.412319038 +0200
1196 -+++ llvm-3.8.0.src/tools/clang/lib/Sema/SemaDeclAttr.cpp 2016-07-10 23:59:08.413719568 +0200
1197 -@@ -4476,10 +4476,6 @@
1198 - D->addAttr(::new (S.Context)
1199 - AbiTagAttr(Attr.getRange(), S.Context, Tags.data(), Tags.size(),
1200 - Attr.getAttributeSpellingListIndex()));
1201 --
1202 -- // FIXME: remove this warning as soon as mangled part is ready.
1203 -- S.Diag(Attr.getRange().getBegin(), diag::warn_attribute_ignored)
1204 -- << Attr.getName();
1205 - }
1206 -
1207 - static void handleARMInterruptAttr(Sema &S, Decl *D,
1208 -diff -Nuar llvm-3.8.0.src.orig/tools/clang/test/CodeGenCXX/mangle-abi-tag.cpp llvm-3.8.0.src/tools/clang/test/CodeGenCXX/mangle-abi-tag.cpp
1209 ---- llvm-3.8.0.src.orig/tools/clang/test/CodeGenCXX/mangle-abi-tag.cpp 1970-01-01 01:00:00.000000000 +0100
1210 -+++ llvm-3.8.0.src/tools/clang/test/CodeGenCXX/mangle-abi-tag.cpp 2016-07-10 23:59:08.413719568 +0200
1211 -@@ -0,0 +1,146 @@
1212 -+// RUN: %clang_cc1 %s -emit-llvm -triple %itanium_abi_triple -std=c++11 -o - | FileCheck %s
1213 -+// RUN: %clang_cc1 %s -emit-llvm -triple i686-linux-gnu -std=c++11 -o - | FileCheck %s
1214 -+// RUN: %clang_cc1 %s -emit-llvm -triple x86_64-linux-gnu -std=c++11 -o - | FileCheck %s
1215 -+
1216 -+struct __attribute__((abi_tag("A", "B"))) A { };
1217 -+
1218 -+struct B: A { };
1219 -+
1220 -+template<class T>
1221 -+
1222 -+struct C {
1223 -+};
1224 -+
1225 -+struct D { A* p; };
1226 -+
1227 -+template<class T>
1228 -+struct __attribute__((abi_tag("C", "D"))) E {
1229 -+};
1230 -+
1231 -+struct __attribute__((abi_tag("A", "B"))) F { };
1232 -+
1233 -+A a1;
1234 -+// CHECK: @_Z2a1B1AB1B =
1235 -+
1236 -+__attribute__((abi_tag("C", "D")))
1237 -+A a2;
1238 -+// CHECK: @_Z2a2B1AB1BB1CB1D =
1239 -+
1240 -+B a3;
1241 -+// CHECK: @a3 =
1242 -+
1243 -+C<A> a4;
1244 -+// CHECK: @_Z2a4B1AB1B =
1245 -+
1246 -+D a5;
1247 -+// CHECK: @a5 =
1248 -+
1249 -+E<int> a6;
1250 -+// CHECK: @_Z2a6B1CB1D =
1251 -+
1252 -+E<A> a7;
1253 -+// CHECK: @_Z2a7B1AB1BB1CB1D =
1254 -+
1255 -+template<>
1256 -+struct E<float> {
1257 -+ static float a8;
1258 -+};
1259 -+float E<float>::a8;
1260 -+// CHECK: @_ZN1EB1CB1DIfE2a8E =
1261 -+
1262 -+template<>
1263 -+struct E<F> {
1264 -+ static bool a9;
1265 -+};
1266 -+bool E<F>::a9;
1267 -+// CHECK: @_ZN1EB1CB1DI1FB1AB1BE2a9E =
1268 -+
1269 -+struct __attribute__((abi_tag("A", "B"))) A10 {
1270 -+ virtual ~A10() {}
1271 -+} a10;
1272 -+// vtable
1273 -+// CHECK: @_ZTV3A10B1AB1B =
1274 -+// typeinfo
1275 -+// CHECK: @_ZTI3A10B1AB1B =
1276 -+
1277 -+// Local variables from f13.
1278 -+// f13()::L::foo[abi:C][abi:D]()::a[abi:A][abi:B]
1279 -+// CHECK-DAG: @_ZZZ3f13vEN1L3fooB1CB1DEvE1aB1AB1B =
1280 -+// guard variable for f13()::L::foo[abi:C][abi:D]()::a[abi:A][abi:B]
1281 -+// CHECK-DAG: @_ZGVZZ3f13vEN1L3fooB1CB1DEvE1aB1AB1B =
1282 -+
1283 -+__attribute__ ((abi_tag("C", "D")))
1284 -+void* f1() {
1285 -+ return 0;
1286 -+}
1287 -+// CHECK: define {{.*}} @_Z2f1B1CB1Dv(
1288 -+
1289 -+__attribute__ ((abi_tag("C", "D")))
1290 -+A* f2() {
1291 -+ return 0;
1292 -+}
1293 -+// CHECK: define {{.*}} @_Z2f2B1AB1BB1CB1Dv(
1294 -+
1295 -+B* f3() {
1296 -+ return 0;
1297 -+}
1298 -+// CHECK: define {{.*}} @_Z2f3v(
1299 -+
1300 -+C<A>* f4() {
1301 -+ return 0;
1302 -+}
1303 -+// CHECK: define {{.*}} @_Z2f4B1AB1Bv(
1304 -+
1305 -+D* f5() {
1306 -+ return 0;
1307 -+}
1308 -+// CHECK: define {{.*}} @_Z2f5v(
1309 -+
1310 -+E<char>* f6() {
1311 -+ return 0;
1312 -+}
1313 -+// CHECK: define {{.*}} @_Z2f6B1CB1Dv(
1314 -+
1315 -+E<A>* f7() {
1316 -+ return 0;
1317 -+}
1318 -+// CHECK: define {{.*}} @_Z2f7B1AB1BB1CB1Dv(
1319 -+
1320 -+void f8(E<A>*) {
1321 -+}
1322 -+// CHECK: define {{.*}} @_Z2f8P1EB1CB1DI1AB1AB1BE(
1323 -+
1324 -+inline namespace Names1 __attribute__((__abi_tag__)) {
1325 -+ class C1 {};
1326 -+}
1327 -+C1 f9() { return C1(); }
1328 -+// CHECK: @_Z2f9B6Names1v(
1329 -+
1330 -+inline namespace Names2 __attribute__((__abi_tag__("Tag1", "Tag2"))) {
1331 -+ class C2 {};
1332 -+}
1333 -+C2 f10() { return C2(); }
1334 -+// CHECK: @_Z3f10B4Tag1B4Tag2v(
1335 -+
1336 -+void __attribute__((abi_tag("A"))) f11(A) {}
1337 -+// f11[abi:A](A[abi:A][abi:B])
1338 -+// CHECK: define {{.*}} @_Z3f11B1A1AB1AB1B(
1339 -+
1340 -+A f12(A) { return A(); }
1341 -+// f12(A[abi:A][abi:B])
1342 -+// CHECK: define {{.*}} @_Z3f121AB1AB1B(
1343 -+
1344 -+inline void f13() {
1345 -+ struct L {
1346 -+ static E<int>* foo() {
1347 -+ static A10 a;
1348 -+ return 0;
1349 -+ }
1350 -+ };
1351 -+ L::foo();
1352 -+}
1353 -+void f11_test() {
1354 -+ f13();
1355 -+}
1356 -+// f13()::L::foo[abi:C][abi:D]()
1357 -+// CHECK: define linkonce_odr %struct.E* @_ZZ3f13vEN1L3fooB1CB1DEv(
1358 -diff -Nuar llvm-3.8.0.src.orig/tools/clang/test/SemaCXX/attr-abi-tag-syntax.cpp llvm-3.8.0.src/tools/clang/test/SemaCXX/attr-abi-tag-syntax.cpp
1359 ---- llvm-3.8.0.src.orig/tools/clang/test/SemaCXX/attr-abi-tag-syntax.cpp 2016-07-10 23:56:02.415319061 +0200
1360 -+++ llvm-3.8.0.src/tools/clang/test/SemaCXX/attr-abi-tag-syntax.cpp 2016-07-10 23:59:08.413719568 +0200
1361 -@@ -16,28 +16,18 @@
1362 - // expected-warning@-1 {{'abi_tag' attribute on anonymous namespace ignored}}
1363 -
1364 - inline namespace N __attribute__((__abi_tag__)) {}
1365 --// FIXME: remove this warning as soon as attribute fully supported.
1366 --// expected-warning@-2 {{'__abi_tag__' attribute ignored}}
1367 -
1368 - } // namespcace N2
1369 -
1370 - __attribute__((abi_tag("B", "A"))) extern int a1;
1371 --// FIXME: remove this warning as soon as attribute fully supported.
1372 --// expected-warning@-2 {{'abi_tag' attribute ignored}}
1373 -
1374 - __attribute__((abi_tag("A", "B"))) extern int a1;
1375 - // expected-note@-1 {{previous declaration is here}}
1376 --// FIXME: remove this warning as soon as attribute fully supported.
1377 --// expected-warning@-3 {{'abi_tag' attribute ignored}}
1378 -
1379 - __attribute__((abi_tag("A", "C"))) extern int a1;
1380 - // expected-error@-1 {{'abi_tag' C missing in original declaration}}
1381 --// FIXME: remove this warning as soon as attribute fully supported.
1382 --// expected-warning@-3 {{'abi_tag' attribute ignored}}
1383 -
1384 - extern int a2;
1385 - // expected-note@-1 {{previous declaration is here}}
1386 - __attribute__((abi_tag("A")))extern int a2;
1387 - // expected-error@-1 {{cannot add 'abi_tag' attribute in a redeclaration}}
1388 --// FIXME: remove this warning as soon as attribute fully supported.
1389 --// expected-warning@-3 {{'abi_tag' attribute ignored}}
1390
1391 diff --git a/sys-devel/llvm/files/3.8.1/clang/abi-tag-support-sema.patch b/sys-devel/llvm/files/3.8.1/clang/abi-tag-support-sema.patch
1392 deleted file mode 100644
1393 index 079f685ff33..00000000000
1394 --- a/sys-devel/llvm/files/3.8.1/clang/abi-tag-support-sema.patch
1395 +++ /dev/null
1396 @@ -1,419 +0,0 @@
1397 -diff -Nuar llvm-3.8.0.src.orig/clang/docs/ItaniumMangleAbiTags.rst llvm-3.8.0.src/clang/docs/ItaniumMangleAbiTags.rst
1398 ---- llvm-3.8.0.src.orig/clang/docs/ItaniumMangleAbiTags.rst 1970-01-01 01:00:00.000000000 +0100
1399 -+++ llvm-3.8.0.src/clang/docs/ItaniumMangleAbiTags.rst 2016-07-10 23:54:47.768756996 +0200
1400 -@@ -0,0 +1,101 @@
1401 -+========
1402 -+ABI tags
1403 -+========
1404 -+
1405 -+Introduction
1406 -+============
1407 -+
1408 -+This text tries to describe gcc semantic for mangling "abi_tag" attributes
1409 -+described in https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Attributes.html
1410 -+
1411 -+There is no guarantee the following rules are correct, complete or make sense
1412 -+in any way as they were determined empirically by experiments with gcc5.
1413 -+
1414 -+Declaration
1415 -+===========
1416 -+
1417 -+ABI tags are declared in an abi_tag attribute and can be applied to a
1418 -+function, variable, class or inline namespace declaration. The attribute takes
1419 -+one or more strings (called tags); the order does not matter.
1420 -+
1421 -+See https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Attributes.html for
1422 -+details.
1423 -+
1424 -+Tags on an inline namespace are called "implicit tags", all other tags are
1425 -+"explicit tags".
1426 -+
1427 -+Mangling
1428 -+========
1429 -+
1430 -+All tags that are "active" on an <unqualified-name> are emitted after the
1431 -+<unqualified-name>, before <template-args> or <discriminator>, and are part of
1432 -+the same <substitution> the <unqualified-name> is.
1433 -+
1434 -+They are mangled as:
1435 -+
1436 -+ <abi-tags> ::= <abi-tag>* # sort by name
1437 -+ <abi-tag> ::= B <tag source-name>
1438 -+
1439 -+Example:
1440 -+
1441 -+ __attribute__((abi_tag("test")))
1442 -+ void Func();
1443 -+
1444 -+ gets mangled as: _Z4FuncB4testv (prettified as `Func[abi:test]()`)
1445 -+
1446 -+Active tags
1447 -+===========
1448 -+
1449 -+A namespace does not have any active tags. For types (class / struct / union /
1450 -+enum), the explicit tags are the active tags.
1451 -+
1452 -+For variables and functions, the active tags are the explicit tags plus any
1453 -+"required tags" which are not in the "available tags" set:
1454 -+
1455 -+ derived-tags := (required-tags - available-tags)
1456 -+ active-tags := explicit-tags + derived-tags
1457 -+
1458 -+Required tags for a function
1459 -+============================
1460 -+
1461 -+If a function is used as a local scope for another name, and is part of
1462 -+another function as local scope, it doesn't have any required tags.
1463 -+
1464 -+If a function is used as a local scope for a guard variable name, it doesn't
1465 -+have any required tags.
1466 -+
1467 -+Otherwise the function requires any implicit or explicit tag used in the name
1468 -+for the return type.
1469 -+
1470 -+Example:
1471 -+ namespace A {
1472 -+ inline namespace B __attribute__((abi_tag)) {
1473 -+ struct C { int x; };
1474 -+ }
1475 -+ }
1476 -+
1477 -+ A::C foo();
1478 -+
1479 -+ gets mangled as: _Z3fooB1Bv (prettified as `foo[abi:B]()`)
1480 -+
1481 -+Required tags for a variable
1482 -+============================
1483 -+
1484 -+A variable requires any implicit or explicit tag used in its type.
1485 -+
1486 -+Available tags
1487 -+==============
1488 -+
1489 -+All tags used in the prefix and in the template arguments for a name are
1490 -+available. Also, for functions, all tags from the <bare-function-type>
1491 -+(which might include the return type for template functions) are available.
1492 -+
1493 -+For <local-name>s all active tags used in the local part (<function-
1494 -+encoding>) are available, but not implicit tags which were not active.
1495 -+
1496 -+Implicit and explicit tags used in the <unqualified-name> for a function (as
1497 -+in the type of a cast operator) are NOT available.
1498 -+
1499 -+Example: a cast operator to std::string (which is
1500 -+std::__cxx11::basic_string<...>) will use 'cxx11' as an active tag, as it is
1501 -+required from the return type `std::string` but not available.
1502 -diff -Nuar llvm-3.8.0.src.orig/tools/clang/docs/ItaniumMangleAbiTags.rst llvm-3.8.0.src/tools/clang/docs/ItaniumMangleAbiTags.rst
1503 ---- llvm-3.8.0.src.orig/tools/clang/docs/ItaniumMangleAbiTags.rst 1970-01-01 01:00:00.000000000 +0100
1504 -+++ llvm-3.8.0.src/tools/clang/docs/ItaniumMangleAbiTags.rst 2016-07-10 23:55:02.544868256 +0200
1505 -@@ -0,0 +1,101 @@
1506 -+========
1507 -+ABI tags
1508 -+========
1509 -+
1510 -+Introduction
1511 -+============
1512 -+
1513 -+This text tries to describe gcc semantic for mangling "abi_tag" attributes
1514 -+described in https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Attributes.html
1515 -+
1516 -+There is no guarantee the following rules are correct, complete or make sense
1517 -+in any way as they were determined empirically by experiments with gcc5.
1518 -+
1519 -+Declaration
1520 -+===========
1521 -+
1522 -+ABI tags are declared in an abi_tag attribute and can be applied to a
1523 -+function, variable, class or inline namespace declaration. The attribute takes
1524 -+one or more strings (called tags); the order does not matter.
1525 -+
1526 -+See https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Attributes.html for
1527 -+details.
1528 -+
1529 -+Tags on an inline namespace are called "implicit tags", all other tags are
1530 -+"explicit tags".
1531 -+
1532 -+Mangling
1533 -+========
1534 -+
1535 -+All tags that are "active" on an <unqualified-name> are emitted after the
1536 -+<unqualified-name>, before <template-args> or <discriminator>, and are part of
1537 -+the same <substitution> the <unqualified-name> is.
1538 -+
1539 -+They are mangled as:
1540 -+
1541 -+ <abi-tags> ::= <abi-tag>* # sort by name
1542 -+ <abi-tag> ::= B <tag source-name>
1543 -+
1544 -+Example:
1545 -+
1546 -+ __attribute__((abi_tag("test")))
1547 -+ void Func();
1548 -+
1549 -+ gets mangled as: _Z4FuncB4testv (prettified as `Func[abi:test]()`)
1550 -+
1551 -+Active tags
1552 -+===========
1553 -+
1554 -+A namespace does not have any active tags. For types (class / struct / union /
1555 -+enum), the explicit tags are the active tags.
1556 -+
1557 -+For variables and functions, the active tags are the explicit tags plus any
1558 -+"required tags" which are not in the "available tags" set:
1559 -+
1560 -+ derived-tags := (required-tags - available-tags)
1561 -+ active-tags := explicit-tags + derived-tags
1562 -+
1563 -+Required tags for a function
1564 -+============================
1565 -+
1566 -+If a function is used as a local scope for another name, and is part of
1567 -+another function as local scope, it doesn't have any required tags.
1568 -+
1569 -+If a function is used as a local scope for a guard variable name, it doesn't
1570 -+have any required tags.
1571 -+
1572 -+Otherwise the function requires any implicit or explicit tag used in the name
1573 -+for the return type.
1574 -+
1575 -+Example:
1576 -+ namespace A {
1577 -+ inline namespace B __attribute__((abi_tag)) {
1578 -+ struct C { int x; };
1579 -+ }
1580 -+ }
1581 -+
1582 -+ A::C foo();
1583 -+
1584 -+ gets mangled as: _Z3fooB1Bv (prettified as `foo[abi:B]()`)
1585 -+
1586 -+Required tags for a variable
1587 -+============================
1588 -+
1589 -+A variable requires any implicit or explicit tag used in its type.
1590 -+
1591 -+Available tags
1592 -+==============
1593 -+
1594 -+All tags used in the prefix and in the template arguments for a name are
1595 -+available. Also, for functions, all tags from the <bare-function-type>
1596 -+(which might include the return type for template functions) are available.
1597 -+
1598 -+For <local-name>s all active tags used in the local part (<function-
1599 -+encoding>) are available, but not implicit tags which were not active.
1600 -+
1601 -+Implicit and explicit tags used in the <unqualified-name> for a function (as
1602 -+in the type of a cast operator) are NOT available.
1603 -+
1604 -+Example: a cast operator to std::string (which is
1605 -+std::__cxx11::basic_string<...>) will use 'cxx11' as an active tag, as it is
1606 -+required from the return type `std::string` but not available.
1607 -diff -Nuar llvm-3.8.0.src.orig/tools/clang/include/clang/Basic/AttrDocs.td llvm-3.8.0.src/tools/clang/include/clang/Basic/AttrDocs.td
1608 ---- llvm-3.8.0.src.orig/tools/clang/include/clang/Basic/AttrDocs.td 2015-12-02 22:58:08.000000000 +0100
1609 -+++ llvm-3.8.0.src/tools/clang/include/clang/Basic/AttrDocs.td 2016-07-10 23:55:02.545868263 +0200
1610 -@@ -1859,3 +1859,16 @@
1611 -
1612 - }];
1613 - }
1614 -+
1615 -+def AbiTagsDocs : Documentation {
1616 -+ let Content = [{
1617 -+The ``abi_tag`` attribute can be applied to a function, variable, class or
1618 -+inline namespace declaration to modify the mangled name of the entity. It gives
1619 -+the ability to distinguish between different versions of the same entity but
1620 -+with different ABI versions supported. For example, a newer version of a class
1621 -+could have a different set of data members and thus have a different size. Using
1622 -+the ``abi_tag`` attribute, it is possible to have different mangled names for
1623 -+a global variable of the class type. Therefor, the old code could keep using
1624 -+the old manged name and the new code will use the new mangled name with tags.
1625 -+ }];
1626 -+}
1627 -diff -Nuar llvm-3.8.0.src.orig/tools/clang/include/clang/Basic/Attr.td llvm-3.8.0.src/tools/clang/include/clang/Basic/Attr.td
1628 ---- llvm-3.8.0.src.orig/tools/clang/include/clang/Basic/Attr.td 2015-12-02 22:58:08.000000000 +0100
1629 -+++ llvm-3.8.0.src/tools/clang/include/clang/Basic/Attr.td 2016-07-10 23:55:02.544868256 +0200
1630 -@@ -349,6 +349,14 @@
1631 - // Attributes begin here
1632 - //
1633 -
1634 -+def AbiTag : Attr {
1635 -+ let Spellings = [GCC<"abi_tag">];
1636 -+ let Args = [VariadicStringArgument<"Tags">];
1637 -+ let Subjects = SubjectList<[Struct, Var, Function, Namespace], ErrorDiag,
1638 -+ "ExpectedStructClassVariableFunctionOrInlineNamespace">;
1639 -+ let Documentation = [AbiTagsDocs];
1640 -+}
1641 -+
1642 - def AddressSpace : TypeAttr {
1643 - let Spellings = [GNU<"address_space">];
1644 - let Args = [IntArgument<"AddressSpace">];
1645 -diff -Nuar llvm-3.8.0.src.orig/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td llvm-3.8.0.src/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td
1646 ---- llvm-3.8.0.src.orig/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td 2016-01-09 13:53:17.000000000 +0100
1647 -+++ llvm-3.8.0.src/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td 2016-07-10 23:55:02.547868278 +0200
1648 -@@ -2434,7 +2434,8 @@
1649 - "Objective-C instance methods|init methods of interface or class extension declarations|"
1650 - "variables, functions and classes|Objective-C protocols|"
1651 - "functions and global variables|structs, unions, and typedefs|structs and typedefs|"
1652 -- "interface or protocol declarations|kernel functions|non-K&R-style functions}1">,
1653 -+ "interface or protocol declarations|kernel functions|non-K&R-style functions|"
1654 -+ "structs, classes, variables, functions, and inline namespaces}1">,
1655 - InGroup<IgnoredAttributes>;
1656 - def err_attribute_wrong_decl_type : Error<warn_attribute_wrong_decl_type.Text>;
1657 - def warn_type_attribute_wrong_type : Warning<
1658 -@@ -4144,6 +4145,13 @@
1659 - def err_redefinition_extern_inline : Error<
1660 - "redefinition of a 'extern inline' function %0 is not supported in "
1661 - "%select{C99 mode|C++}1">;
1662 -+def warn_attr_abi_tag_namespace : Warning<
1663 -+ "'abi_tag' attribute on %select{non-inline|anonymous}0 namespace ignored">,
1664 -+ InGroup<IgnoredAttributes>;
1665 -+def err_abi_tag_on_redeclaration : Error<
1666 -+ "cannot add 'abi_tag' attribute in a redeclaration">;
1667 -+def err_new_abi_tag_on_redeclaration : Error<
1668 -+ "'abi_tag' %0 missing in original declaration">;
1669 -
1670 - def note_deleted_dtor_no_operator_delete : Note<
1671 - "virtual destructor requires an unambiguous, accessible 'operator delete'">;
1672 -diff -Nuar llvm-3.8.0.src.orig/tools/clang/include/clang/Sema/AttributeList.h llvm-3.8.0.src/tools/clang/include/clang/Sema/AttributeList.h
1673 ---- llvm-3.8.0.src.orig/tools/clang/include/clang/Sema/AttributeList.h 2015-12-02 18:07:30.000000000 +0100
1674 -+++ llvm-3.8.0.src/tools/clang/include/clang/Sema/AttributeList.h 2016-07-10 23:55:02.548868286 +0200
1675 -@@ -855,7 +855,8 @@
1676 - ExpectedStructOrTypedef,
1677 - ExpectedObjectiveCInterfaceOrProtocol,
1678 - ExpectedKernelFunction,
1679 -- ExpectedFunctionWithProtoType
1680 -+ ExpectedFunctionWithProtoType,
1681 -+ ExpectedStructClassVariableFunctionOrInlineNamespace
1682 - };
1683 -
1684 - } // end namespace clang
1685 -diff -Nuar llvm-3.8.0.src.orig/tools/clang/lib/Sema/SemaDeclAttr.cpp llvm-3.8.0.src/tools/clang/lib/Sema/SemaDeclAttr.cpp
1686 ---- llvm-3.8.0.src.orig/tools/clang/lib/Sema/SemaDeclAttr.cpp 2016-01-13 02:07:35.000000000 +0100
1687 -+++ llvm-3.8.0.src/tools/clang/lib/Sema/SemaDeclAttr.cpp 2016-07-10 23:55:02.552868316 +0200
1688 -@@ -4446,6 +4446,42 @@
1689 - Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
1690 - }
1691 -
1692 -+static void handleAbiTagAttr(Sema &S, Decl *D, const AttributeList &Attr) {
1693 -+ SmallVector<std::string, 4> Tags;
1694 -+ for (unsigned I = 0, E = Attr.getNumArgs(); I != E; ++I) {
1695 -+ StringRef Tag;
1696 -+ if (!S.checkStringLiteralArgumentAttr(Attr, I, Tag))
1697 -+ return;
1698 -+ Tags.push_back(Tag);
1699 -+ }
1700 -+
1701 -+ if (const auto *NS = dyn_cast<NamespaceDecl>(D)) {
1702 -+ if (!NS->isInline()) {
1703 -+ S.Diag(Attr.getLoc(), diag::warn_attr_abi_tag_namespace) << 0;
1704 -+ return;
1705 -+ }
1706 -+ if (NS->isAnonymousNamespace()) {
1707 -+ S.Diag(Attr.getLoc(), diag::warn_attr_abi_tag_namespace) << 1;
1708 -+ return;
1709 -+ }
1710 -+ if (Attr.getNumArgs() == 0)
1711 -+ Tags.push_back(NS->getName());
1712 -+ } else if (!checkAttributeAtLeastNumArgs(S, Attr, 1))
1713 -+ return;
1714 -+
1715 -+ // Store tags sorted and without duplicates.
1716 -+ std::sort(Tags.begin(), Tags.end());
1717 -+ Tags.erase(std::unique(Tags.begin(), Tags.end()), Tags.end());
1718 -+
1719 -+ D->addAttr(::new (S.Context)
1720 -+ AbiTagAttr(Attr.getRange(), S.Context, Tags.data(), Tags.size(),
1721 -+ Attr.getAttributeSpellingListIndex()));
1722 -+
1723 -+ // FIXME: remove this warning as soon as mangled part is ready.
1724 -+ S.Diag(Attr.getRange().getBegin(), diag::warn_attribute_ignored)
1725 -+ << Attr.getName();
1726 -+}
1727 -+
1728 - static void handleARMInterruptAttr(Sema &S, Decl *D,
1729 - const AttributeList &Attr) {
1730 - // Check the attribute arguments.
1731 -@@ -5360,6 +5396,9 @@
1732 - case AttributeList::AT_Thread:
1733 - handleDeclspecThreadAttr(S, D, Attr);
1734 - break;
1735 -+ case AttributeList::AT_AbiTag:
1736 -+ handleAbiTagAttr(S, D, Attr);
1737 -+ break;
1738 -
1739 - // Thread safety attributes:
1740 - case AttributeList::AT_AssertExclusiveLock:
1741 -diff -Nuar llvm-3.8.0.src.orig/tools/clang/lib/Sema/SemaDecl.cpp llvm-3.8.0.src/tools/clang/lib/Sema/SemaDecl.cpp
1742 ---- llvm-3.8.0.src.orig/tools/clang/lib/Sema/SemaDecl.cpp 2016-01-11 23:41:53.000000000 +0100
1743 -+++ llvm-3.8.0.src/tools/clang/lib/Sema/SemaDecl.cpp 2016-07-10 23:55:02.551868308 +0200
1744 -@@ -2396,6 +2396,24 @@
1745 - }
1746 - }
1747 -
1748 -+ // Re-declaration cannot add abi_tag's.
1749 -+ if (const auto *NewAbiTagAttr = New->getAttr<AbiTagAttr>()) {
1750 -+ if (const auto *OldAbiTagAttr = Old->getAttr<AbiTagAttr>()) {
1751 -+ for (const auto &NewTag : NewAbiTagAttr->tags()) {
1752 -+ if (std::find(OldAbiTagAttr->tags_begin(), OldAbiTagAttr->tags_end(),
1753 -+ NewTag) == OldAbiTagAttr->tags_end()) {
1754 -+ Diag(NewAbiTagAttr->getLocation(),
1755 -+ diag::err_new_abi_tag_on_redeclaration)
1756 -+ << NewTag;
1757 -+ Diag(OldAbiTagAttr->getLocation(), diag::note_previous_declaration);
1758 -+ }
1759 -+ }
1760 -+ } else {
1761 -+ Diag(NewAbiTagAttr->getLocation(), diag::err_abi_tag_on_redeclaration);
1762 -+ Diag(Old->getLocation(), diag::note_previous_declaration);
1763 -+ }
1764 -+ }
1765 -+
1766 - if (!Old->hasAttrs())
1767 - return;
1768 -
1769 -diff -Nuar llvm-3.8.0.src.orig/tools/clang/test/SemaCXX/attr-abi-tag-syntax.cpp llvm-3.8.0.src/tools/clang/test/SemaCXX/attr-abi-tag-syntax.cpp
1770 ---- llvm-3.8.0.src.orig/tools/clang/test/SemaCXX/attr-abi-tag-syntax.cpp 1970-01-01 01:00:00.000000000 +0100
1771 -+++ llvm-3.8.0.src/tools/clang/test/SemaCXX/attr-abi-tag-syntax.cpp 2016-07-10 23:55:02.552868316 +0200
1772 -@@ -0,0 +1,43 @@
1773 -+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
1774 -+
1775 -+namespace N1 {
1776 -+
1777 -+namespace __attribute__((__abi_tag__)) {}
1778 -+// expected-warning@-1 {{'abi_tag' attribute on non-inline namespace ignored}}
1779 -+
1780 -+namespace N __attribute__((__abi_tag__)) {}
1781 -+// expected-warning@-1 {{'abi_tag' attribute on non-inline namespace ignored}}
1782 -+
1783 -+} // namespace N1
1784 -+
1785 -+namespace N2 {
1786 -+
1787 -+inline namespace __attribute__((__abi_tag__)) {}
1788 -+// expected-warning@-1 {{'abi_tag' attribute on anonymous namespace ignored}}
1789 -+
1790 -+inline namespace N __attribute__((__abi_tag__)) {}
1791 -+// FIXME: remove this warning as soon as attribute fully supported.
1792 -+// expected-warning@-2 {{'__abi_tag__' attribute ignored}}
1793 -+
1794 -+} // namespcace N2
1795 -+
1796 -+__attribute__((abi_tag("B", "A"))) extern int a1;
1797 -+// FIXME: remove this warning as soon as attribute fully supported.
1798 -+// expected-warning@-2 {{'abi_tag' attribute ignored}}
1799 -+
1800 -+__attribute__((abi_tag("A", "B"))) extern int a1;
1801 -+// expected-note@-1 {{previous declaration is here}}
1802 -+// FIXME: remove this warning as soon as attribute fully supported.
1803 -+// expected-warning@-3 {{'abi_tag' attribute ignored}}
1804 -+
1805 -+__attribute__((abi_tag("A", "C"))) extern int a1;
1806 -+// expected-error@-1 {{'abi_tag' C missing in original declaration}}
1807 -+// FIXME: remove this warning as soon as attribute fully supported.
1808 -+// expected-warning@-3 {{'abi_tag' attribute ignored}}
1809 -+
1810 -+extern int a2;
1811 -+// expected-note@-1 {{previous declaration is here}}
1812 -+__attribute__((abi_tag("A")))extern int a2;
1813 -+// expected-error@-1 {{cannot add 'abi_tag' attribute in a redeclaration}}
1814 -+// FIXME: remove this warning as soon as attribute fully supported.
1815 -+// expected-warning@-3 {{'abi_tag' attribute ignored}}
1816
1817 diff --git a/sys-devel/llvm/files/3.8.1/clang/default-libs.patch b/sys-devel/llvm/files/3.8.1/clang/default-libs.patch
1818 deleted file mode 100644
1819 index 8d172f74689..00000000000
1820 --- a/sys-devel/llvm/files/3.8.1/clang/default-libs.patch
1821 +++ /dev/null
1822 @@ -1,106 +0,0 @@
1823 -diff --git a/CMakeLists.txt b/CMakeLists.txt
1824 -index ad2ac42..18dcfbe 100644
1825 ---- a/CMakeLists.txt
1826 -+++ b/CMakeLists.txt
1827 -@@ -196,6 +196,24 @@ set(GCC_INSTALL_PREFIX "" CACHE PATH "Directory where gcc is installed." )
1828 - set(DEFAULT_SYSROOT "" CACHE PATH
1829 - "Default <path> to all compiler invocations for --sysroot=<path>." )
1830 -
1831 -+set(CLANG_DEFAULT_CXX_STDLIB "" CACHE STRING
1832 -+ "Default C++ stdlib to use (libstdc++ or libc++)")
1833 -+if (NOT(CLANG_DEFAULT_CXX_STDLIB STREQUAL "" OR
1834 -+ CLANG_DEFAULT_CXX_STDLIB STREQUAL "libstdc++" OR
1835 -+ CLANG_DEFAULT_CXX_STDLIB STREQUAL "libc++"))
1836 -+ message(WARNING "Resetting default C++ stdlib to use platform default")
1837 -+ set(CLANG_DEFAULT_CXX_STDLIB "")
1838 -+endif()
1839 -+
1840 -+set(CLANG_DEFAULT_RTLIB "" CACHE STRING
1841 -+ "Default runtime library to use (libgcc or compiler-rt)")
1842 -+if (NOT(CLANG_DEFAULT_RTLIB STREQUAL "" OR
1843 -+ CLANG_DEFAULT_RTLIB STREQUAL "libgcc" OR
1844 -+ CLANG_DEFAULT_RTLIB STREQUAL "compiler-rt"))
1845 -+ message(WARNING "Resetting default rtlib to use platform default")
1846 -+ set(CLANG_DEFAULT_RTLIB "")
1847 -+endif()
1848 -+
1849 - set(CLANG_DEFAULT_OPENMP_RUNTIME "libomp" CACHE STRING
1850 - "Default OpenMP runtime used by -fopenmp.")
1851 -
1852 -diff --git a/include/clang/Config/config.h.cmake b/include/clang/Config/config.h.cmake
1853 -index b7486f3..eb8aa27 100644
1854 ---- a/include/clang/Config/config.h.cmake
1855 -+++ b/include/clang/Config/config.h.cmake
1856 -@@ -8,6 +8,12 @@
1857 - /* Bug report URL. */
1858 - #define BUG_REPORT_URL "${BUG_REPORT_URL}"
1859 -
1860 -+/* Default C++ stdlib to use. */
1861 -+#define CLANG_DEFAULT_CXX_STDLIB "${CLANG_DEFAULT_CXX_STDLIB}"
1862 -+
1863 -+/* Default runtime library to use. */
1864 -+#define CLANG_DEFAULT_RTLIB "${CLANG_DEFAULT_RTLIB}"
1865 -+
1866 - /* Default OpenMP runtime used by -fopenmp. */
1867 - #define CLANG_DEFAULT_OPENMP_RUNTIME "${CLANG_DEFAULT_OPENMP_RUNTIME}"
1868 -
1869 -diff --git a/lib/Driver/ToolChain.cpp b/lib/Driver/ToolChain.cpp
1870 -index cbbd485..3af7f8a 100644
1871 ---- a/lib/Driver/ToolChain.cpp
1872 -+++ b/lib/Driver/ToolChain.cpp
1873 -@@ -9,6 +9,7 @@
1874 -
1875 - #include "Tools.h"
1876 - #include "clang/Basic/ObjCRuntime.h"
1877 -+#include "clang/Config/config.h"
1878 - #include "clang/Driver/Action.h"
1879 - #include "clang/Driver/Driver.h"
1880 - #include "clang/Driver/DriverDiagnostic.h"
1881 -@@ -520,29 +521,29 @@ void ToolChain::addProfileRTLibs(const llvm::opt::ArgList &Args,
1882 -
1883 - ToolChain::RuntimeLibType ToolChain::GetRuntimeLibType(
1884 - const ArgList &Args) const {
1885 -- if (Arg *A = Args.getLastArg(options::OPT_rtlib_EQ)) {
1886 -- StringRef Value = A->getValue();
1887 -- if (Value == "compiler-rt")
1888 -- return ToolChain::RLT_CompilerRT;
1889 -- if (Value == "libgcc")
1890 -- return ToolChain::RLT_Libgcc;
1891 -- getDriver().Diag(diag::err_drv_invalid_rtlib_name)
1892 -- << A->getAsString(Args);
1893 -- }
1894 -+ const Arg* A = Args.getLastArg(options::OPT_rtlib_EQ);
1895 -+ StringRef LibName = A ? A->getValue() : CLANG_DEFAULT_RTLIB;
1896 -+
1897 -+ if (LibName == "compiler-rt")
1898 -+ return ToolChain::RLT_CompilerRT;
1899 -+ if (LibName == "libgcc")
1900 -+ return ToolChain::RLT_Libgcc;
1901 -+ if (A)
1902 -+ getDriver().Diag(diag::err_drv_invalid_rtlib_name) << A->getAsString(Args);
1903 -
1904 - return GetDefaultRuntimeLibType();
1905 - }
1906 -
1907 - ToolChain::CXXStdlibType ToolChain::GetCXXStdlibType(const ArgList &Args) const{
1908 -- if (Arg *A = Args.getLastArg(options::OPT_stdlib_EQ)) {
1909 -- StringRef Value = A->getValue();
1910 -- if (Value == "libc++")
1911 -- return ToolChain::CST_Libcxx;
1912 -- if (Value == "libstdc++")
1913 -- return ToolChain::CST_Libstdcxx;
1914 -- getDriver().Diag(diag::err_drv_invalid_stdlib_name)
1915 -- << A->getAsString(Args);
1916 -- }
1917 -+ const Arg* A = Args.getLastArg(options::OPT_stdlib_EQ);
1918 -+ StringRef LibName = A ? A->getValue() : CLANG_DEFAULT_CXX_STDLIB;
1919 -+
1920 -+ if (LibName == "libc++")
1921 -+ return ToolChain::CST_Libcxx;
1922 -+ if (LibName == "libstdc++")
1923 -+ return ToolChain::CST_Libstdcxx;
1924 -+ if (A)
1925 -+ getDriver().Diag(diag::err_drv_invalid_stdlib_name) << A->getAsString(Args);
1926 -
1927 - return ToolChain::CST_Libstdcxx;
1928 - }
1929
1930 diff --git a/sys-devel/llvm/files/3.8.1/clang/gcc4.9-search-path.patch b/sys-devel/llvm/files/3.8.1/clang/gcc4.9-search-path.patch
1931 deleted file mode 100644
1932 index bafe218ceba..00000000000
1933 --- a/sys-devel/llvm/files/3.8.1/clang/gcc4.9-search-path.patch
1934 +++ /dev/null
1935 @@ -1,70 +0,0 @@
1936 -From af4db76e059c1a3f4a7f437001051ccebc8a50fe Mon Sep 17 00:00:00 2001
1937 -From: Chandler Carruth <chandlerc@×××××.com>
1938 -Date: Sun, 8 May 2016 07:59:56 +0000
1939 -Subject: [PATCH] Teach header search about GCC 4.9 header search paths in
1940 - Gentoo, they now use the full GCC version in their weird suffix.
1941 -
1942 -git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@268874 91177308-0d34-0410-b5e6-96231b3b80d8
1943 ----
1944 - lib/Driver/ToolChains.cpp | 1 +
1945 - .../Inputs/gentoo_linux_gcc_4.9.3_tree/usr/include/.keep | 0
1946 - .../usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/crtbegin.o | 0
1947 - .../x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3/.keep | 0
1948 - .../usr/x86_64-pc-linux-gnu/lib/.keep | 0
1949 - test/Driver/linux-header-search.cpp | 15 +++++++++++++++
1950 - 6 files changed, 16 insertions(+)
1951 - create mode 100644 test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/include/.keep
1952 - create mode 100644 test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/crtbegin.o
1953 - create mode 100644 test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3/.keep
1954 - create mode 100644 test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/x86_64-pc-linux-gnu/lib/.keep
1955 -
1956 -diff --git a/tools/clang/lib/Driver/ToolChains.cpp b/tools/clang/lib/Driver/ToolChains.cpp
1957 -index f905b5d..1bf17e4 100644
1958 ---- a/tools/clang/lib/Driver/ToolChains.cpp
1959 -+++ b/tools/clang/lib/Driver/ToolChains.cpp
1960 -@@ -4134,6 +4134,7 @@ void Linux::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
1961 - const std::string LibStdCXXIncludePathCandidates[] = {
1962 - // Gentoo is weird and places its headers inside the GCC install,
1963 - // so if the first attempt to find the headers fails, try these patterns.
1964 -+ InstallDir.str() + "/include/g++-v" + Version.Text,
1965 - InstallDir.str() + "/include/g++-v" + Version.MajorStr + "." +
1966 - Version.MinorStr,
1967 - InstallDir.str() + "/include/g++-v" + Version.MajorStr,
1968 -diff --git a/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/include/.keep b/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/include/.keep
1969 -new file mode 100644
1970 -index 0000000..e69de29
1971 -diff --git a/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/crtbegin.o b/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/crtbegin.o
1972 -new file mode 100644
1973 -index 0000000..e69de29
1974 -diff --git a/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3/.keep b/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3/.keep
1975 -new file mode 100644
1976 -index 0000000..e69de29
1977 -diff --git a/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/x86_64-pc-linux-gnu/lib/.keep b/tools/clang/test/Driver/Inputs/gentoo_linux_gcc_4.9.3_tree/usr/x86_64-pc-linux-gnu/lib/.keep
1978 -new file mode 100644
1979 -index 0000000..e69de29
1980 -diff --git a/tools/clang/test/Driver/linux-header-search.cpp b/tools/clang/test/Driver/linux-header-search.cpp
1981 -index 9568bde..5f6ac50 100644
1982 ---- a/tools/clang/test/Driver/linux-header-search.cpp
1983 -+++ b/tools/clang/test/Driver/linux-header-search.cpp
1984 -@@ -285,6 +285,21 @@
1985 - // CHECK-GENTOO-4-6-4: "-internal-isystem" "[[RESOURCE_DIR]]{{/|\\\\}}include"
1986 - // CHECK-GENTOO-4-6-4: "-internal-externc-isystem" "[[SYSROOT]]/include"
1987 - // CHECK-GENTOO-4-6-4: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
1988 -+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
1989 -+// RUN: -target x86_64-unknown-linux-gnu -stdlib=libstdc++ \
1990 -+// RUN: --sysroot=%S/Inputs/gentoo_linux_gcc_4.9.3_tree \
1991 -+// RUN: --gcc-toolchain="" \
1992 -+// RUN: | FileCheck --check-prefix=CHECK-GENTOO-4-9-3 %s
1993 -+// CHECK-GENTOO-4-9-3: "{{.*}}clang{{.*}}" "-cc1"
1994 -+// CHECK-GENTOO-4-9-3: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
1995 -+// CHECK-GENTOO-4-9-3: "-isysroot" "[[SYSROOT:[^"]+]]"
1996 -+// CHECK-GENTOO-4-9-3: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3"
1997 -+// CHECK-GENTOO-4-9-3: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3/x86_64-pc-linux-gnu"
1998 -+// CHECK-GENTOO-4-9-3: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3/backward"
1999 -+// CHECK-GENTOO-4-9-3: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
2000 -+// CHECK-GENTOO-4-9-3: "-internal-isystem" "[[RESOURCE_DIR]]{{/|\\\\}}include"
2001 -+// CHECK-GENTOO-4-9-3: "-internal-externc-isystem" "[[SYSROOT]]/include"
2002 -+// CHECK-GENTOO-4-9-3: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
2003 - //
2004 - // Check header search on Debian 6 / MIPS64
2005 - // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
2006
2007 diff --git a/sys-devel/llvm/files/3.8.1/clang/gentoo-runtime-gcc-detection-v3.patch b/sys-devel/llvm/files/3.8.1/clang/gentoo-runtime-gcc-detection-v3.patch
2008 deleted file mode 100644
2009 index 1f81af0b7ff..00000000000
2010 --- a/sys-devel/llvm/files/3.8.1/clang/gentoo-runtime-gcc-detection-v3.patch
2011 +++ /dev/null
2012 @@ -1,42 +0,0 @@
2013 -From 916572e1243633ddf913c8f32771a3a7f70fd853 Mon Sep 17 00:00:00 2001
2014 -From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@g.o>
2015 -Date: Fri, 5 Sep 2014 16:49:35 +0200
2016 -Subject: [PATCH] Support obtaining active toolchain from gcc-config.
2017 -
2018 ----
2019 - tools/clang/lib/Driver/ToolChains.cpp | 19 +++++++++++++++++++
2020 - 1 file changed, 19 insertions(+)
2021 -
2022 -diff --git a/tools/clang/lib/Driver/ToolChains.cpp b/tools/clang/lib/Driver/ToolChains.cpp
2023 -index b46f69d..2d4374d 100644
2024 ---- a/tools/clang/lib/Driver/ToolChains.cpp
2025 -+++ b/tools/clang/lib/Driver/ToolChains.cpp
2026 -@@ -1253,6 +1253,25 @@ Generic_GCC::GCCInstallationDetector::init(
2027 - Prefixes.push_back("/usr");
2028 - }
2029 -
2030 -+ for (unsigned k = 0, ke = CandidateTripleAliases.size(); k < ke; ++k) {
2031 -+ llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> File =
2032 -+ llvm::MemoryBuffer::getFile(D.SysRoot + "/etc/env.d/gcc/config-" + CandidateTripleAliases[k].str());
2033 -+ if (File)
2034 -+ {
2035 -+ const std::string VersionText = File.get()->getBuffer().rsplit('-').second.substr(0,5).str();
2036 -+ const std::string GentooPath = D.SysRoot + "/usr/lib/gcc/" + CandidateTripleAliases[k].str() + "/" + VersionText;
2037 -+ if (llvm::sys::fs::exists(GentooPath + "/crtbegin.o"))
2038 -+ {
2039 -+ Version = GCCVersion::Parse(VersionText);
2040 -+ GCCInstallPath = GentooPath;
2041 -+ GCCParentLibPath = GCCInstallPath + "/../../..";
2042 -+ GCCTriple.setTriple(CandidateTripleAliases[k]);
2043 -+ IsValid = true;
2044 -+ return;
2045 -+ }
2046 -+ }
2047 -+ }
2048 -+
2049 - // Loop over the various components which exist and select the best GCC
2050 - // installation available. GCC installs are ranked by version number.
2051 - Version = GCCVersion::Parse("0.0.0");
2052 ---
2053 -2.1.0
2054 -
2055
2056 diff --git a/sys-devel/llvm/files/3.8.1/clang/musl-support.patch b/sys-devel/llvm/files/3.8.1/clang/musl-support.patch
2057 deleted file mode 100644
2058 index 8a234e6277a..00000000000
2059 --- a/sys-devel/llvm/files/3.8.1/clang/musl-support.patch
2060 +++ /dev/null
2061 @@ -1,108 +0,0 @@
2062 -diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp
2063 -index 9c6eaff..92872ab 100644
2064 ---- a/lib/Basic/Targets.cpp
2065 -+++ b/lib/Basic/Targets.cpp
2066 -@@ -4513,6 +4513,8 @@ public:
2067 - case llvm::Triple::Android:
2068 - case llvm::Triple::GNUEABI:
2069 - case llvm::Triple::GNUEABIHF:
2070 -+ case llvm::Triple::MuslEABI:
2071 -+ case llvm::Triple::MuslEABIHF:
2072 - setABI("aapcs-linux");
2073 - break;
2074 - case llvm::Triple::EABIHF:
2075 -diff --git a/lib/CodeGen/TargetInfo.cpp b/lib/CodeGen/TargetInfo.cpp
2076 -index 04edc0c..298b2cc 100644
2077 ---- a/lib/CodeGen/TargetInfo.cpp
2078 -+++ b/lib/CodeGen/TargetInfo.cpp
2079 -@@ -4811,6 +4811,8 @@ public:
2080 - case llvm::Triple::EABIHF:
2081 - case llvm::Triple::GNUEABI:
2082 - case llvm::Triple::GNUEABIHF:
2083 -+ case llvm::Triple::MuslEABI:
2084 -+ case llvm::Triple::MuslEABIHF:
2085 - return true;
2086 - default:
2087 - return false;
2088 -@@ -4821,6 +4823,7 @@ public:
2089 - switch (getTarget().getTriple().getEnvironment()) {
2090 - case llvm::Triple::EABIHF:
2091 - case llvm::Triple::GNUEABIHF:
2092 -+ case llvm::Triple::MuslEABIHF:
2093 - return true;
2094 - default:
2095 - return false;
2096 -@@ -7548,7 +7551,8 @@ const TargetCodeGenInfo &CodeGenModule::getTargetCodeGenInfo() {
2097 - Kind = ARMABIInfo::AAPCS16_VFP;
2098 - else if (CodeGenOpts.FloatABI == "hard" ||
2099 - (CodeGenOpts.FloatABI != "soft" &&
2100 -- Triple.getEnvironment() == llvm::Triple::GNUEABIHF))
2101 -+ (Triple.getEnvironment() == llvm::Triple::GNUEABIHF ||
2102 -+ Triple.getEnvironment() == llvm::Triple::MuslEABIHF)))
2103 - Kind = ARMABIInfo::AAPCS_VFP;
2104 -
2105 - return *(TheTargetCodeGenInfo = new ARMTargetCodeGenInfo(Types, Kind));
2106 -diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
2107 -index b7ac24f..2a529fb 100644
2108 ---- a/lib/Driver/Tools.cpp
2109 -+++ b/lib/Driver/Tools.cpp
2110 -@@ -724,13 +724,19 @@ arm::FloatABI arm::getARMFloatABI(const ToolChain &TC, const ArgList &Args) {
2111 - default:
2112 - switch (Triple.getEnvironment()) {
2113 - case llvm::Triple::GNUEABIHF:
2114 -+ case llvm::Triple::MuslEABIHF:
2115 - case llvm::Triple::EABIHF:
2116 - ABI = FloatABI::Hard;
2117 - break;
2118 - case llvm::Triple::GNUEABI:
2119 -+ case llvm::Triple::MuslEABI:
2120 - case llvm::Triple::EABI:
2121 - // EABI is always AAPCS, and if it was not marked 'hard', it's softfp
2122 -- ABI = FloatABI::SoftFP;
2123 -+ //
2124 -+ // Also consider triples like armv7a-hardfloat-linux-eabi, where 'hard'
2125 -+ // is marked in the vender field.
2126 -+ ABI = (Triple.getVendorName() == "hardfloat") ?
2127 -+ FloatABI::Hard : FloatABI::SoftFP;
2128 - break;
2129 - case llvm::Triple::Android:
2130 - ABI = (SubArch == 7) ? FloatABI::SoftFP : FloatABI::Soft;
2131 -@@ -968,6 +974,8 @@ void Clang::AddARMTargetArgs(const llvm::Triple &Triple, const ArgList &Args,
2132 - case llvm::Triple::Android:
2133 - case llvm::Triple::GNUEABI:
2134 - case llvm::Triple::GNUEABIHF:
2135 -+ case llvm::Triple::MuslEABI:
2136 -+ case llvm::Triple::MuslEABIHF:
2137 - ABIName = "aapcs-linux";
2138 - break;
2139 - case llvm::Triple::EABIHF:
2140 -@@ -8632,6 +8640,29 @@ static std::string getLinuxDynamicLinker(const ArgList &Args,
2141 - return "/system/bin/linker64";
2142 - else
2143 - return "/system/bin/linker";
2144 -+ } else if (ToolChain.getTriple().isMusl()) {
2145 -+ std::string ArchName;
2146 -+ bool IsArm = false;
2147 -+ switch (Arch) {
2148 -+ case llvm::Triple::arm:
2149 -+ case llvm::Triple::thumb:
2150 -+ ArchName = "arm";
2151 -+ IsArm = true;
2152 -+ break;
2153 -+ case llvm::Triple::armeb:
2154 -+ case llvm::Triple::thumbeb:
2155 -+ ArchName = "armeb";
2156 -+ IsArm = true;
2157 -+ break;
2158 -+ default:
2159 -+ ArchName = ToolChain.getTriple().getArchName().str();
2160 -+ }
2161 -+ if (IsArm &&
2162 -+ (ToolChain.getTriple().getEnvironment() == llvm::Triple::MuslEABIHF ||
2163 -+ arm::getARMFloatABI(ToolChain, Args) == arm::FloatABI::Hard))
2164 -+ ArchName += "hf";
2165 -+
2166 -+ return "/lib/ld-musl-" + ArchName + ".so.1";
2167 - } else if (Arch == llvm::Triple::x86 || Arch == llvm::Triple::sparc ||
2168 - Arch == llvm::Triple::sparcel)
2169 - return "/lib/ld-linux.so.2";
2170
2171 diff --git a/sys-devel/llvm/files/3.8.1/compiler-rt/0001-cmake-Install-compiler-rt-into-usr-lib-without-suffi.patch b/sys-devel/llvm/files/3.8.1/compiler-rt/0001-cmake-Install-compiler-rt-into-usr-lib-without-suffi.patch
2172 deleted file mode 100644
2173 index 93538009d29..00000000000
2174 --- a/sys-devel/llvm/files/3.8.1/compiler-rt/0001-cmake-Install-compiler-rt-into-usr-lib-without-suffi.patch
2175 +++ /dev/null
2176 @@ -1,25 +0,0 @@
2177 -From 8bd62a681744d3c31a0837c0f84f99ea4987e017 Mon Sep 17 00:00:00 2001
2178 -From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@g.o>
2179 -Date: Tue, 9 Jun 2015 12:17:57 +0200
2180 -Subject: [PATCH] cmake: Install compiler-rt into /usr/lib (without suffix)
2181 -
2182 ----
2183 - CMakeLists.txt | 2 +-
2184 - 1 file changed, 1 insertion(+), 1 deletion(-)
2185 -
2186 -diff --git a/CMakeLists.txt b/CMakeLists.txt
2187 -index 0d8a880..5ae98a9 100644
2188 ---- a/projects/compiler-rt/CMakeLists.txt
2189 -+++ b/projects/compiler-rt/CMakeLists.txt
2190 -@@ -52,7 +52,7 @@ if (NOT COMPILER_RT_STANDALONE_BUILD)
2191 - # Setup the paths where compiler-rt runtimes and headers should be stored.
2192 - set(COMPILER_RT_OUTPUT_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION})
2193 - set(COMPILER_RT_EXEC_OUTPUT_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
2194 -- set(COMPILER_RT_INSTALL_PATH lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION})
2195 -+ set(COMPILER_RT_INSTALL_PATH lib/clang/${CLANG_VERSION})
2196 - option(COMPILER_RT_INCLUDE_TESTS "Generate and build compiler-rt unit tests."
2197 - ${LLVM_INCLUDE_TESTS})
2198 - option(COMPILER_RT_ENABLE_WERROR "Fail and stop if warning is triggered"
2199 ---
2200 -2.4.3
2201 -
2202
2203 diff --git a/sys-devel/llvm/files/3.8.1/compiler-rt/arm_march_flags.patch b/sys-devel/llvm/files/3.8.1/compiler-rt/arm_march_flags.patch
2204 deleted file mode 100644
2205 index d82236e85fe..00000000000
2206 --- a/sys-devel/llvm/files/3.8.1/compiler-rt/arm_march_flags.patch
2207 +++ /dev/null
2208 @@ -1,17 +0,0 @@
2209 -diff -Naur llvm-3.8.0rc1.src.orig/projects/compiler-rt/cmake/config-ix.cmake llvm-3.8.0rc1.src/projects/compiler-rt/cmake/config-ix.cmake
2210 ---- llvm-3.8.0rc1.src.orig/projects/compiler-rt/cmake/config-ix.cmake 2016-01-13 17:56:15.000000000 +0100
2211 -+++ llvm-3.8.0rc1.src/projects/compiler-rt/cmake/config-ix.cmake 2016-01-27 19:43:21.265315207 +0100
2212 -@@ -219,13 +219,6 @@
2213 - elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "mips")
2214 - test_target_arch(mips "" "-mips32r2" "--target=mips-linux-gnu")
2215 - test_target_arch(mips64 "" "-mips64r2" "--target=mips64-linux-gnu" "-mabi=n64")
2216 -- elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "arm")
2217 -- test_target_arch(arm "" "-march=armv7-a" "-mfloat-abi=soft")
2218 -- test_target_arch(armhf "" "-march=armv7-a" "-mfloat-abi=hard")
2219 -- elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "aarch32")
2220 -- test_target_arch(aarch32 "" "-march=armv8-a")
2221 -- elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "aarch64")
2222 -- test_target_arch(aarch64 "" "-march=armv8-a")
2223 - elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "wasm32")
2224 - test_target_arch(wasm32 "" "--target=wasm32-unknown-unknown")
2225 - elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "wasm64")
2226
2227 diff --git a/sys-devel/llvm/files/3.8.1/compiler-rt/darwin-default-sysroot.patch b/sys-devel/llvm/files/3.8.1/compiler-rt/darwin-default-sysroot.patch
2228 deleted file mode 100644
2229 index 9122ce9bc79..00000000000
2230 --- a/sys-devel/llvm/files/3.8.1/compiler-rt/darwin-default-sysroot.patch
2231 +++ /dev/null
2232 @@ -1,14 +0,0 @@
2233 -find_darwin_sdk_dir: fall back to / for sysroot
2234 -
2235 ---- a/projects/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
2236 -+++ b/projects/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
2237 -@@ -17,6 +17,9 @@
2238 - ERROR_FILE /dev/null
2239 - )
2240 - endif()
2241 -+ if("" STREQUAL "${var_internal}")
2242 -+ set(var_internal "/")
2243 -+ endif()
2244 - set(${var} ${var_internal} PARENT_SCOPE)
2245 - endfunction()
2246 -
2247
2248 diff --git a/sys-devel/llvm/files/3.8.1/compiler-rt/fbsd.patch b/sys-devel/llvm/files/3.8.1/compiler-rt/fbsd.patch
2249 deleted file mode 100644
2250 index 297620bc775..00000000000
2251 --- a/sys-devel/llvm/files/3.8.1/compiler-rt/fbsd.patch
2252 +++ /dev/null
2253 @@ -1,20 +0,0 @@
2254 -https://llvm.org/bugs/show_bug.cgi?id=26651
2255 -https://github.com/llvm-mirror/compiler-rt/commit/6606c7b50cbb4ec7eab4ecbebbbaaa049734bbd3
2256 -
2257 -diff --git a/projects/compiler-rt/lib/tsan/CMakeLists.txt b/projects/compiler-rt/lib/tsan/CMakeLists.txt
2258 -index c185cfa..a151c6c 100644
2259 ---- a/projects/compiler-rt/lib/tsan/CMakeLists.txt
2260 -+++ b/projects/compiler-rt/lib/tsan/CMakeLists.txt
2261 -@@ -192,7 +192,11 @@ endif()
2262 - add_dependencies(compiler-rt tsan)
2263 -
2264 - # Make sure that non-platform-specific files don't include any system headers.
2265 --if(COMPILER_RT_HAS_SYSROOT_FLAG)
2266 -+# FreeBSD does not install a number of Clang-provided headers for the compiler
2267 -+# in the base system due to incompatibilities between FreeBSD's and Clang's
2268 -+# versions. As a workaround do not use --sysroot=. on FreeBSD until this is
2269 -+# addressed.
2270 -+if(COMPILER_RT_HAS_SYSROOT_FLAG AND NOT CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
2271 - file(GLOB _tsan_generic_sources rtl/tsan*)
2272 - file(GLOB _tsan_platform_sources rtl/tsan*posix* rtl/tsan*mac*
2273 - rtl/tsan*linux*)
2274
2275 diff --git a/sys-devel/llvm/files/3.8.1/llvm-config.patch b/sys-devel/llvm/files/3.8.1/llvm-config.patch
2276 deleted file mode 100644
2277 index 3eace43f6de..00000000000
2278 --- a/sys-devel/llvm/files/3.8.1/llvm-config.patch
2279 +++ /dev/null
2280 @@ -1,114 +0,0 @@
2281 -From 5ed05738769643b7c652f798fa6c3aa30c7f0b2b Mon Sep 17 00:00:00 2001
2282 -From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@g.o>
2283 -Date: Wed, 2 Dec 2015 16:04:56 +0100
2284 -Subject: [PATCH] llvm-config: Clean up exported values, update for shared
2285 - linking
2286 -
2287 -Gentoo-specific fixup for llvm-config, including:
2288 -- wiping build-specific CFLAGS, CXXFLAGS,
2289 -- updating library suffixes for shared libs,
2290 -- wiping --system-libs for shared linking,
2291 -- banning --obj-root and --src-root due to no sources installed,
2292 -- making --build-mode return "Release" rather than "Gentoo".
2293 -
2294 -Thanks to Steven Newbury for the initial patch.
2295 -
2296 -Bug: https://bugs.gentoo.org/565358
2297 -Bug: https://bugs.gentoo.org/501684
2298 ----
2299 - tools/llvm-config/CMakeLists.txt | 11 ++++++++---
2300 - tools/llvm-config/llvm-config.cpp | 20 +++++++++++++++-----
2301 - utils/llvm-build/llvmbuild/main.py | 4 +++-
2302 - 3 files changed, 26 insertions(+), 9 deletions(-)
2303 -
2304 -diff --git a/tools/llvm-config/CMakeLists.txt b/tools/llvm-config/CMakeLists.txt
2305 -index 83794bb..eba6f45 100644
2306 ---- a/tools/llvm-config/CMakeLists.txt
2307 -+++ b/tools/llvm-config/CMakeLists.txt
2308 -@@ -22,15 +22,20 @@ get_property(COMPILE_FLAGS TARGET llvm-config PROPERTY COMPILE_FLAGS)
2309 - set(LLVM_SRC_ROOT ${LLVM_MAIN_SRC_DIR})
2310 - set(LLVM_OBJ_ROOT ${LLVM_BINARY_DIR})
2311 - set(LLVM_CPPFLAGS "${CMAKE_CPP_FLAGS} ${CMAKE_CPP_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${LLVM_DEFINITIONS}")
2312 --set(LLVM_CFLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${LLVM_DEFINITIONS}")
2313 --set(LLVM_CXXFLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${COMPILE_FLAGS} ${LLVM_DEFINITIONS}")
2314 -+# Just use CMAKE_CPP_FLAGS for CFLAGS and CXXFLAGS, otherwise compiler
2315 -+# specific flags will be set when we don't know what compiler will be used
2316 -+# with external project utilising llvm-config. C++ Standard is required.
2317 -+# TODO: figure out if we can remove -std=c++11 and move it to revdeps.
2318 -+set(LLVM_CFLAGS "${CMAKE_CPP_FLAGS} ${CMAKE_C_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${LLVM_DEFINITIONS}")
2319 -+set(LLVM_CXXFLAGS "${CMAKE_CPP_FLAGS} -std=c++11 ${CMAKE_CXX_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${LLVM_DEFINITIONS}")
2320 - set(LLVM_BUILD_SYSTEM cmake)
2321 - set(LLVM_HAS_RTTI ${LLVM_CONFIG_HAS_RTTI})
2322 -
2323 - # Use the C++ link flags, since they should be a superset of C link flags.
2324 - set(LLVM_LDFLAGS "${CMAKE_CXX_LINK_FLAGS}")
2325 - set(LLVM_BUILDMODE ${CMAKE_BUILD_TYPE})
2326 --set(LLVM_SYSTEM_LIBS ${SYSTEM_LIBS})
2327 -+# We don't do static libs, so we don't need to supply any system-libs
2328 -+set(LLVM_SYSTEM_LIBS "")
2329 - if(BUILD_SHARED_LIBS)
2330 - set(LLVM_ENABLE_SHARED ON)
2331 - else()
2332 -diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp
2333 -index 80f6279..5c65c57 100644
2334 ---- a/tools/llvm-config/llvm-config.cpp
2335 -+++ b/tools/llvm-config/llvm-config.cpp
2336 -@@ -484,7 +484,8 @@ int main(int argc, char **argv) {
2337 - } else if (Arg == "--host-target") {
2338 - OS << Triple::normalize(LLVM_DEFAULT_TARGET_TRIPLE) << '\n';
2339 - } else if (Arg == "--build-mode") {
2340 -- OS << build_mode << '\n';
2341 -+ // force Release since we force non-standard Gentoo build mode
2342 -+ OS << "Release" << '\n';
2343 - } else if (Arg == "--assertion-mode") {
2344 - #if defined(NDEBUG)
2345 - OS << "OFF\n";
2346 -@@ -497,10 +498,19 @@ int main(int argc, char **argv) {
2347 - OS << LLVM_HAS_RTTI << '\n';
2348 - } else if (Arg == "--shared-mode") {
2349 - PrintSharedMode = true;
2350 -- } else if (Arg == "--obj-root") {
2351 -- OS << ActivePrefix << '\n';
2352 -- } else if (Arg == "--src-root") {
2353 -- OS << LLVM_SRC_ROOT << '\n';
2354 -+ } else if (Arg == "--obj-root" || Arg == "--src-root") {
2355 -+ if (IsInDevelopmentTree) {
2356 -+ if (Arg == "--obj-root") {
2357 -+ OS << ActivePrefix << '\n';
2358 -+ } else {
2359 -+ OS << LLVM_SRC_ROOT << '\n';
2360 -+ }
2361 -+ } else {
2362 -+ // sources are not installed
2363 -+ llvm::errs() << "llvm-config: sources not installed, "
2364 -+ << Arg << " not available\n";
2365 -+ exit(1);
2366 -+ }
2367 - } else {
2368 - usage();
2369 - }
2370 -diff --git a/utils/llvm-build/llvmbuild/main.py b/utils/llvm-build/llvmbuild/main.py
2371 -index f2472f6..c89c77a 100644
2372 ---- a/utils/llvm-build/llvmbuild/main.py
2373 -+++ b/utils/llvm-build/llvmbuild/main.py
2374 -@@ -393,6 +393,8 @@ subdirectories = %s
2375 - //
2376 - //===----------------------------------------------------------------------===//
2377 -
2378 -+#include "llvm/Config/config.h"
2379 -+
2380 - """)
2381 - f.write('struct AvailableComponent {\n')
2382 - f.write(' /// The name of the component.\n')
2383 -@@ -413,7 +415,7 @@ subdirectories = %s
2384 - if library_name is None:
2385 - library_name_as_cstr = 'nullptr'
2386 - else:
2387 -- library_name_as_cstr = '"lib%s.a"' % library_name
2388 -+ library_name_as_cstr = '"lib%s" LTDL_SHLIB_EXT' % library_name
2389 - if is_installed:
2390 - is_installed_as_cstr = 'true'
2391 - else:
2392 ---
2393 -2.7.4
2394 -
2395
2396 diff --git a/sys-devel/llvm/files/3.8.1/musl-env-support.patch b/sys-devel/llvm/files/3.8.1/musl-env-support.patch
2397 deleted file mode 100644
2398 index 8de660d01cf..00000000000
2399 --- a/sys-devel/llvm/files/3.8.1/musl-env-support.patch
2400 +++ /dev/null
2401 @@ -1,164 +0,0 @@
2402 -diff --git a/include/llvm/ADT/Triple.h b/include/llvm/ADT/Triple.h
2403 -index e01db0a..bf9361a 100644
2404 ---- a/include/llvm/ADT/Triple.h
2405 -+++ b/include/llvm/ADT/Triple.h
2406 -@@ -173,6 +173,9 @@ public:
2407 - EABI,
2408 - EABIHF,
2409 - Android,
2410 -+ Musl,
2411 -+ MuslEABI,
2412 -+ MuslEABIHF,
2413 -
2414 - MSVC,
2415 - Itanium,
2416 -@@ -544,6 +547,13 @@ public:
2417 - /// Tests whether the target is Android
2418 - bool isAndroid() const { return getEnvironment() == Triple::Android; }
2419 -
2420 -+ /// Tests whether the environment is musl-libc
2421 -+ bool isMusl() const {
2422 -+ return getEnvironment() == Triple::Musl ||
2423 -+ getEnvironment() == Triple::MuslEABI ||
2424 -+ getEnvironment() == Triple::MuslEABIHF;
2425 -+ }
2426 -+
2427 - /// @}
2428 - /// @name Mutators
2429 - /// @{
2430 -diff --git a/lib/Support/Triple.cpp b/lib/Support/Triple.cpp
2431 -index 11afcf7..ad9cffd 100644
2432 ---- a/lib/Support/Triple.cpp
2433 -+++ b/lib/Support/Triple.cpp
2434 -@@ -200,6 +200,9 @@ const char *Triple::getEnvironmentTypeName(EnvironmentType Kind) {
2435 - case EABI: return "eabi";
2436 - case EABIHF: return "eabihf";
2437 - case Android: return "android";
2438 -+ case Musl: return "musl";
2439 -+ case MuslEABI: return "musleabi";
2440 -+ case MuslEABIHF: return "musleabihf";
2441 - case MSVC: return "msvc";
2442 - case Itanium: return "itanium";
2443 - case Cygnus: return "cygnus";
2444 -@@ -454,6 +457,9 @@ static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) {
2445 - .StartsWith("code16", Triple::CODE16)
2446 - .StartsWith("gnu", Triple::GNU)
2447 - .StartsWith("android", Triple::Android)
2448 -+ .StartsWith("musleabihf", Triple::MuslEABIHF)
2449 -+ .StartsWith("musleabi", Triple::MuslEABI)
2450 -+ .StartsWith("musl", Triple::Musl)
2451 - .StartsWith("msvc", Triple::MSVC)
2452 - .StartsWith("itanium", Triple::Itanium)
2453 - .StartsWith("cygnus", Triple::Cygnus)
2454 -@@ -1431,6 +1437,7 @@ StringRef Triple::getARMCPUForArch(StringRef MArch) const {
2455 - switch (getEnvironment()) {
2456 - case llvm::Triple::EABIHF:
2457 - case llvm::Triple::GNUEABIHF:
2458 -+ case llvm::Triple::MuslEABIHF:
2459 - return "arm1176jzf-s";
2460 - default:
2461 - return "arm7tdmi";
2462 -diff --git a/lib/Target/ARM/ARMAsmPrinter.cpp b/lib/Target/ARM/ARMAsmPrinter.cpp
2463 -index f3813c8..45e8c4a 100644
2464 ---- a/lib/Target/ARM/ARMAsmPrinter.cpp
2465 -+++ b/lib/Target/ARM/ARMAsmPrinter.cpp
2466 -@@ -541,7 +541,8 @@ void ARMAsmPrinter::EmitEndOfAsmFile(Module &M) {
2467 - ARMTargetStreamer &ATS = static_cast<ARMTargetStreamer &>(TS);
2468 -
2469 - if (OptimizationGoals > 0 &&
2470 -- (Subtarget->isTargetAEABI() || Subtarget->isTargetGNUAEABI()))
2471 -+ (Subtarget->isTargetAEABI() || Subtarget->isTargetGNUAEABI() ||
2472 -+ Subtarget->isTargetMuslAEABI()))
2473 - ATS.emitAttribute(ARMBuildAttrs::ABI_optimization_goals, OptimizationGoals);
2474 - OptimizationGoals = -1;
2475 -
2476 -diff --git a/lib/Target/ARM/ARMISelLowering.cpp b/lib/Target/ARM/ARMISelLowering.cpp
2477 -index a2daa89..3b2c0bb 100644
2478 ---- a/lib/Target/ARM/ARMISelLowering.cpp
2479 -+++ b/lib/Target/ARM/ARMISelLowering.cpp
2480 -@@ -254,7 +254,7 @@ ARMTargetLowering::ARMTargetLowering(const TargetMachine &TM,
2481 - // RTLIB
2482 - if (Subtarget->isAAPCS_ABI() &&
2483 - (Subtarget->isTargetAEABI() || Subtarget->isTargetGNUAEABI() ||
2484 -- Subtarget->isTargetAndroid())) {
2485 -+ Subtarget->isTargetMuslAEABI() || Subtarget->isTargetAndroid())) {
2486 - static const struct {
2487 - const RTLIB::Libcall Op;
2488 - const char * const Name;
2489 -@@ -787,7 +787,8 @@ ARMTargetLowering::ARMTargetLowering(const TargetMachine &TM,
2490 - setOperationAction(ISD::SREM, MVT::i32, Expand);
2491 - setOperationAction(ISD::UREM, MVT::i32, Expand);
2492 - // Register based DivRem for AEABI (RTABI 4.2)
2493 -- if (Subtarget->isTargetAEABI() || Subtarget->isTargetAndroid()) {
2494 -+ if (Subtarget->isTargetAEABI() || Subtarget->isTargetAndroid() ||
2495 -+ Subtarget->isTargetMuslAEABI()) {
2496 - setOperationAction(ISD::SREM, MVT::i64, Custom);
2497 - setOperationAction(ISD::UREM, MVT::i64, Custom);
2498 -
2499 -@@ -11651,7 +11652,8 @@ static TargetLowering::ArgListTy getDivRemArgList(
2500 - }
2501 -
2502 - SDValue ARMTargetLowering::LowerDivRem(SDValue Op, SelectionDAG &DAG) const {
2503 -- assert((Subtarget->isTargetAEABI() || Subtarget->isTargetAndroid()) &&
2504 -+ assert((Subtarget->isTargetAEABI() || Subtarget->isTargetAndroid() ||
2505 -+ Subtarget->isTargetMuslAEABI()) &&
2506 - "Register-based DivRem lowering only");
2507 - unsigned Opcode = Op->getOpcode();
2508 - assert((Opcode == ISD::SDIVREM || Opcode == ISD::UDIVREM) &&
2509 -diff --git a/lib/Target/ARM/ARMSubtarget.h b/lib/Target/ARM/ARMSubtarget.h
2510 -index 4d54e57..fa1c516 100644
2511 ---- a/lib/Target/ARM/ARMSubtarget.h
2512 -+++ b/lib/Target/ARM/ARMSubtarget.h
2513 -@@ -399,14 +399,21 @@ public:
2514 - TargetTriple.getEnvironment() == Triple::GNUEABIHF) &&
2515 - !isTargetDarwin() && !isTargetWindows();
2516 - }
2517 -+ bool isTargetMuslAEABI() const {
2518 -+ return (TargetTriple.getEnvironment() == Triple::MuslEABI ||
2519 -+ TargetTriple.getEnvironment() == Triple::MuslEABIHF) &&
2520 -+ !isTargetDarwin() && !isTargetWindows();
2521 -+ }
2522 -
2523 - // ARM Targets that support EHABI exception handling standard
2524 - // Darwin uses SjLj. Other targets might need more checks.
2525 - bool isTargetEHABICompatible() const {
2526 - return (TargetTriple.getEnvironment() == Triple::EABI ||
2527 - TargetTriple.getEnvironment() == Triple::GNUEABI ||
2528 -+ TargetTriple.getEnvironment() == Triple::MuslEABI ||
2529 - TargetTriple.getEnvironment() == Triple::EABIHF ||
2530 - TargetTriple.getEnvironment() == Triple::GNUEABIHF ||
2531 -+ TargetTriple.getEnvironment() == Triple::MuslEABIHF ||
2532 - isTargetAndroid()) &&
2533 - !isTargetDarwin() && !isTargetWindows();
2534 - }
2535 -@@ -414,6 +421,7 @@ public:
2536 - bool isTargetHardFloat() const {
2537 - // FIXME: this is invalid for WindowsCE
2538 - return TargetTriple.getEnvironment() == Triple::GNUEABIHF ||
2539 -+ TargetTriple.getEnvironment() == Triple::MuslEABIHF ||
2540 - TargetTriple.getEnvironment() == Triple::EABIHF ||
2541 - isTargetWindows() || isAAPCS16_ABI();
2542 - }
2543 -diff --git a/lib/Target/ARM/ARMTargetMachine.cpp b/lib/Target/ARM/ARMTargetMachine.cpp
2544 -index fca1901..a96b1f9 100644
2545 ---- a/lib/Target/ARM/ARMTargetMachine.cpp
2546 -+++ b/lib/Target/ARM/ARMTargetMachine.cpp
2547 -@@ -99,6 +99,8 @@ computeTargetABI(const Triple &TT, StringRef CPU,
2548 - case llvm::Triple::Android:
2549 - case llvm::Triple::GNUEABI:
2550 - case llvm::Triple::GNUEABIHF:
2551 -+ case llvm::Triple::MuslEABI:
2552 -+ case llvm::Triple::MuslEABIHF:
2553 - case llvm::Triple::EABIHF:
2554 - case llvm::Triple::EABI:
2555 - TargetABI = ARMBaseTargetMachine::ARM_ABI_AAPCS;
2556 -@@ -192,7 +194,8 @@ ARMBaseTargetMachine::ARMBaseTargetMachine(const Target &T, const Triple &TT,
2557 - // Default to triple-appropriate EABI
2558 - if (Options.EABIVersion == EABI::Default ||
2559 - Options.EABIVersion == EABI::Unknown) {
2560 -- if (Subtarget.isTargetGNUAEABI())
2561 -+ // musl is compatible with glibc with regard to EABI version
2562 -+ if (Subtarget.isTargetGNUAEABI() || Subtarget.isTargetMuslAEABI())
2563 - this->Options.EABIVersion = EABI::GNU;
2564 - else
2565 - this->Options.EABIVersion = EABI::EABI5;
2566
2567 diff --git a/sys-devel/llvm/llvm-3.8.1-r2.ebuild b/sys-devel/llvm/llvm-3.8.1-r2.ebuild
2568 index 0c120d3c6cd..e1df41fb8a4 100644
2569 --- a/sys-devel/llvm/llvm-3.8.1-r2.ebuild
2570 +++ b/sys-devel/llvm/llvm-3.8.1-r2.ebuild
2571 @@ -1,4 +1,4 @@
2572 -# Copyright 1999-2016 Gentoo Foundation
2573 +# Copyright 1999-2017 Gentoo Foundation
2574 # Distributed under the terms of the GNU General Public License v2
2575
2576 EAPI=6
2577 @@ -16,7 +16,8 @@ SRC_URI="http://llvm.org/releases/${PV}/${P}.src.tar.xz
2578 http://llvm.org/releases/${PV}/cfe-${PV}.src.tar.xz
2579 http://llvm.org/releases/${PV}/clang-tools-extra-${PV}.src.tar.xz )
2580 lldb? ( http://llvm.org/releases/${PV}/lldb-${PV}.src.tar.xz )
2581 - !doc? ( http://dev.gentoo.org/~voyageur/distfiles/${PN}-3.8.0-manpages.tar.bz2 )"
2582 + !doc? ( https://dev.gentoo.org/~voyageur/distfiles/${PN}-3.8.0-manpages.tar.bz2 )
2583 + https://dev.gentoo.org/~mgorny/dist/llvm/${P}-patchset.tar.xz"
2584
2585 # Additional licenses:
2586 # 1. OpenBSD regex: Henry Spencer's license ('rc' in Gentoo) + BSD.
2587 @@ -156,38 +157,38 @@ src_prepare() {
2588 # Make ocaml warnings non-fatal, bug #537308
2589 sed -e "/RUN/s/-warn-error A//" -i test/Bindings/OCaml/*ml || die
2590 # Fix libdir for ocaml bindings install, bug #559134
2591 - eapply "${FILESDIR}"/3.9.1/0001-cmake-Install-OCaml-modules-into-correct-package-loc.patch
2592 + eapply "${WORKDIR}/${P}-patchset"/0001-cmake-Install-OCaml-modules-into-correct-package-loc.patch
2593 # Do not build/install ocaml docs with USE=-doc, bug #562008
2594 - eapply "${FILESDIR}"/3.9.1/0002-cmake-Make-OCaml-docs-dependent-on-LLVM_BUILD_DOCS.patch
2595 + eapply "${WORKDIR}/${P}-patchset"/0002-cmake-Make-OCaml-docs-dependent-on-LLVM_BUILD_DOCS.patch
2596
2597 # Make it possible to override Sphinx HTML install dirs
2598 # https://llvm.org/bugs/show_bug.cgi?id=23780
2599 - eapply "${FILESDIR}"/3.9.1/0003-cmake-Support-overriding-Sphinx-HTML-doc-install-dir.patch
2600 + eapply "${WORKDIR}/${P}-patchset"/0003-cmake-Support-overriding-Sphinx-HTML-doc-install-dir.patch
2601
2602 # Prevent race conditions with parallel Sphinx runs
2603 # https://llvm.org/bugs/show_bug.cgi?id=23781
2604 - eapply "${FILESDIR}"/3.8.1/0004-cmake-Add-an-ordering-dep-between-HTML-man-Sphinx-ta.patch
2605 + eapply "${WORKDIR}/${P}-patchset"/0004-cmake-Add-an-ordering-dep-between-HTML-man-Sphinx-ta.patch
2606
2607 # Prevent installing libgtest
2608 # https://llvm.org/bugs/show_bug.cgi?id=18341
2609 - eapply "${FILESDIR}"/3.8.1/0005-cmake-Do-not-install-libgtest.patch
2610 + eapply "${WORKDIR}/${P}-patchset"/0005-cmake-Do-not-install-libgtest.patch
2611
2612 # Allow custom cmake build types (like 'Gentoo')
2613 - eapply "${FILESDIR}"/3.9.1/0006-cmake-Remove-the-CMAKE_BUILD_TYPE-assertion.patch
2614 + eapply "${WORKDIR}/${P}-patchset"/0006-cmake-Remove-the-CMAKE_BUILD_TYPE-assertion.patch
2615
2616 # Fix llvm-config for shared linking and sane flags
2617 # https://bugs.gentoo.org/show_bug.cgi?id=565358
2618 - eapply "${FILESDIR}"/3.9.1/llvm-config-r1.patch
2619 + eapply "${WORKDIR}/${P}-patchset"/llvm-config-r1.patch
2620
2621 # Restore SOVERSIONs for shared libraries
2622 # https://bugs.gentoo.org/show_bug.cgi?id=578392
2623 - eapply "${FILESDIR}"/3.8.1/0008-cmake-Restore-SOVERSIONs-on-shared-libraries.patch
2624 + eapply "${WORKDIR}/${P}-patchset"/0008-cmake-Restore-SOVERSIONs-on-shared-libraries.patch
2625
2626 # support building llvm against musl-libc
2627 - use elibc_musl && eapply "${FILESDIR}"/9999/musl-fixes.patch
2628 + use elibc_musl && eapply "${WORKDIR}/${P}-patchset"/musl-fixes.patch
2629
2630 # support "musl" as a valid environment type in llvm
2631 - eapply "${FILESDIR}"/3.8.1/musl-env-support.patch
2632 + eapply "${WORKDIR}/${P}-patchset"/musl-env-support.patch
2633
2634 # disable use of SDK on OSX, bug #568758
2635 sed -i -e 's/xcrun/false/' utils/lit/lit/util.py || die
2636 @@ -197,21 +198,21 @@ src_prepare() {
2637
2638 if use clang; then
2639 # Automatically select active system GCC's libraries, bugs #406163 and #417913
2640 - eapply "${FILESDIR}"/3.8.1/clang/gentoo-runtime-gcc-detection-v3.patch
2641 + eapply "${WORKDIR}/${P}-patchset"/clang/gentoo-runtime-gcc-detection-v3.patch
2642
2643 # Support gcc4.9 search paths
2644 # https://github.com/llvm-mirror/clang/commit/af4db76e059c1a3
2645 - eapply "${FILESDIR}"/3.8.1/clang/gcc4.9-search-path.patch
2646 + eapply "${WORKDIR}/${P}-patchset"/clang/gcc4.9-search-path.patch
2647
2648 - eapply "${FILESDIR}"/3.9.1/clang/darwin_prefix-include-paths.patch
2649 + eapply "${WORKDIR}/${P}-patchset"/clang/darwin_prefix-include-paths.patch
2650 eprefixify tools/clang/lib/Frontend/InitHeaderSearch.cpp
2651
2652 pushd "${S}"/tools/clang >/dev/null || die
2653 # be able to specify default values for -stdlib and -rtlib at build time
2654 - eapply "${FILESDIR}"/3.8.1/clang/default-libs.patch
2655 + eapply "${WORKDIR}/${P}-patchset"/clang/default-libs.patch
2656
2657 # enable clang to recognize musl-libc
2658 - eapply "${FILESDIR}"/3.8.1/clang/musl-support.patch
2659 + eapply "${WORKDIR}/${P}-patchset"/clang/musl-support.patch
2660 popd >/dev/null || die
2661
2662 sed -i -e "s^@EPREFIX@^${EPREFIX}^" \
2663 @@ -219,28 +220,28 @@ src_prepare() {
2664
2665 # Install clang runtime into /usr/lib/clang
2666 # https://llvm.org/bugs/show_bug.cgi?id=23792
2667 - eapply "${FILESDIR}"/3.9.1/clang/0001-Install-clang-runtime-into-usr-lib-without-suffix.patch
2668 - eapply "${FILESDIR}"/3.8.1/compiler-rt/0001-cmake-Install-compiler-rt-into-usr-lib-without-suffi.patch
2669 + eapply "${WORKDIR}/${P}-patchset"/clang/0001-Install-clang-runtime-into-usr-lib-without-suffix.patch
2670 + eapply "${WORKDIR}/${P}-patchset"/compiler-rt/0001-cmake-Install-compiler-rt-into-usr-lib-without-suffi.patch
2671
2672 # Do not force -march flags on arm platforms
2673 # https://bugs.gentoo.org/show_bug.cgi?id=562706
2674 - eapply "${FILESDIR}"/3.8.1/compiler-rt/arm_march_flags.patch
2675 + eapply "${WORKDIR}/${P}-patchset"/compiler-rt/arm_march_flags.patch
2676
2677 # Make it possible to override CLANG_LIBDIR_SUFFIX
2678 # (that is used only to find LLVMgold.so)
2679 # https://llvm.org/bugs/show_bug.cgi?id=23793
2680 - eapply "${FILESDIR}"/3.9.1/clang/0002-cmake-Make-CLANG_LIBDIR_SUFFIX-overridable.patch
2681 + eapply "${WORKDIR}/${P}-patchset"/clang/0002-cmake-Make-CLANG_LIBDIR_SUFFIX-overridable.patch
2682
2683 # Fix git-clang-format shebang, bug #562688
2684 python_fix_shebang tools/clang/tools/clang-format/git-clang-format
2685
2686 # Fix 'stdarg.h' file not found on Gentoo/FreeBSD, bug #578064
2687 # https://llvm.org/bugs/show_bug.cgi?id=26651
2688 - eapply "${FILESDIR}"/3.8.1/compiler-rt/fbsd.patch
2689 + eapply "${WORKDIR}/${P}-patchset"/compiler-rt/fbsd.patch
2690
2691 # Backport abi-tag support, bug #571600
2692 - eapply "${FILESDIR}"/3.8.1/clang/abi-tag-support-sema.patch
2693 - eapply "${FILESDIR}"/3.8.1/clang/abi-tag-support-mangler.patch
2694 + eapply "${WORKDIR}/${P}-patchset"/clang/abi-tag-support-sema.patch
2695 + eapply "${WORKDIR}/${P}-patchset"/clang/abi-tag-support-mangler.patch
2696
2697 pushd projects/compiler-rt >/dev/null || die
2698
2699 @@ -258,7 +259,7 @@ src_prepare() {
2700 sed -e 's/add_subdirectory(readline)/#&/' \
2701 -i tools/lldb/scripts/Python/modules/CMakeLists.txt || die
2702 # Do not install bundled six module
2703 - eapply "${FILESDIR}"/3.9.1/lldb/six.patch
2704 + eapply "${WORKDIR}/${P}-patchset"/lldb/six.patch
2705 fi
2706
2707 # User patches