Description
Describe the bug
This can happen when you have a C library which depends something from libc or something else that the C compiler would link in automatically and you then link a Rust binary against that C library. In Mesa, we saw it show up as undefined reference to '__aarch64_cas4_sync'
errors when building certain unit tests against aarch64 (https://gitlab.freedesktop.org/mesa/mesa/-/issues/11632). I've also seen it show up as a undefined reference to 'atexit'
. In both cases in Mesa, the C libraries were static libs. I have no idea if it can come up with dynamic linking.
To Reproduce
Unfortunately, this is can be really annoying to reproduce reliably. I was never able to reproduce the aarch64 Mesa issue in Mesa CI, even though both the bug reporter and our CI build on Debian. I suspect the atexit
one is probably easier to reproduce but that issue showed up in a coworker's build, not mine. (I never pulled their branch and tried to build it so IDK if it would have reproduced for me.)
Workaround
The current workaround is to set rust_args: ['-C', 'default-linker-libraries']
in the binary. This gets us going again in Mesa but it feels like a hack.