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: unassignedb...@nondot.org
Reporter: natechancel...@gmail.com
CC: a...@lowrisc.org, llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs