[clang] [lld] [Driver] Default enable LoongArch linker relaxation (PR #111488)

via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 15 01:31:25 PDT 2024


ywgrit wrote:

> > How about now?
> 
> The patch doesn't touch lld, so my suggestion is "[Driver] Default enable LoongArch linker relaxation".
> 
Thanks, the title has changed.

> Some additional comments:
> 
> * Do we need to consider the `-gsplit-dwarf` issue [MC: "error: A dwo section may not contain relocations" when building with fission + RISCV64 #56642](https://github.com/llvm/llvm-project/issues/56642) resolved by https://reviews.llvm.org/D130190 ?

The code has been implemented and tested, just like riscv, I think this part of the code can be put together with this change.

> * The `--no-relax` option should be passed to linker, see [[Clang][RISCV] Forward --no-relax option to linker for RISC-V #76432](https://github.com/llvm/llvm-project/pull/76432)

The code remains consistent with RISCV.

> * Pass `-X` to linker to discard a plethora of `.L` symbols due to linker relaxation. See https://reviews.llvm.org/D127826

Discard_sec_merge is used by default in GNU ld, and in LoongArch's definition, it converts the use of discard_sec_merge to the use of discard_l, as shown in the code below. So our changes are consistent with RISCV.
```
  if (link_info.discard == discard_sec_merge)
    link_info.discard = discard_l;
```

Should we put together the two part of code of pass --no-relax and -X with this change? These three parts of code (including this change) don't seem to have much to do with each other.

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


More information about the cfe-commits mailing list