[RFC] riscv32 compiler flags
Heinrich Schuchardt
heinrich.schuchardt at canonical.com
Sat Oct 8 10:23:47 CEST 2022
Hello Rick, hello Leo,
in origin master we have moved to compiling riscv32 using the GCC the
32bit toolchain provided by kernel.org. This works fine with GCC-11.
Tom now tried to move to GCC-12. Here libgcc.a is compiled with:
readelf -h
/opt/gcc-12.2.0-nolibc/riscv32-linux/lib/gcc/riscv32-linux/12.2.0/libgcc.a
Flags: 0x5, RVC, double-float ABI
while up to now our code is compiled with
readelf -h arch/riscv/cpu/start.o
Flags: 0x1, RVC, soft-float ABI
This leads to a linking error:
/opt/gcc-12.2.0-nolibc/riscv32-linux/bin/riscv32-linux-ld.bfd:
/opt/gcc-12.2.0-nolibc/riscv32-linux/bin/../lib/gcc/riscv32-linux/12.2.0/libgcc.a(_lshrdi3.o):
can't link double-float modules with soft-float module
This can be reproduced with
sudo docker pull trini/u-boot-gitlab-ci-runner:jammy-20221003-08Oct2022
sudo docker run -ti
trini/u-boot-gitlab-ci-runner:jammy-20221003-08Oct2022 /bin/bash
CROSS_COMPILE=/opt/gcc-12.2.0-nolibc/riscv32-linux/bin/riscv32-linux-
cd ~
git clone https://source.denx.de/u-boot/u-boot.git
cd u-boot/
git checkout origin/WIP/update-to-llvm-14-gcc-12.2
Building U-Boot with
-march=rv32imafdc -mabi=ilp32d
instead of
-march=rv32iac -mabi=ilp32
results in binaries that can be linked to libgcc.a.
Neither U-Boot nor the linked libgcc code actually uses floating-point
numbers. So the generated code probably is just the same.
We already have CONFIG_RISCV_ISA_C and CONFIG_RISCV_ISA_A to tune the
build flags for U-Boot.
I will try to create a patch that adds configuration settings for the F
and D extension.
Best regards
Heinrich
More information about the U-Boot
mailing list