1 |
commit: d4850f51bb1610a9c16ee5d6da6515e6aefff8f9 |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Aug 16 17:52:17 2018 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Aug 16 18:49:20 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d4850f51 |
7 |
|
8 |
sys-devel/llvm: Backport binutils compatibility patch to 6.0.1 |
9 |
|
10 |
Backport the patch necessary to make LLVM assembly compatible |
11 |
with new restrictions in binutils-2.31.1. |
12 |
|
13 |
Closes: https://bugs.gentoo.org/663442 |
14 |
|
15 |
...c-Produce-R_X86_64_PLT32-for-call-jmp-foo.patch | 314 +++++++++++++++++++++ |
16 |
sys-devel/llvm/llvm-6.0.1-r1.ebuild | 266 +++++++++++++++++ |
17 |
2 files changed, 580 insertions(+) |
18 |
|
19 |
diff --git a/sys-devel/llvm/files/6.0.1/0002-llvm-mc-Produce-R_X86_64_PLT32-for-call-jmp-foo.patch b/sys-devel/llvm/files/6.0.1/0002-llvm-mc-Produce-R_X86_64_PLT32-for-call-jmp-foo.patch |
20 |
new file mode 100644 |
21 |
index 00000000000..eac5fe44178 |
22 |
--- /dev/null |
23 |
+++ b/sys-devel/llvm/files/6.0.1/0002-llvm-mc-Produce-R_X86_64_PLT32-for-call-jmp-foo.patch |
24 |
@@ -0,0 +1,314 @@ |
25 |
+From 9ff352cb602d5dd68bcd7bf2ba4711c8568271a9 Mon Sep 17 00:00:00 2001 |
26 |
+From: George Rimar <grimar@××××××××××××.com> |
27 |
+Date: Tue, 20 Feb 2018 10:17:57 +0000 |
28 |
+Subject: [PATCH] [llvm-mc] - Produce R_X86_64_PLT32 for "call/jmp foo". |
29 |
+ |
30 |
+For instructions like call foo and jmp foo patch changes |
31 |
+relocation produced from R_X86_64_PC32 to R_X86_64_PLT32. |
32 |
+Relocation can be used as a marker for 32-bit PC-relative branches. |
33 |
+Linker will reduce PLT32 relocation to PC32 if function is defined locally. |
34 |
+ |
35 |
+Differential revision: https://reviews.llvm.org/D43383 |
36 |
+ |
37 |
+git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@325569 91177308-0d34-0410-b5e6-96231b3b80d8 |
38 |
+--- |
39 |
+ lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp | 3 ++ |
40 |
+ .../X86/MCTargetDesc/X86ELFObjectWriter.cpp | 3 ++ |
41 |
+ lib/Target/X86/MCTargetDesc/X86FixupKinds.h | 1 + |
42 |
+ .../X86/MCTargetDesc/X86MCCodeEmitter.cpp | 32 +++++++++++++++++-- |
43 |
+ .../X86/MCTargetDesc/X86MachObjectWriter.cpp | 1 + |
44 |
+ .../MCTargetDesc/X86WinCOFFObjectWriter.cpp | 1 + |
45 |
+ test/CodeGen/X86/cmp.ll | 2 +- |
46 |
+ test/CodeGen/X86/fma.ll | 8 ++--- |
47 |
+ test/MC/ELF/basic-elf-64.s | 18 ++++++----- |
48 |
+ test/MC/ELF/ifunc-reloc.s | 2 +- |
49 |
+ test/MC/ELF/weak-diff.s | 2 +- |
50 |
+ test/MC/ELF/weak-relocation.s | 2 +- |
51 |
+ test/MC/ELF/weakref-reloc.s | 2 +- |
52 |
+ 13 files changed, 58 insertions(+), 19 deletions(-) |
53 |
+ |
54 |
+diff --git a/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp b/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp |
55 |
+index 34db5918926..b301722b535 100644 |
56 |
+--- a/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp |
57 |
++++ b/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp |
58 |
+@@ -46,6 +46,7 @@ static unsigned getFixupKindLog2Size(unsigned Kind) { |
59 |
+ case X86::reloc_signed_4byte: |
60 |
+ case X86::reloc_signed_4byte_relax: |
61 |
+ case X86::reloc_global_offset_table: |
62 |
++ case X86::reloc_branch_4byte_pcrel: |
63 |
+ case FK_SecRel_4: |
64 |
+ case FK_Data_4: |
65 |
+ return 2; |
66 |
+@@ -95,6 +96,7 @@ public: |
67 |
+ {"reloc_signed_4byte_relax", 0, 32, 0}, |
68 |
+ {"reloc_global_offset_table", 0, 32, 0}, |
69 |
+ {"reloc_global_offset_table8", 0, 64, 0}, |
70 |
++ {"reloc_branch_4byte_pcrel", 0, 32, MCFixupKindInfo::FKF_IsPCRel}, |
71 |
+ }; |
72 |
+ |
73 |
+ if (Kind < FirstTargetFixupKind) |
74 |
+@@ -102,6 +104,7 @@ public: |
75 |
+ |
76 |
+ assert(unsigned(Kind - FirstTargetFixupKind) < getNumFixupKinds() && |
77 |
+ "Invalid kind!"); |
78 |
++ assert(Infos[Kind - FirstTargetFixupKind].Name && "Empty fixup name!"); |
79 |
+ return Infos[Kind - FirstTargetFixupKind]; |
80 |
+ } |
81 |
+ |
82 |
+diff --git a/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp b/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp |
83 |
+index 4cdbae4d0d9..2ecbb80cd06 100644 |
84 |
+--- a/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp |
85 |
++++ b/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp |
86 |
+@@ -75,6 +75,9 @@ static X86_64RelType getType64(unsigned Kind, |
87 |
+ case X86::reloc_riprel_4byte_relax_rex: |
88 |
+ case X86::reloc_riprel_4byte_movq_load: |
89 |
+ return RT64_32; |
90 |
++ case X86::reloc_branch_4byte_pcrel: |
91 |
++ Modifier = MCSymbolRefExpr::VK_PLT; |
92 |
++ return RT64_32; |
93 |
+ case FK_PCRel_2: |
94 |
+ case FK_Data_2: |
95 |
+ return RT64_16; |
96 |
+diff --git a/lib/Target/X86/MCTargetDesc/X86FixupKinds.h b/lib/Target/X86/MCTargetDesc/X86FixupKinds.h |
97 |
+index dfdc9ec29ae..3c04b13e002 100644 |
98 |
+--- a/lib/Target/X86/MCTargetDesc/X86FixupKinds.h |
99 |
++++ b/lib/Target/X86/MCTargetDesc/X86FixupKinds.h |
100 |
+@@ -30,6 +30,7 @@ enum Fixups { |
101 |
+ // of the instruction. Used only |
102 |
+ // for _GLOBAL_OFFSET_TABLE_. |
103 |
+ reloc_global_offset_table8, // 64-bit variant. |
104 |
++ reloc_branch_4byte_pcrel, // 32-bit PC relative branch. |
105 |
+ // Marker |
106 |
+ LastTargetFixupKind, |
107 |
+ NumTargetFixupKinds = LastTargetFixupKind - FirstTargetFixupKind |
108 |
+diff --git a/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp b/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp |
109 |
+index 4ddc1f0ba42..608dc4acb04 100644 |
110 |
+--- a/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp |
111 |
++++ b/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp |
112 |
+@@ -152,6 +152,8 @@ public: |
113 |
+ |
114 |
+ uint8_t DetermineREXPrefix(const MCInst &MI, uint64_t TSFlags, |
115 |
+ int MemOperand, const MCInstrDesc &Desc) const; |
116 |
++ |
117 |
++ bool isPCRel32Branch(const MCInst &MI) const; |
118 |
+ }; |
119 |
+ |
120 |
+ } // end anonymous namespace |
121 |
+@@ -276,6 +278,22 @@ static bool HasSecRelSymbolRef(const MCExpr *Expr) { |
122 |
+ return false; |
123 |
+ } |
124 |
+ |
125 |
++bool X86MCCodeEmitter::isPCRel32Branch(const MCInst &MI) const { |
126 |
++ unsigned Opcode = MI.getOpcode(); |
127 |
++ const MCInstrDesc &Desc = MCII.get(Opcode); |
128 |
++ if ((Opcode != X86::CALL64pcrel32 && Opcode != X86::JMP_4) || |
129 |
++ getImmFixupKind(Desc.TSFlags) != FK_PCRel_4) |
130 |
++ return false; |
131 |
++ |
132 |
++ unsigned CurOp = X86II::getOperandBias(Desc); |
133 |
++ const MCOperand &Op = MI.getOperand(CurOp); |
134 |
++ if (!Op.isExpr()) |
135 |
++ return false; |
136 |
++ |
137 |
++ const MCSymbolRefExpr *Ref = dyn_cast<MCSymbolRefExpr>(Op.getExpr()); |
138 |
++ return Ref && Ref->getKind() == MCSymbolRefExpr::VK_None; |
139 |
++} |
140 |
++ |
141 |
+ void X86MCCodeEmitter:: |
142 |
+ EmitImmediate(const MCOperand &DispOp, SMLoc Loc, unsigned Size, |
143 |
+ MCFixupKind FixupKind, unsigned &CurByte, raw_ostream &OS, |
144 |
+@@ -331,7 +349,8 @@ EmitImmediate(const MCOperand &DispOp, SMLoc Loc, unsigned Size, |
145 |
+ FixupKind == MCFixupKind(X86::reloc_riprel_4byte) || |
146 |
+ FixupKind == MCFixupKind(X86::reloc_riprel_4byte_movq_load) || |
147 |
+ FixupKind == MCFixupKind(X86::reloc_riprel_4byte_relax) || |
148 |
+- FixupKind == MCFixupKind(X86::reloc_riprel_4byte_relax_rex)) |
149 |
++ FixupKind == MCFixupKind(X86::reloc_riprel_4byte_relax_rex) || |
150 |
++ FixupKind == MCFixupKind(X86::reloc_branch_4byte_pcrel)) |
151 |
+ ImmOffset -= 4; |
152 |
+ if (FixupKind == FK_PCRel_2) |
153 |
+ ImmOffset -= 2; |
154 |
+@@ -1287,9 +1306,18 @@ encodeInstruction(const MCInst &MI, raw_ostream &OS, |
155 |
+ EmitByte(BaseOpcode, CurByte, OS); |
156 |
+ break; |
157 |
+ } |
158 |
+- case X86II::RawFrm: |
159 |
++ case X86II::RawFrm: { |
160 |
+ EmitByte(BaseOpcode, CurByte, OS); |
161 |
++ |
162 |
++ if (!is64BitMode(STI) || !isPCRel32Branch(MI)) |
163 |
++ break; |
164 |
++ |
165 |
++ const MCOperand &Op = MI.getOperand(CurOp++); |
166 |
++ EmitImmediate(Op, MI.getLoc(), X86II::getSizeOfImm(TSFlags), |
167 |
++ MCFixupKind(X86::reloc_branch_4byte_pcrel), CurByte, OS, |
168 |
++ Fixups); |
169 |
+ break; |
170 |
++ } |
171 |
+ case X86II::RawFrmMemOffs: |
172 |
+ // Emit segment override opcode prefix as needed. |
173 |
+ EmitSegmentOverridePrefix(CurByte, 1, MI, OS); |
174 |
+diff --git a/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp b/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp |
175 |
+index 965f7de809b..22773e64409 100644 |
176 |
+--- a/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp |
177 |
++++ b/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp |
178 |
+@@ -94,6 +94,7 @@ static unsigned getFixupKindLog2Size(unsigned Kind) { |
179 |
+ case X86::reloc_riprel_4byte_movq_load: |
180 |
+ case X86::reloc_signed_4byte: |
181 |
+ case X86::reloc_signed_4byte_relax: |
182 |
++ case X86::reloc_branch_4byte_pcrel: |
183 |
+ case FK_Data_4: return 2; |
184 |
+ case FK_Data_8: return 3; |
185 |
+ } |
186 |
+diff --git a/lib/Target/X86/MCTargetDesc/X86WinCOFFObjectWriter.cpp b/lib/Target/X86/MCTargetDesc/X86WinCOFFObjectWriter.cpp |
187 |
+index 5139bb46b56..291056e3526 100644 |
188 |
+--- a/lib/Target/X86/MCTargetDesc/X86WinCOFFObjectWriter.cpp |
189 |
++++ b/lib/Target/X86/MCTargetDesc/X86WinCOFFObjectWriter.cpp |
190 |
+@@ -62,6 +62,7 @@ unsigned X86WinCOFFObjectWriter::getRelocType(MCContext &Ctx, |
191 |
+ case X86::reloc_riprel_4byte_movq_load: |
192 |
+ case X86::reloc_riprel_4byte_relax: |
193 |
+ case X86::reloc_riprel_4byte_relax_rex: |
194 |
++ case X86::reloc_branch_4byte_pcrel: |
195 |
+ return COFF::IMAGE_REL_AMD64_REL32; |
196 |
+ case FK_Data_4: |
197 |
+ case X86::reloc_signed_4byte: |
198 |
+diff --git a/test/CodeGen/X86/cmp.ll b/test/CodeGen/X86/cmp.ll |
199 |
+index 1ab8421638d..244e651e182 100644 |
200 |
+--- a/test/CodeGen/X86/cmp.ll |
201 |
++++ b/test/CodeGen/X86/cmp.ll |
202 |
+@@ -240,7 +240,7 @@ define i32 @test12() ssp uwtable { |
203 |
+ ; CHECK-NEXT: pushq %rax # encoding: [0x50] |
204 |
+ ; CHECK-NEXT: .cfi_def_cfa_offset 16 |
205 |
+ ; CHECK-NEXT: callq test12b # encoding: [0xe8,A,A,A,A] |
206 |
+-; CHECK-NEXT: # fixup A - offset: 1, value: test12b-4, kind: FK_PCRel_4 |
207 |
++; CHECK-NEXT: # fixup A - offset: 1, value: test12b-4, kind: reloc_branch_4byte_pcrel |
208 |
+ ; CHECK-NEXT: testb %al, %al # encoding: [0x84,0xc0] |
209 |
+ ; CHECK-NEXT: je .LBB12_2 # encoding: [0x74,A] |
210 |
+ ; CHECK-NEXT: # fixup A - offset: 1, value: .LBB12_2-1, kind: FK_PCRel_1 |
211 |
+diff --git a/test/CodeGen/X86/fma.ll b/test/CodeGen/X86/fma.ll |
212 |
+index 611f707d64c..2c919e3ebc9 100644 |
213 |
+--- a/test/CodeGen/X86/fma.ll |
214 |
++++ b/test/CodeGen/X86/fma.ll |
215 |
+@@ -137,7 +137,7 @@ define x86_fp80 @test_f80(x86_fp80 %a, x86_fp80 %b, x86_fp80 %c) #0 { |
216 |
+ ; FMA64-NEXT: fstpt {{[0-9]+}}(%rsp) ## encoding: [0xdb,0x7c,0x24,0x10] |
217 |
+ ; FMA64-NEXT: fstpt (%rsp) ## encoding: [0xdb,0x3c,0x24] |
218 |
+ ; FMA64-NEXT: callq _fmal ## encoding: [0xe8,A,A,A,A] |
219 |
+-; FMA64-NEXT: ## fixup A - offset: 1, value: _fmal-4, kind: FK_PCRel_4 |
220 |
++; FMA64-NEXT: ## fixup A - offset: 1, value: _fmal-4, kind: reloc_branch_4byte_pcrel |
221 |
+ ; FMA64-NEXT: addq $56, %rsp ## encoding: [0x48,0x83,0xc4,0x38] |
222 |
+ ; FMA64-NEXT: retq ## encoding: [0xc3] |
223 |
+ ; |
224 |
+@@ -151,7 +151,7 @@ define x86_fp80 @test_f80(x86_fp80 %a, x86_fp80 %b, x86_fp80 %c) #0 { |
225 |
+ ; FMACALL64-NEXT: fstpt {{[0-9]+}}(%rsp) ## encoding: [0xdb,0x7c,0x24,0x10] |
226 |
+ ; FMACALL64-NEXT: fstpt (%rsp) ## encoding: [0xdb,0x3c,0x24] |
227 |
+ ; FMACALL64-NEXT: callq _fmal ## encoding: [0xe8,A,A,A,A] |
228 |
+-; FMACALL64-NEXT: ## fixup A - offset: 1, value: _fmal-4, kind: FK_PCRel_4 |
229 |
++; FMACALL64-NEXT: ## fixup A - offset: 1, value: _fmal-4, kind: reloc_branch_4byte_pcrel |
230 |
+ ; FMACALL64-NEXT: addq $56, %rsp ## encoding: [0x48,0x83,0xc4,0x38] |
231 |
+ ; FMACALL64-NEXT: retq ## encoding: [0xc3] |
232 |
+ ; |
233 |
+@@ -165,7 +165,7 @@ define x86_fp80 @test_f80(x86_fp80 %a, x86_fp80 %b, x86_fp80 %c) #0 { |
234 |
+ ; AVX512-NEXT: fstpt {{[0-9]+}}(%rsp) ## encoding: [0xdb,0x7c,0x24,0x10] |
235 |
+ ; AVX512-NEXT: fstpt (%rsp) ## encoding: [0xdb,0x3c,0x24] |
236 |
+ ; AVX512-NEXT: callq _fmal ## encoding: [0xe8,A,A,A,A] |
237 |
+-; AVX512-NEXT: ## fixup A - offset: 1, value: _fmal-4, kind: FK_PCRel_4 |
238 |
++; AVX512-NEXT: ## fixup A - offset: 1, value: _fmal-4, kind: reloc_branch_4byte_pcrel |
239 |
+ ; AVX512-NEXT: addq $56, %rsp ## encoding: [0x48,0x83,0xc4,0x38] |
240 |
+ ; AVX512-NEXT: retq ## encoding: [0xc3] |
241 |
+ ; |
242 |
+@@ -179,7 +179,7 @@ define x86_fp80 @test_f80(x86_fp80 %a, x86_fp80 %b, x86_fp80 %c) #0 { |
243 |
+ ; AVX512VL-NEXT: fstpt {{[0-9]+}}(%rsp) ## encoding: [0xdb,0x7c,0x24,0x10] |
244 |
+ ; AVX512VL-NEXT: fstpt (%rsp) ## encoding: [0xdb,0x3c,0x24] |
245 |
+ ; AVX512VL-NEXT: callq _fmal ## encoding: [0xe8,A,A,A,A] |
246 |
+-; AVX512VL-NEXT: ## fixup A - offset: 1, value: _fmal-4, kind: FK_PCRel_4 |
247 |
++; AVX512VL-NEXT: ## fixup A - offset: 1, value: _fmal-4, kind: reloc_branch_4byte_pcrel |
248 |
+ ; AVX512VL-NEXT: addq $56, %rsp ## encoding: [0x48,0x83,0xc4,0x38] |
249 |
+ ; AVX512VL-NEXT: retq ## encoding: [0xc3] |
250 |
+ entry: |
251 |
+diff --git a/test/MC/ELF/basic-elf-64.s b/test/MC/ELF/basic-elf-64.s |
252 |
+index 01f020bd64b..ae0903ec8cd 100644 |
253 |
+--- a/test/MC/ELF/basic-elf-64.s |
254 |
++++ b/test/MC/ELF/basic-elf-64.s |
255 |
+@@ -13,6 +13,7 @@ main: # @main |
256 |
+ callq puts |
257 |
+ xorl %eax, %eax |
258 |
+ addq $8, %rsp |
259 |
++ call foo@GOTPCREL |
260 |
+ ret |
261 |
+ .Ltmp0: |
262 |
+ .size main, .Ltmp0-main |
263 |
+@@ -44,14 +45,15 @@ main: # @main |
264 |
+ |
265 |
+ // CHECK: Name: .rela.text |
266 |
+ |
267 |
+-// CHECK: Relocations [ |
268 |
+-// CHECK: Section {{.*}} .rela.text { |
269 |
+-// CHECK: 0x5 R_X86_64_32 .rodata.str1.1 0x0 |
270 |
+-// CHECK: 0xA R_X86_64_PC32 puts 0xFFFFFFFFFFFFFFFC |
271 |
+-// CHECK: 0xF R_X86_64_32 .rodata.str1.1 0x6 |
272 |
+-// CHECK: 0x14 R_X86_64_PC32 puts 0xFFFFFFFFFFFFFFFC |
273 |
+-// CHECK: } |
274 |
+-// CHECK: ] |
275 |
++// CHECK: Relocations [ |
276 |
++// CHECK: Section {{.*}} .rela.text { |
277 |
++// CHECK-NEXT: 0x5 R_X86_64_32 .rodata.str1.1 0x0 |
278 |
++// CHECK-NEXT: 0xA R_X86_64_PLT32 puts 0xFFFFFFFFFFFFFFFC |
279 |
++// CHECK-NEXT: 0xF R_X86_64_32 .rodata.str1.1 0x6 |
280 |
++// CHECK-NEXT: 0x14 R_X86_64_PLT32 puts 0xFFFFFFFFFFFFFFFC |
281 |
++// CHECK-NEXT: 0x1F R_X86_64_GOTPCREL foo 0xFFFFFFFFFFFFFFFC |
282 |
++// CHECK-NEXT: } |
283 |
++// CHECK-NEXT: ] |
284 |
+ |
285 |
+ // CHECK: Symbol { |
286 |
+ // CHECK: Binding: Local |
287 |
+diff --git a/test/MC/ELF/ifunc-reloc.s b/test/MC/ELF/ifunc-reloc.s |
288 |
+index 6f1d79b22c4..b4917371b0f 100644 |
289 |
+--- a/test/MC/ELF/ifunc-reloc.s |
290 |
++++ b/test/MC/ELF/ifunc-reloc.s |
291 |
+@@ -11,6 +11,6 @@ alias: |
292 |
+ |
293 |
+ // CHECK: Relocations [ |
294 |
+ // CHECK-NEXT: Section {{.*}} .rela.text { |
295 |
+-// CHECK-NEXT: 0x1 R_X86_64_PC32 sym 0xFFFFFFFFFFFFFFFC |
296 |
++// CHECK-NEXT: 0x1 R_X86_64_PLT32 sym 0xFFFFFFFFFFFFFFFC |
297 |
+ // CHECK-NEXT: } |
298 |
+ // CHECK-NEXT: ] |
299 |
+diff --git a/test/MC/ELF/weak-diff.s b/test/MC/ELF/weak-diff.s |
300 |
+index ded89b8f833..9785a2befb1 100644 |
301 |
+--- a/test/MC/ELF/weak-diff.s |
302 |
++++ b/test/MC/ELF/weak-diff.s |
303 |
+@@ -2,7 +2,7 @@ |
304 |
+ |
305 |
+ // CHECK: Relocations [ |
306 |
+ // CHECK-NEXT: Section ({{.*}}) .rela.text { |
307 |
+-// CHECK-NEXT: 0x1D R_X86_64_PC32 f2 0xFFFFFFFFFFFFFFFC |
308 |
++// CHECK-NEXT: 0x1D R_X86_64_PLT32 f2 0xFFFFFFFFFFFFFFFC |
309 |
+ // CHECK-NEXT: } |
310 |
+ // CHECK-NEXT: ] |
311 |
+ |
312 |
+diff --git a/test/MC/ELF/weak-relocation.s b/test/MC/ELF/weak-relocation.s |
313 |
+index 19153aa50da..defaf4e6a38 100644 |
314 |
+--- a/test/MC/ELF/weak-relocation.s |
315 |
++++ b/test/MC/ELF/weak-relocation.s |
316 |
+@@ -9,6 +9,6 @@ bar: |
317 |
+ |
318 |
+ // CHECK: Relocations [ |
319 |
+ // CHECK-NEXT: Section ({{[0-9]+}}) .rela.text { |
320 |
+-// CHECK-NEXT: 0x1 R_X86_64_PC32 foo 0xFFFFFFFFFFFFFFFC |
321 |
++// CHECK-NEXT: 0x1 R_X86_64_PLT32 foo 0xFFFFFFFFFFFFFFFC |
322 |
+ // CHECK-NEXT: } |
323 |
+ // CHECK-NEXT: ] |
324 |
+diff --git a/test/MC/ELF/weakref-reloc.s b/test/MC/ELF/weakref-reloc.s |
325 |
+index baf80060c43..997aea0477a 100644 |
326 |
+--- a/test/MC/ELF/weakref-reloc.s |
327 |
++++ b/test/MC/ELF/weakref-reloc.s |
328 |
+@@ -9,6 +9,6 @@ |
329 |
+ // CHECK: Relocations [ |
330 |
+ // CHECK-NEXT: Section ({{[0-9]+}}) {{[^ ]+}} { |
331 |
+ // CHECK-NEXT: 0x1 R_X86_64_PLT32 zed 0xFFFFFFFFFFFFFFFC |
332 |
+-// CHECK-NEXT: 0x6 R_X86_64_PC32 foo 0xFFFFFFFFFFFFFFFC |
333 |
++// CHECK-NEXT: 0x6 R_X86_64_PLT32 foo 0xFFFFFFFFFFFFFFFC |
334 |
+ // CHECK-NEXT: } |
335 |
+ // CHECK-NEXT: ] |
336 |
+-- |
337 |
+2.18.0 |
338 |
+ |
339 |
|
340 |
diff --git a/sys-devel/llvm/llvm-6.0.1-r1.ebuild b/sys-devel/llvm/llvm-6.0.1-r1.ebuild |
341 |
new file mode 100644 |
342 |
index 00000000000..1d5d5a04df1 |
343 |
--- /dev/null |
344 |
+++ b/sys-devel/llvm/llvm-6.0.1-r1.ebuild |
345 |
@@ -0,0 +1,266 @@ |
346 |
+# Copyright 1999-2018 Gentoo Foundation |
347 |
+# Distributed under the terms of the GNU General Public License v2 |
348 |
+ |
349 |
+EAPI=6 |
350 |
+ |
351 |
+: ${CMAKE_MAKEFILE_GENERATOR:=ninja} |
352 |
+# (needed due to CMAKE_BUILD_TYPE != Gentoo) |
353 |
+CMAKE_MIN_VERSION=3.7.0-r1 |
354 |
+PYTHON_COMPAT=( python2_7 ) |
355 |
+ |
356 |
+inherit cmake-utils eapi7-ver flag-o-matic multilib-minimal \ |
357 |
+ multiprocessing pax-utils python-any-r1 toolchain-funcs |
358 |
+ |
359 |
+DESCRIPTION="Low Level Virtual Machine" |
360 |
+HOMEPAGE="https://llvm.org/" |
361 |
+SRC_URI="https://releases.llvm.org/${PV/_//}/${P/_/}.src.tar.xz |
362 |
+ !doc? ( https://dev.gentoo.org/~mgorny/dist/llvm/${P}-manpages.tar.bz2 )" |
363 |
+ |
364 |
+# Keep in sync with CMakeLists.txt |
365 |
+ALL_LLVM_TARGETS=( AArch64 AMDGPU ARM BPF Hexagon Lanai Mips MSP430 |
366 |
+ NVPTX PowerPC Sparc SystemZ X86 XCore ) |
367 |
+ALL_LLVM_TARGETS=( "${ALL_LLVM_TARGETS[@]/#/llvm_targets_}" ) |
368 |
+ |
369 |
+# Additional licenses: |
370 |
+# 1. OpenBSD regex: Henry Spencer's license ('rc' in Gentoo) + BSD. |
371 |
+# 2. ARM backend: LLVM Software Grant by ARM. |
372 |
+# 3. MD5 code: public-domain. |
373 |
+# 4. Tests (not installed): |
374 |
+# a. gtest: BSD. |
375 |
+# b. YAML tests: MIT. |
376 |
+ |
377 |
+LICENSE="UoI-NCSA rc BSD public-domain |
378 |
+ llvm_targets_ARM? ( LLVM-Grant )" |
379 |
+SLOT="$(ver_cut 1)" |
380 |
+KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~x86 ~amd64-fbsd ~amd64-linux ~ppc-macos ~x64-macos ~x86-macos" |
381 |
+IUSE="debug doc gold libedit +libffi ncurses test xar xml |
382 |
+ kernel_Darwin ${ALL_LLVM_TARGETS[*]}" |
383 |
+RESTRICT="!test? ( test )" |
384 |
+ |
385 |
+RDEPEND=" |
386 |
+ sys-libs/zlib:0= |
387 |
+ gold? ( >=sys-devel/binutils-2.22:*[cxx] ) |
388 |
+ libedit? ( dev-libs/libedit:0=[${MULTILIB_USEDEP}] ) |
389 |
+ libffi? ( >=virtual/libffi-3.0.13-r1:0=[${MULTILIB_USEDEP}] ) |
390 |
+ ncurses? ( >=sys-libs/ncurses-5.9-r3:0=[${MULTILIB_USEDEP}] ) |
391 |
+ xar? ( app-arch/xar ) |
392 |
+ xml? ( dev-libs/libxml2:2=[${MULTILIB_USEDEP}] )" |
393 |
+# configparser-3.2 breaks the build (3.3 or none at all are fine) |
394 |
+DEPEND="${RDEPEND} |
395 |
+ dev-lang/perl |
396 |
+ || ( >=sys-devel/gcc-3.0 >=sys-devel/llvm-3.5 |
397 |
+ ( >=sys-freebsd/freebsd-lib-9.1-r10 sys-libs/libcxx ) |
398 |
+ ) |
399 |
+ kernel_Darwin? ( |
400 |
+ <sys-libs/libcxx-$(ver_cut 1-3).9999 |
401 |
+ >=sys-devel/binutils-apple-5.1 |
402 |
+ ) |
403 |
+ doc? ( dev-python/sphinx ) |
404 |
+ gold? ( sys-libs/binutils-libs ) |
405 |
+ libffi? ( virtual/pkgconfig ) |
406 |
+ !!<dev-python/configparser-3.3.0.2 |
407 |
+ ${PYTHON_DEPS}" |
408 |
+# There are no file collisions between these versions but having :0 |
409 |
+# installed means llvm-config there will take precedence. |
410 |
+RDEPEND="${RDEPEND} |
411 |
+ !sys-devel/llvm:0" |
412 |
+PDEPEND="sys-devel/llvm-common |
413 |
+ gold? ( >=sys-devel/llvmgold-${SLOT} )" |
414 |
+ |
415 |
+REQUIRED_USE="${PYTHON_REQUIRED_USE} |
416 |
+ || ( ${ALL_LLVM_TARGETS[*]} )" |
417 |
+ |
418 |
+S=${WORKDIR}/${P/_/}.src |
419 |
+ |
420 |
+# least intrusive of all |
421 |
+CMAKE_BUILD_TYPE=RelWithDebInfo |
422 |
+ |
423 |
+src_prepare() { |
424 |
+ # Fix llvm-config for shared linking and sane flags |
425 |
+ # https://bugs.gentoo.org/show_bug.cgi?id=565358 |
426 |
+ eapply "${FILESDIR}"/9999/0007-llvm-config-Clean-up-exported-values-update-for-shar.patch |
427 |
+ |
428 |
+ # Fix appending -Wl,-rpath-link on non-Linux (-> FreeBSD). |
429 |
+ eapply "${FILESDIR}"/6.0.1/0001-cmake-Append-Wl-rpath-link-conditionally-to-GNULD.patch |
430 |
+ |
431 |
+ # Fix assembly compatibility with binutils-2.31.1 |
432 |
+ # https://bugs.gentoo.org/663442 |
433 |
+ eapply "${FILESDIR}"/6.0.1/0002-llvm-mc-Produce-R_X86_64_PLT32-for-call-jmp-foo.patch |
434 |
+ |
435 |
+ # disable use of SDK on OSX, bug #568758 |
436 |
+ sed -i -e 's/xcrun/false/' utils/lit/lit/util.py || die |
437 |
+ |
438 |
+ # User patches + QA |
439 |
+ cmake-utils_src_prepare |
440 |
+} |
441 |
+ |
442 |
+multilib_src_configure() { |
443 |
+ local ffi_cflags ffi_ldflags |
444 |
+ if use libffi; then |
445 |
+ ffi_cflags=$($(tc-getPKG_CONFIG) --cflags-only-I libffi) |
446 |
+ ffi_ldflags=$($(tc-getPKG_CONFIG) --libs-only-L libffi) |
447 |
+ fi |
448 |
+ |
449 |
+ local libdir=$(get_libdir) |
450 |
+ local mycmakeargs=( |
451 |
+ # disable appending VCS revision to the version to improve |
452 |
+ # direct cache hit ratio |
453 |
+ -DLLVM_APPEND_VC_REV=OFF |
454 |
+ -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr/lib/llvm/${SLOT}" |
455 |
+ -DLLVM_LIBDIR_SUFFIX=${libdir#lib} |
456 |
+ |
457 |
+ -DBUILD_SHARED_LIBS=ON |
458 |
+ -DLLVM_TARGETS_TO_BUILD="${LLVM_TARGETS// /;}" |
459 |
+ -DLLVM_BUILD_TESTS=$(usex test) |
460 |
+ |
461 |
+ -DLLVM_ENABLE_FFI=$(usex libffi) |
462 |
+ -DLLVM_ENABLE_LIBEDIT=$(usex libedit) |
463 |
+ -DLLVM_ENABLE_TERMINFO=$(usex ncurses) |
464 |
+ -DLLVM_ENABLE_LIBXML2=$(usex xml) |
465 |
+ -DLLVM_ENABLE_ASSERTIONS=$(usex debug) |
466 |
+ -DLLVM_ENABLE_EH=ON |
467 |
+ -DLLVM_ENABLE_RTTI=ON |
468 |
+ |
469 |
+ -DWITH_POLLY=OFF # TODO |
470 |
+ |
471 |
+ -DLLVM_HOST_TRIPLE="${CHOST}" |
472 |
+ |
473 |
+ -DFFI_INCLUDE_DIR="${ffi_cflags#-I}" |
474 |
+ -DFFI_LIBRARY_DIR="${ffi_ldflags#-L}" |
475 |
+ # used only for llvm-objdump tool |
476 |
+ -DHAVE_LIBXAR=$(multilib_native_usex xar 1 0) |
477 |
+ |
478 |
+ # disable OCaml bindings (now in dev-ml/llvm-ocaml) |
479 |
+ -DOCAMLFIND=NO |
480 |
+ ) |
481 |
+ |
482 |
+# Note: go bindings have no CMake rules at the moment |
483 |
+# but let's kill the check in case they are introduced |
484 |
+# if ! multilib_is_native_abi || ! use go; then |
485 |
+ mycmakeargs+=( |
486 |
+ -DGO_EXECUTABLE=GO_EXECUTABLE-NOTFOUND |
487 |
+ ) |
488 |
+# fi |
489 |
+ |
490 |
+ use test && mycmakeargs+=( |
491 |
+ -DLLVM_LIT_ARGS="-vv;-j;${LIT_JOBS:-$(makeopts_jobs "${MAKEOPTS}" "$(get_nproc)")}" |
492 |
+ ) |
493 |
+ |
494 |
+ if multilib_is_native_abi; then |
495 |
+ mycmakeargs+=( |
496 |
+ -DLLVM_BUILD_DOCS=$(usex doc) |
497 |
+ -DLLVM_ENABLE_OCAMLDOC=OFF |
498 |
+ -DLLVM_ENABLE_SPHINX=$(usex doc) |
499 |
+ -DLLVM_ENABLE_DOXYGEN=OFF |
500 |
+ -DLLVM_INSTALL_UTILS=ON |
501 |
+ ) |
502 |
+ use doc && mycmakeargs+=( |
503 |
+ -DCMAKE_INSTALL_MANDIR="${EPREFIX}/usr/lib/llvm/${SLOT}/share/man" |
504 |
+ -DLLVM_INSTALL_SPHINX_HTML_DIR="${EPREFIX}/usr/share/doc/${PF}/html" |
505 |
+ -DSPHINX_WARNINGS_AS_ERRORS=OFF |
506 |
+ ) |
507 |
+ use gold && mycmakeargs+=( |
508 |
+ -DLLVM_BINUTILS_INCDIR="${EPREFIX}"/usr/include |
509 |
+ ) |
510 |
+ fi |
511 |
+ |
512 |
+ if tc-is-cross-compiler; then |
513 |
+ local tblgen="${EPREFIX}/usr/lib/llvm/${SLOT}/bin/llvm-tblgen" |
514 |
+ [[ -x "${tblgen}" ]] \ |
515 |
+ || die "${tblgen} not found or usable" |
516 |
+ mycmakeargs+=( |
517 |
+ -DCMAKE_CROSSCOMPILING=ON |
518 |
+ -DLLVM_TABLEGEN="${tblgen}" |
519 |
+ ) |
520 |
+ fi |
521 |
+ |
522 |
+ # workaround BMI bug in gcc-7 (fixed in 7.4) |
523 |
+ # https://bugs.gentoo.org/649880 |
524 |
+ # apply only to x86, https://bugs.gentoo.org/650506 |
525 |
+ if tc-is-gcc && [[ ${MULTILIB_ABI_FLAG} == abi_x86* ]] && |
526 |
+ [[ $(gcc-major-version) -eq 7 && $(gcc-minor-version) -lt 4 ]] |
527 |
+ then |
528 |
+ local CFLAGS="${CFLAGS} -mno-bmi" |
529 |
+ local CXXFLAGS="${CXXFLAGS} -mno-bmi" |
530 |
+ fi |
531 |
+ |
532 |
+ # LLVM_ENABLE_ASSERTIONS=NO does not guarantee this for us, #614844 |
533 |
+ use debug || local -x CPPFLAGS="${CPPFLAGS} -DNDEBUG" |
534 |
+ cmake-utils_src_configure |
535 |
+} |
536 |
+ |
537 |
+multilib_src_compile() { |
538 |
+ cmake-utils_src_compile |
539 |
+ |
540 |
+ pax-mark m "${BUILD_DIR}"/bin/llvm-rtdyld |
541 |
+ pax-mark m "${BUILD_DIR}"/bin/lli |
542 |
+ pax-mark m "${BUILD_DIR}"/bin/lli-child-target |
543 |
+ |
544 |
+ if use test; then |
545 |
+ pax-mark m "${BUILD_DIR}"/unittests/ExecutionEngine/Orc/OrcJITTests |
546 |
+ pax-mark m "${BUILD_DIR}"/unittests/ExecutionEngine/MCJIT/MCJITTests |
547 |
+ pax-mark m "${BUILD_DIR}"/unittests/Support/SupportTests |
548 |
+ fi |
549 |
+} |
550 |
+ |
551 |
+multilib_src_test() { |
552 |
+ # respect TMPDIR! |
553 |
+ local -x LIT_PRESERVES_TMP=1 |
554 |
+ cmake-utils_src_make check |
555 |
+} |
556 |
+ |
557 |
+src_install() { |
558 |
+ local MULTILIB_CHOST_TOOLS=( |
559 |
+ /usr/lib/llvm/${SLOT}/bin/llvm-config |
560 |
+ ) |
561 |
+ |
562 |
+ local MULTILIB_WRAPPED_HEADERS=( |
563 |
+ /usr/include/llvm/Config/llvm-config.h |
564 |
+ ) |
565 |
+ |
566 |
+ local LLVM_LDPATHS=() |
567 |
+ multilib-minimal_src_install |
568 |
+ |
569 |
+ # move wrapped headers back |
570 |
+ mv "${ED%/}"/usr/include "${ED%/}"/usr/lib/llvm/${SLOT}/include || die |
571 |
+} |
572 |
+ |
573 |
+multilib_src_install() { |
574 |
+ cmake-utils_src_install |
575 |
+ |
576 |
+ # move headers to /usr/include for wrapping |
577 |
+ rm -rf "${ED%/}"/usr/include || die |
578 |
+ mv "${ED%/}"/usr/lib/llvm/${SLOT}/include "${ED%/}"/usr/include || die |
579 |
+ |
580 |
+ LLVM_LDPATHS+=( "${EPREFIX}/usr/lib/llvm/${SLOT}/$(get_libdir)" ) |
581 |
+} |
582 |
+ |
583 |
+multilib_src_install_all() { |
584 |
+ local revord=$(( 9999 - ${SLOT} )) |
585 |
+ cat <<-_EOF_ > "${T}/10llvm-${revord}" || die |
586 |
+ PATH="${EPREFIX}/usr/lib/llvm/${SLOT}/bin" |
587 |
+ # we need to duplicate it in ROOTPATH for Portage to respect... |
588 |
+ ROOTPATH="${EPREFIX}/usr/lib/llvm/${SLOT}/bin" |
589 |
+ MANPATH="${EPREFIX}/usr/lib/llvm/${SLOT}/share/man" |
590 |
+ LDPATH="$( IFS=:; echo "${LLVM_LDPATHS[*]}" )" |
591 |
+_EOF_ |
592 |
+ doenvd "${T}/10llvm-${revord}" |
593 |
+ |
594 |
+ # install pre-generated manpages |
595 |
+ if ! use doc; then |
596 |
+ # (doman does not support custom paths) |
597 |
+ insinto "/usr/lib/llvm/${SLOT}/share/man/man1" |
598 |
+ doins "${WORKDIR}/${P}-manpages/llvm"/*.1 |
599 |
+ fi |
600 |
+ |
601 |
+ docompress "/usr/lib/llvm/${SLOT}/share/man" |
602 |
+} |
603 |
+ |
604 |
+pkg_postinst() { |
605 |
+ elog "You can find additional opt-viewer utility scripts in:" |
606 |
+ elog " ${EROOT}/usr/lib/llvm/${SLOT}/share/opt-viewer" |
607 |
+ elog "To use these scripts, you will need Python 2.7 along with the following" |
608 |
+ elog "packages:" |
609 |
+ elog " dev-python/pygments (for opt-viewer)" |
610 |
+ elog " dev-python/pyyaml (for all of them)" |
611 |
+} |