nuttx: RISC-V linker fail, relocation truncated to fit: R_RISCV_HI20
When I try to compile nuttx hash: f39de6fd1a config: rv-virt:smp64 tookchain: riscv64-unknown-elf-gcc (g2ee5e430018) 12.2.0
riscv64-unknown-elf-ld: warning: /home/ubuntu/nuttxSpace/nuttx/nuttx has a LOAD segment with RWX permissions
/opt/riscv/lib/gcc/riscv64-unknown-elf/12.2.0/libgcc.a(_clzsi2.o): in function `__clzdi2':
/home/ubuntu/riscv-gnu-toolchain/build-gcc-newlib-stage2/riscv64-unknown-elf/libgcc/../../.././gcc/libgcc/libgcc2.c:690:(.text+0x18): relocation truncated to fit: R_RISCV_HI20 against symbol `__clz_tab' defined in .rodata section in /opt/riscv/lib/gcc/riscv64-unknown-elf/12.2.0/libgcc.a(_clz.o)
Does anyone meet this problem?
About this issue
- Original URL
- State: closed
- Created 10 months ago
- Reactions: 1
- Comments: 23 (23 by maintainers)
If you do not need to compile C++ code then you can use the latest toolchain from https://github.com/sifive/freedom-tools/releases
Thanks for your notifacation, maybe we can consider to use xPack’s toolchain for risc-v in CI.
@lupyuen libm issue could be fixed by select from nuttx, newlib, libmcs and openlibm if toolchain doesn’t provide one: https://github.com/apache/nuttx/blob/master/libs/libm/Kconfig#L6-L61
xPack’s toolchain may not fix this problem, I got its compile configurations by
--verbose:The toolchain from Ubuntu/Debian may works since it compiled with
-mcmodel=medanybut it lacks of libm:I downloaded and installed the same toolchain and am able to reproduce an issue. I think the case is that toolchain is build without support of
medanymodel asriscv64-unknown-elf-gcc -voutputsI think the best would be to use toolchain from https://github.com/apache/nuttx/pull/10306