dtolnay / linkme

Safe cross-platform linker shenanigans
Apache License 2.0
625 stars 42 forks source link

rust-lld: error: undefined symbol: `__[start|stop]_linkm2_KNOWN_STUBS` #94

Open torokati44 opened 3 months ago

torokati44 commented 3 months ago

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
torokati44 commented 3 months ago

See also: https://github.com/dtolnay/linkme/actions/runs/9458387043/job/26053880019

torokati44 commented 3 months ago

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

yoctozepto commented 1 month ago

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.

yoctozepto commented 1 month ago

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