Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-fPIC causes issues with building the Linux kernel #44199

Closed
nathanchance opened this issue Feb 9, 2020 · 5 comments
Closed

-fPIC causes issues with building the Linux kernel #44199

nathanchance opened this issue Feb 9, 2020 · 5 comments
Labels
backend:RISC-V bugzilla Issues migrated from bugzilla

Comments

@nathanchance
Copy link
Member

Bugzilla Link 44854
Version trunk
OS All
CC @asb,@efriedma-quic,@nickdesaulniers,@lenary

Extended Description

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

@efriedma-quic
Copy link
Collaborator

That syntax looks fine. What version of binutils are you using?

@nathanchance
Copy link
Member Author

$ riscv64-linux-gnu-as --version | head -n1
GNU assembler (GNU Binutils for Debian) 2.31.1

I can try a newer version once I am home from traveling.

@llvmbot
Copy link
Member

llvmbot commented Feb 9, 2020

Just tried running

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

and it succeeded. Problem with GNU as confirmed.

@nathanchance
Copy link
Member Author

I still see this with ToT binutils

$ ./bin/riscv64-linux-gnu-as --version | head -n1
GNU assembler (GNU Binutils) 2.34.50.20200210

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
@nathanchance
Copy link
Member Author

I don't think this is reproducible any longer and we have since moved onto compiling the RISC-V with the integrated assembler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:RISC-V bugzilla Issues migrated from bugzilla
Projects
None yet
Development

No branches or pull requests

3 participants