-
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
Add option to not include .o files from a .a in the .rlib which uses them #38095
Comments
This is literally what specifying |
Ah, you mean in the .rs file, use |
@jsgf Not specifying a kind defaults to dylib yes. If you specify the library to link via a build script rather than the source code, use
|
OK, so maybe the issue is simply that the documentation needs to be updated and/or the current names are deprecated in favour of less misleading ones. |
cc @steveklabnik We really need to clarify this in the documentation. |
I think this is a valid issue, and I wouldn't recommend using @retep998 I know you feel quite strongly about this topic, but we should shy away from hyperboles "The naming is terrible and now nobody will ever fix it". The best way to help fix this problem is to be part of the solution! @jsgf for now if the I/O or perf of this is a problem, I'd probably recommend avoiding In general we haven't really paid a huge amount of attention to the perf impact of |
This isn't currently critical, but if rustc can't handle thin archives then it could be a real problem. |
The particular case where this occurs is when you are working with rust dylibs (not cdylibs), the predominant use case being compiler plugins for rustc. A static library should only be linked once into the first immediate binary (either dylib or exe) and then any reachable symbols from the static library should be exported (if it is a dylib), while a dynamic library should be linked into every binary. Although to be fair, there is one other difference that is Windows specific, which at the time of me writing this post doesn't actually exist yet, but will once a certain PR lands. Mainly, that tl;dr 99% of the time you can just use
@alexcrichton Which is why I've been pushing for |
According to #37403, static-nobundle has been implemented and so we can close this -- that is the correct way to do this I think. |
At the moment, if a Rust crate has a linkage with a static library (
libfoo.a
), it will extract all the.o
files from the.a
and insert them into the.rlib
(which is also anar
archive).This is fine for small libraries, but can be a problem if the library is very large, both because of the excessive IO, and from storage use.
It would be good if
rustc
had an option to not do this, but instead just remember a reference to the.a
file for use at final binary generation time (assuming the final link has the appropriate-L native=<dir>
option).The text was updated successfully, but these errors were encountered: