-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
rust: Don't Link non-cdylib/staticlib Rust libraries into non-Rust ta… #11723
base: master
Are you sure you want to change the base?
rust: Don't Link non-cdylib/staticlib Rust libraries into non-Rust ta… #11723
Conversation
Another alternative is to promote link to link_whole there: https://github.com/mesonbuild/meson/blob/master/mesonbuild/build.py#L1391. I think that reflects better what actually happens, and we already do similar stuff there. Does that work? @sdroege see the comment in the link above, seems @dcbaker already had to deal with similar case. |
You mean adding a |
Not sure I understood exactly the use-case actually. Do I understand correctly that when rustc links rlib A to another rlib B, it does it whole-archive, meaning that when an executable links to A we don't need B and its dependencies anymore? We definitely need a unit test for this, and I'm sure that will also clarify what exactly you're fixing. |
The problem is that if you build a
while it should be just
The change in this PR and also the alternative are both changing it from the first with all the
I don't know how to make a unit test for this because it works fine and just passes too much to the linker. Do you have a suggestion? |
I don't know any nice way of doing this, I initially thought that linker would error out if getting .rlib files. I see we have a few unit tests that parse build.ninja with some regex, that would work. See linuxliketests.py. |
Not beautiful but I guess that will do. Do you have a preferred approach/place for solving the bug though? |
@sdroege I think
|
As always, when investigating more closely the root cause I discover that the problem is bigger than we thought. a = static_library('foo', 'foo.c')
b = static_library('bar', 'bar.c', link_whole: a)
e = executable('prog', 'main.c', link_with: b) This is a similar pure C example, libfoo.a is not needed to link prog, but it is given to command line too. |
That seems like a separate but similar issue. As discussed on IRC, @xclaesse thinks that the best approach here would be to explicitly use
|
Fixes #11721
CC @dcbaker @xclaesse
This is probably wrong but not sure at which other place this should be. This seems to work though.
Another option would be