On Sat, 20 Jul 2024 00:20:19 GMT, Jiangli Zhou <jian...@openjdk.org> wrote:

> Please review this PR that strips the `.llvm_addrsig` section from JDK and 
> hotspot `.a` static libraries when building with clang. Please see 
> https://bugs.openjdk.org/browse/JDK-8336849 description for details.

But why and how do you specify `-Wl,--icf=safe` when building libjvm.a? That is 
not part of the linker flags in the JDK build mainline. I have not encountered 
these problems when trying to link with lld. 

Is it something you turn on explicitly in a separate branch? Or is it turned on 
by default by your lld version?

In any case, the links you provided explains why this approach is 
catastrophically wrong: 

> Other linkers, notably LLVM lld, supports --icf=safe. It uses .llvm_addrsig 
> sections to identify functions that are safe to merge. Functions that are not 
> mentioned in the section are not address-taken (no one takes its pointer), so 
> they are safe to merge.

If you were to remove these sections, then the linker will believe that all 
functions are safe to merge. 

Yes, you will "solve" the problem with the error message, but the price you pay 
is that you get a binary that violates the C++ specification. 

If you really want that, then you should pass `--icf=all` to the linker, and 
then it will stop caring about  the `.llvm_addrsig` sections.

But from reading the links you sent, the safe and sound approach seems to be to 
send `--icf=none` to lld when it should operate on a partially linked (ld -r) 
.o file.

In any case, heavyhandedly cutting out sections like this seem utterly wrong.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/20265#issuecomment-2271291483

Reply via email to