rust-lld: error: undefined symbol: `__[start|stop]_linkm2_KNOWN_STUBS`
This has been an issue before (https://github.com/dtolnay/linkme/pull/88), but now it has reached rustc beta: https://github.com/ruffle-rs/ruffle/actions/runs/9462151873/job/26064482962?pr=16448
= note: rust-lld: error: undefined symbol: __start_linkm2_KNOWN_STUBS
>>> referenced by 14g71b7tf2rrf8tb6zps16jjh
>>> ruffle_core-d15044b578f91d45.14g71b7tf2rrf8tb6zps16jjh.rcgu.o:(ruffle_core::stub::KNOWN_STUBS::h570647c79bce49d9) in archive /home/runner/work/ruffle/ruffle/target/ci/deps/libruffle_core-d15044b578f91d45.rlib
>>> did you mean: __start_linkme_KNOWN_STUBS
>>> defined in: <internal>
>>> the encapsulation symbol needs to be retained under --gc-sections properly; consider -z nostart-stop-gc (see https://lld.llvm.org/ELF/start-stop-gc)
rust-lld: error: undefined symbol: __stop_linkm2_KNOWN_STUBS
>>> referenced by 14g71b7tf2rrf8tb6zps16jjh
>>> ruffle_core-d15044b578f91d45.14g71b7tf2rrf8tb6zps16jjh.rcgu.o:(ruffle_core::stub::KNOWN_STUBS::h570647c79bce49d9) in archive /home/runner/work/ruffle/ruffle/target/ci/deps/libruffle_core-d15044b578f91d45.rlib
>>> did you mean: __stop_linkme_KNOWN_STUBS
>>> defined in: <internal>
collect2: error: ld returned 1 exit status
See also: https://github.com/dtolnay/linkme/actions/runs/9458387043/job/26053880019
RUSTFLAGS="-C link-args=-znostart-stop-gc" does indeed work around this.
Pasting the link from the error message to make it clickable: https://lld.llvm.org/ELF/start-stop-gc
It seems to really be a dup of now-long-standing #49 (see that digit switch? what a coincidence!)
BTW, what was the platform in this case? (distro, libc, cc toolkit; with versions) I am wondering how to pinpoint the real culprit.
It seems to really be a dup of now-long-standing #49 (see that digit switch? what a coincidence!)
BTW, what was the platform in this case? (distro, libc, cc toolkit; with versions) I am wondering how to pinpoint the real culprit.
I have realised the main post had a ref to GHA running Ubuntu 22.04 which has clang in version 14 https://packages.ubuntu.com/jammy/clang and obviously runs glibc
Same issue here. link-args=-znostart-stop-gc as the error suggests works for me, as does link-dead-code.
Host triple: x86_64-unknown-linux-gnu Arch Linux w/Rustup rustc 1.85.0-nightly (a224f3807 2024-12-09) glibc 2.40 clang/lld 18.1.8
Also having the same issue with macOS
Rust will pass the necessary flag automatically for now: https://github.com/rust-lang/rust/pull/137685
But this should be fixed in linkme as described in the lld docs.
The workaround indeed doesn't seem to be required anymore. Thanks!