[llvm-bugs] [Bug 44854] New: -fPIC causes issues with building the Linux kernel

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Feb 9 05:05:54 PST 2020


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

            Bug ID: 44854
           Summary: -fPIC causes issues with building the Linux kernel
           Product: libraries
           Version: trunk
          Hardware: Other
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: RISC-V
          Assignee: unassignedbugs at nondot.org
          Reporter: natechancellor at gmail.com
                CC: asb at lowrisc.org, llvm-bugs at lists.llvm.org

Attempting to build a Linux kernel with tip of tree results in an assembler
error in fs/nfs/flexfilelayout/flexfilelayout.o:

$ make -j$(nproc) ARCH=riscv CC=clang-11 CROSS_COMPILE=riscv64-linux-gnu-
HOSTCC=clang-11 O=/out.riscv distclean defconfig
fs/nfs/flexfilelayout/flexfilelayout.o
...

/tmp/flexfilelayout-143baf.s: Assembler messages:                              
                                                           [0/99810]
/tmp/flexfilelayout-143baf.s:37: Error: bad expression                          
/tmp/flexfilelayout-143baf.s:37: Error: illegal operands `auipc
a0,%got_pcrel_hi(kmalloc_caches)'
/tmp/flexfilelayout-143baf.s:232: Error: bad expression                         
/tmp/flexfilelayout-143baf.s:232: Error: illegal operands `auipc
a2,%got_pcrel_hi(kmalloc_caches)'
/tmp/flexfilelayout-143baf.s:359: Error: bad expression                         
/tmp/flexfilelayout-143baf.s:359: Error: illegal operands `auipc
a0,%got_pcrel_hi(mem_map)'
/tmp/flexfilelayout-143baf.s:367: Error: bad expression                         
/tmp/flexfilelayout-143baf.s:367: Error: illegal operands `auipc
a2,%got_pcrel_hi(pfn_base)'
/tmp/flexfilelayout-143baf.s:374: Error: bad expression                         
/tmp/flexfilelayout-143baf.s:374: Error: illegal operands `auipc
a3,%got_pcrel_hi(va_pa_offset)'
/tmp/flexfilelayout-143baf.s:429: Error: bad expression                         
/tmp/flexfilelayout-143baf.s:429: Error: illegal operands `auipc
a1,%got_pcrel_hi(kmalloc_caches)'
/tmp/flexfilelayout-143baf.s:478: Error: bad expression                         
/tmp/flexfilelayout-143baf.s:478: Error: illegal operands `auipc
a0,%got_pcrel_hi(kmalloc_caches)'       
/tmp/flexfilelayout-143baf.s:755: Error: bad expression                         
/tmp/flexfilelayout-143baf.s:755: Error: illegal operands `auipc
a0,%got_pcrel_hi(init_user_ns)'
/tmp/flexfilelayout-143baf.s:797: Error: bad expression                         
/tmp/flexfilelayout-143baf.s:797: Error: illegal operands `auipc
a0,%got_pcrel_hi(init_user_ns)'
/tmp/flexfilelayout-143baf.s:1702: Error: bad expression                        
/tmp/flexfilelayout-143baf.s:1702: Error: illegal operands `auipc
a0,%got_pcrel_hi(kmalloc_caches)'
/tmp/flexfilelayout-143baf.s:1777: Error: bad expression                        
/tmp/flexfilelayout-143baf.s:1777: Error: illegal operands `auipc
a1,%got_pcrel_hi(kmalloc_caches)'
/tmp/flexfilelayout-143baf.s:3291: Error: bad expression                        
/tmp/flexfilelayout-143baf.s:3291: Error: illegal operands `auipc
a2,%got_pcrel_hi(__per_cpu_offset)'
/tmp/flexfilelayout-143baf.s:3599: Error: bad expression                        
/tmp/flexfilelayout-143baf.s:3599: Error: illegal operands `auipc
a1,%got_pcrel_hi(layoutstats_timer)'
/tmp/flexfilelayout-143baf.s:4219: Error: bad expression                        
/tmp/flexfilelayout-143baf.s:4219: Error: illegal operands `auipc
a1,%got_pcrel_hi(layoutstats_timer)'
/tmp/flexfilelayout-143baf.s:4718: Error: bad expression                        
/tmp/flexfilelayout-143baf.s:4718: Error: illegal operands `auipc
a1,%got_pcrel_hi(layoutstats_timer)'
/tmp/flexfilelayout-143baf.s:5644: Error: bad expression                        
/tmp/flexfilelayout-143baf.s:5644: Error: illegal operands `auipc
a3,%got_pcrel_hi(mem_map)'                          
/tmp/flexfilelayout-143baf.s:5654: Error: bad expression                        
/tmp/flexfilelayout-143baf.s:5654: Error: illegal operands `auipc
a2,%got_pcrel_hi(pfn_base)'
/tmp/flexfilelayout-143baf.s:5661: Error: bad expression                        
/tmp/flexfilelayout-143baf.s:5661: Error: illegal operands `auipc
a3,%got_pcrel_hi(va_pa_offset)'                                                 
clang: error: assembler command failed with exit code 1 (use -v to see
invocation)
...

I narrowed it down to the use of -fPIC, which is used with kernel modules:
https://elixir.bootlin.com/linux/v5.5.2/source/arch/riscv/Makefile#L16

creduce spits out:

$ cat flexfilelayout.i
a() { b(a); }

$ cat test.sh
clang-11 --target=riscv64-linux-gnu --prefix=/usr/bin/ --gcc-toolchain=/usr
-no-integrated-as -mabi=lp64 -march=rv64imac -mcmodel=medany -O2 -c -o /
dev/null flexfilelayout.i || exit ${?}
! clang-11 --target=riscv64-linux-gnu --prefix=/usr/bin/ --gcc-toolchain=/usr
-no-integrated-as -mabi=lp64 -march=rv64imac -mcmodel=medany -O2 -fPIC
 -c -o /dev/null flexfilelayout.i

Full preprocessed file available here:
https://gist.github.com/b15e69f181fe1dcabb05414da00575eb

-- 
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/20200209/46f01a32/attachment.html>


More information about the llvm-bugs mailing list