feat: Support RISC-V call relaxation#1552
Conversation
|
This PR contains two commits. The first implements call relaxation based on the previously implemented byte reduction tracking infrastructure. However, I found that this approach alone has limitations for applying relaxation generically. Without iterative relaxation, applying relaxation across object files proves difficult (as demonstrated by the |
davidlattimore
left a comment
There was a problem hiding this comment.
Could be good to get @marxin's thoughts, but I think that should be post-submission, since I want to reduce the potential for merge conflicts with the changes I'm making, so getting this submitted sooner rather than later seems like a good idea.
| } | ||
| } | ||
|
|
||
| /// Compute the output address of every loaded input section across all object files. |
There was a problem hiding this comment.
Wow, that sounds expensive. But I think it's fine for now since it only affects riscv and it can be turned off with --no-relax. At some point, we should possibly think about ways to make this cheaper.
|
My general view is that code relaxations aren’t worth the added linker complexity and longer link times (see: https://maskray.me/blog/2021-03-14-the-dark-side-of-riscv-linker-relaxation |
part of #874
This relaxation replaces
auipc+jalrpairs (function calls viacall) with a singlejalinstruction when the target is within ±1 MiB.Below are the test results using the added
wild/tests/sources/riscv-call-relaxation.s. First, the original code callsnearby_funcusingcall, which has been replaced withjal.And the reduced
_startsymbol size resulting from this has also been updated in the symbol table.