This is in accordance with avr-gcc, even '-mno-relax' is specified
to avr-gcc, this flag will also be added to the output relocatables.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/test/MC/AVR/elf_header.s | ||
---|---|---|
71 | This is the newly added ELF flag. |
I'm concerned of this change. Do you intend to add linker relaxation to lld/ELF's AVR port? Implementing features is indeed fun but I am unsure whether the use case has a sufficient demand of the feature.
RISC-V linker relaxation has greatly increased code complexity and LoongArch folks want to copy that. I don't want to see a third arch which may use a non-recommended way implementing linker relaxation.
I have no plan for adding linker relaxation to lld/ELF's AVR port, at least, you can deny that if you think it introduces complexity to lld.
However, avr-ld indeed has already implemented linker relaxation, my current patch can make use of it, and clang+avr-ld can generate shorter assembly.
I think we should understand what this flag does and how it affects assemblers/linkers.
If it does not cause behavior difference, I am unsure we should add it.
This flag does cause difference behavior of gnu ld. With this flag added and --relax specified to gnu-ld, the gnu-ld will optimize long call (4-byte instruction) to short call (2-byte instruction), otherwise either this flag or --relax is absent, gnu-ld will not do the long call to short call optimization.
This is how gnu ld perform linker relaxation for AVR
https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=bfd/elf32-avr.c;h=702719136d09acbc8c98ec49ab8129d0f33fffa8;hb=6777dece58127236db900215857f9070ad63e0bf#l2423
We can see this flag EF_AVR_LINKRELAX_PREPARED does affect
https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=bfd/elf32-avr.c;h=702719136d09acbc8c98ec49ab8129d0f33fffa8;hb=6777dece58127236db900215857f9070ad63e0bf#l2533
The gnu ld will optimize long call (absolute address) to short call (PC relative address) only if this flag is set. (Of course --relax must also be specified.)
The commit has Reviewed By: MaskRay, jacquesguan, aykevl but @jacquesguan/@aykevl haven't signed off on the patch so it should just have my username :)
If you use arc amend (https://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-command-line), Reviewed By: will be added correctly.
This is the newly added ELF flag.