<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - clang fails building ppc64le Linux kernel"
href="https://bugs.llvm.org/show_bug.cgi?id=38864">38864</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang fails building ppc64le Linux kernel
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>joel@jms.id.au
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=20852" name="attach_20852" title="preprocesed source for kernel/irq/manage.c">attachment 20852</a> <a href="attachment.cgi?id=20852&action=edit" title="preprocesed source for kernel/irq/manage.c">[details]</a></span>
preprocesed source for kernel/irq/manage.c
I am attempting to build the powerpc Linux kernel (v4.19-rc2) with clang.
At link time, it will fail with a number of failed relocations:
ld: kernel/irq/manage.o: in function `local_bh_enable':
manage.c:(.text+0x3ccc): relocation truncated to fit: R_PPC64_ADDR16_HA against
`.text'+3cb8
0000000000003cb0 <local_bh_enable>:
3cb0: 00 00 4c 3c addis r2,r12,0
3cb4: 00 00 42 38 addi r2,r2,0
3cb8: a6 02 08 7c mflr r0
3cbc: 10 00 01 f8 std r0,16(r1)
3cc0: e1 ff 21 f8 stdu r1,-32(r1)
3cc4: 00 00 60 38 li r3,0
3cc8: 00 02 80 38 li r4,512
3ccc: 00 00 63 3c addis r3,r3,0
3cd0: 01 00 00 48 bl 3cd0 <local_bh_enable+0x20>
3cd4: 00 00 00 60 nop
3cd8: 20 00 21 38 addi r1,r1,32
3cdc: 10 00 01 e8 ld r0,16(r1)
3ce0: a6 03 08 7c mtlr r0
3ce4: 20 00 80 4e blr
It is suspected that the use of _THIS_IP_ is the cause of the error. On GCC
this is placed in the TOC, but that is not the case for clang. I was able to
reproduce with clang trunk.
I've attached the preprocessed source file. Here's the line used to compile it:
clang-7 -nostdinc -Qunused-arguments -Wall -Wundef -Wstrict-prototypes
-Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar
-Werror-implicit-function-declaration -Wno-format-security -std=gnu89
-no-integrated-as -fno-PIE -mlittle-endian -m64 -msoft-float -pipe
-Iarch/powerpc -mabi=elfv2 -mcmodel=medium -mcpu=power8 -mtune=power9
-mno-altivec -mno-vsx -funit-at-a-time -fno-dwarf2-cfi-asm -Wa,-maltivec
-Wa,-mpower8 -mlittle-endian -fno-delete-null-pointer-checks
-Wno-duplicate-decl-specifier -O2 -Wframe-larger-than=2048 -fno-stack-protector
-Wno-format-invalid-specifier -Wno-gnu -Wno-address-of-packed-member
-Wno-tautological-compare -mno-global-merge -Wno-unused-const-variable
-fomit-frame-pointer -g -fno-var-tracking -Wdeclaration-after-statement
-Wno-pointer-sign -fno-strict-overflow -fno-merge-all-constants
-fno-stack-check -Werror=implicit-int -Werror=strict-prototypes
-Werror=date-time -Werror=incompatible-pointer-types -Wno-initializer-overrides
-Wno-unused-value -Wno-format -Wno-sign-compare -Wno-format-zero-length
-Wno-uninitialized -c -o manage.o manage.i
To reproduce from kernel sources:
Apply this patch: <a href="https://patchwork.ozlabs.org/patch/966825/">https://patchwork.ozlabs.org/patch/966825/</a>
make ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- powernv_defconfig
./scripts/config -e PPC_DISABLE_WERROR
./scripts/config -d FTRACE
./scripts/config -d BTRFS_FS
./scripts/config -d MD_RAID456
make CC=clang-7 CLANG_TRIPLE=powerpc64le-linux-gnu \
ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu-
ld: kernel/irq/manage.o: in function `local_bh_enable':
/scratch/joel/linus/./include/linux/bottom_half.h:32:(.text+0x3ccc): relocation
truncated to fit: R_PPC64_ADDR16_HA against `.text'+3cb8
ld: kernel/rcu/srcutree.o: in function `local_bh_enable':
/scratch/joel/linus/./include/linux/bottom_half.h:32:(.text+0x258c): relocation
truncated to fit: R_PPC64_ADDR16_HA against `.text'+2578
ld: kernel/time/hrtimer.o: in function `local_bh_enable':
/scratch/joel/linus/./include/linux/bottom_half.h:32:(.text+0x242c): relocation
truncated to fit: R_PPC64_ADDR16_HA against `.text'+2418
ld: kernel/bpf/cpumap.o: in function `local_bh_enable':
/scratch/joel/linus/./include/linux/bottom_half.h:32:(.text+0x134c): relocation
truncated to fit: R_PPC64_ADDR16_HA against `.text'+1338
ld: drivers/net/ethernet/broadcom/tg3.o: in function `local_bh_enable':
/scratch/joel/linus/./include/linux/bottom_half.h:32:(.text+0x87dc): relocation
truncated to fit: R_PPC64_ADDR16_HA against `.text'+87c8
ld: drivers/net/ethernet/intel/e1000/e1000_main.o: in function
`local_bh_enable':
/scratch/joel/linus/./include/linux/bottom_half.h:32:(.text+0xc13c): relocation
truncated to fit: R_PPC64_ADDR16_HA against `.text'+c128
ld: net/core/sock.o: in function `local_bh_enable':
/scratch/joel/linus/./include/linux/bottom_half.h:32:(.text+0x5a6c): relocation
truncated to fit: R_PPC64_ADDR16_HA against `.text'+5a58
ld: net/core/gen_estimator.o: in function `local_bh_enable':
/scratch/joel/linus/./include/linux/bottom_half.h:32:(.text+0x2ec): relocation
truncated to fit: R_PPC64_ADDR16_HA against `.text'+2d8
ld: net/core/dev.o: in function `local_bh_enable':
/scratch/joel/linus/./include/linux/bottom_half.h:32:(.text+0x8a6c): relocation
truncated to fit: R_PPC64_ADDR16_HA against `.text'+8a58
ld: net/core/neighbour.o: in function `local_bh_enable':
/scratch/joel/linus/./include/linux/bottom_half.h:32:(.text+0x1f2c): relocation
truncated to fit: R_PPC64_ADDR16_HA against `.text'+1f18
ld: net/sched/sch_generic.o: in function `local_bh_enable':
/scratch/joel/linus/./include/linux/bottom_half.h:32:(.text+0x392c): additional
relocation overflows omitted from the output</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>