[llvm] [clang] [RISCV] Always emit relocations for resolved symbols and relax (PR #73793)

Andreu Carminati via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 1 00:52:01 PST 2023


andcarminati wrote:

> As far as I can tell this is pointless. If you want relaxation you need R_RISCV_RELAX and R_RISC_ALIGN relocations to be emitted. If you don't want relaxation you don't need these. Therefore it seems like all this does is emit a whole bunch of useless relocations for the case when you're not enabling relaxation at compile time and thus cannot possibly enable it at link time?

Hi @jrtc27, thank you for your comment, understood your point. For relaxation, I think we need also the branch relocation/anything relative, as we are removing some lui instructions. My original idea was based on the case that relaxation is a default ON feature for RISCV, but I honestly don't know the use cases to disable it.

Just to follow the discussion, I can consider the following use case:

clang [...] -c -o myobject.o (just compile)
clang [...] my0bject.o -o myobject.elf -mno-relax (linking)

In this case, myobject.elf will be relaxed, the -mno-relax will be silently ignored.

Maybe we have two different things to handle.

Regards.

https://github.com/llvm/llvm-project/pull/73793


More information about the cfe-commits mailing list