[Bug target/91420] relocation truncated to fit: R_RISCV_HI20 against `.LC0' with GCC 8.2/8.3 with "-O2" on RISC-V

belegdol at gmail dot com gcc-bugzilla@gcc.gnu.org
Sun Mar 1 11:40:41 GMT 2026


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91420

Julian Sikorski <belegdol at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |belegdol at gmail dot com

--- Comment #15 from Julian Sikorski <belegdol at gmail dot com> ---
I have been experiencing this issue when attempting to build mame for riscv64:
https://riscv-koji.fedoraproject.org/koji/taskinfo?taskID=139782
This is already with --mcmodel=medany. With --mcmodel=large, the program would
not build due to incompatibility with -fPIC:
https://riscv-koji.fedoraproject.org/koji/taskinfo?taskID=140659
Trying to use lld on gcc generated code resulted in a different relocation
issue (error: relocation refers to a symbol in a discarded section: .LFB7279):
https://riscv-koji.fedoraproject.org/koji/taskinfo?taskID=140665
Finally, switching to llvm toolchain entirely has allowed for a successful
build:
https://riscv-koji.fedoraproject.org/koji/taskinfo?taskID=140779
I am now checking whether llvm needs --mcmodel=medany and will report back.


More information about the Gcc-bugs mailing list