-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
rustc
should prefer statically linking native dependencies with unspecified kind if crt-static
is enabled
#71647
Comments
If #39998 is accepted as the way to go by default when |
This was discussed at length in #55566, where I was told that |
Some history in links: #71586 (comment) |
@smaeul We can at least make an experiment (possibly using crater, possibly landing this on nightly and reverting) and verify what actually breaks in practice. |
I fear crater will likely have a pretty poor coverage as far as linkage is concerned as its environment won't generally have anything but the most common libraries installed on the system (and the "native" libraries built in |
Was this not resolved with #111698 ? |
The main goal of
+crt-static
(at least on non-Windows targets) is to produce self-contained statically linked executables.With this goal in mind
rustc
switches linking of 1) Rust crates and 2) libc to static if possible. (Thelibc
part is done in the libraries through lazycfg
s though.)However, for native dependencies with unspecified kind
rustc
will still prefer the dynamic version of the library if both are available.Unfortunately, doing this is not entirely trivial because
-Bstatic -lmylib
won't just prefer the static version (e.g.libmylib.a
), it will require it.So we need to check for the existence of
libmylib.a
first (in which directories exactly?) and then pass-l:libmylib.a
instead of-lmylib
if it exists.cc #71586 #39998
The text was updated successfully, but these errors were encountered: