-
Notifications
You must be signed in to change notification settings - Fork 474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue locating static libraries and parsing linker scripts? #1375
Comments
I'm not aware of anything like this for cc-rs, the best I known is zulip. |
Not sure, honestly never seen this before.
By default rustc invokes c compiler to invoke the system-wide linker with the correct arguments. Maybe there's something different about your environment that rustc didn't take account of? |
This comment has been minimized.
This comment has been minimized.
For the question itself, I think this may be more relevant on the rust-lang/rust repo? It sounds like you can reproduce it without
When? Can you try to narrow down the nightly |
This comment has been minimized.
This comment has been minimized.
Thanks for the input! I found that I sidestepped my issue by just dynamically linking instead on linux, ie removing the
FWIW this issue happened on a couple of WSL Ubuntus as well as my own Ubuntu machine and some other distro.
I develop on MacOS mainly so it might have gone unnoticed for a while, but yup I will look into it again at some point and work out when the breakage was and raise on rust-lang/rust! Thanks guys! |
cc @jsdw oops I just realized that you are trying to statically link to glibc, which is not supported by glibc. Only musl libc can do that static linking. And I'm not sure if you need to link if manually, rustc automatically link with libc and its libm on the final linking stage. The compilation of a crate just creates an archive and doesn't do any linking. |
Maybe I'm misunderstanding, but I am only trying to statically link to libm and libz, not libc itself? Also, this code has worked without issue for a couple of years, and only recently started failing; I'd have assumed it would always have failed if there was something more fundamental like that wrong with it? |
For libm, I believe it is part of libc, so glibc and musl libc provides different libm as part of their libc distr.
Maybe it's the gnu ld script? Perhaps old versions of glibc doesn't use them which is why they worked
|
Hello!
Apologies if this is a dumb question; It's not an area I venture into super often!
I have some C code which I've been successfully compiling using the
cc
crate for a while now. The config in build.rs is nothing special and looks like this:This still builds today without any issue in MacOS, but has started failing on linux (Ubuntu 22.04) with the error:
I have a
libm.a
at the path/usr/lib/x86_64-linux-gnu/libm.a
, which is a path specified in my/etc/ld.so.conf
file (well, included via/etc/ld.so.conf.d/x86_64-linux-gnu.conf
).Nevertheless, I manually added this path to my build script like so:
This now leads to a new error on trying to compile:
Weird! So just out of curiosity I
cat /usr/lib/x86_64-linux-gnu/libm.a
and see:Ok.. this is a linker script or something and not an actual static library. Based on this I try manually including the libm it shows here ie I add this to my build script (removing the original):
My library now successfully compiles, hurrah! My new build.rs looks like:
But what I am now wondering is:
Apologies if this is the complete wrong place to ask this (it probably is), but I wonder if you might have any insight?
The text was updated successfully, but these errors were encountered: