<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 - -fPIC causes issues with building the Linux kernel"
href="https://bugs.llvm.org/show_bug.cgi?id=44854">44854</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>-fPIC causes issues with building the Linux kernel
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Other
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</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>Backend: RISC-V
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>natechancellor@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>asb@lowrisc.org, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>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:
<a href="https://elixir.bootlin.com/linux/v5.5.2/source/arch/riscv/Makefile#L16">https://elixir.bootlin.com/linux/v5.5.2/source/arch/riscv/Makefile#L16</a>
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:
<a href="https://gist.github.com/b15e69f181fe1dcabb05414da00575eb">https://gist.github.com/b15e69f181fe1dcabb05414da00575eb</a></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>