Hi,

We had a report of GnuTLS lacking symbol versioning [0]. After some
digging, it looks like m4/ld-version-script.m4 is incompatible with >=
lld 16 because those versions default to [1][2] --no-undefined-version
which confuses the configure test.

$ echo 'int main()' > /tmp/lld.c
$ cat <<-EOF > /tmp/lld.map
VERS_1 {
        global: sym;
};

VERS_2 {
        global: sym;
} VERS_1;
EOF
$ gcc lld.c -Wl,--version-script=lld.map -fuse-ld=bfd
$ gcc lld.c -Wl,--version-script=lld.map -fuse-ld=mold
mold: warning: lld.map: cannot assign version `VERS_1` to symbol `sym`: symbol 
not found
mold: warning: lld.map: cannot assign version `VERS_2` to symbol `sym`: symbol 
not found
$ gcc lld.c -Wl,--version-script=lld.map -fuse-ld=lld
ld.lld: error: version script assignment of 'VERS_1' to symbol 'sym' failed: 
symbol not defined
ld.lld: error: version script assignment of 'VERS_2' to symbol 'sym' failed: 
symbol not defined
collect2: error: ld returned 1 exit status

bfd accepts it (and doesn't warn), mold warns, while lld errors
out. It's an intentional (albeit IMO unfortunate) decision in lld. We
can either define `sym` in AC_LANG_PROGRAM or we can pass
-Wl,--undefined-version if supported by the linker.

[0] https://bugs.gentoo.org/966252
[1] https://reviews.llvm.org/D135402
[2] 
https://github.com/llvm/llvm-project/commit/241dbd310599e3c1a0f1b0c9ced14c8b8760539e

thanks,
sam

Reply via email to