[llvm-bugs] [Bug 38864] New: clang fails building ppc64le Linux kernel

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Sep 7 00:59:15 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=38864

            Bug ID: 38864
           Summary: clang fails building ppc64le Linux kernel
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: joel at jms.id.au
                CC: llvm-bugs at lists.llvm.org

Created attachment 20852
  --> https://bugs.llvm.org/attachment.cgi?id=20852&action=edit
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: https://patchwork.ozlabs.org/patch/966825/

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

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180907/9f20466d/attachment-0001.html>


More information about the llvm-bugs mailing list