[Driver] Pass -X to ld for riscv*-{elf,freebsd,linux}
GNU ld has a hack that defaults to -X (--discard-locals) in the emulation file `riscvelf.em`. The recommended way, as gcc/config/arm does, is to let the compiler driver pass -X to ld. (The motivation is likely to discard a plethora of `.L` symbols due to linker relaxation.) lld default to --discard-none. To make clang+lld match GNU ld's behavior, pass -X to ld. Note: GNU ld has a special rule to treat ld -r -s as ld -r -S -x. With -X, driver `-r -Wl,-s` will behave as ld `-r -S -X`. This removes fewer symbols than `-r -S -x` but is safe. Differential Revision: https://reviews.llvm.org/D127826
Loading
Please sign in to comment