-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
build: don't add targets to link_whole_targets if we took their objects #10699
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
build: don't add targets to link_whole_targets if we took their objects #10699
Conversation
See: lovell/sharp-libvips#154 for an example of this |
Codecov Report
@@ Coverage Diff @@
## master #10699 +/- ##
==========================================
- Coverage 68.95% 59.03% -9.92%
==========================================
Files 406 203 -203
Lines 88306 44167 -44139
Branches 19591 9791 -9800
==========================================
- Hits 60888 26076 -34812
+ Misses 22836 15910 -6926
+ Partials 4582 2181 -2401
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
e433ca0
to
17fc6ce
Compare
46ef337
to
9500aad
Compare
I think I have it all sorted out now, we'll see. A lot changed between this version and the last one. |
This actually works with This magically worked before this PR only because there was a direct dependency on |
There are two distinct cases here that need to be considered. The first issue is mesonbuild#10723 and mesonbuild#10724, which means that Meson can't actually generate link-whole arguments with rust targets. The second is that rlibs are never valid candidates for link-whole anyway. The promotion happens to work because of another bug in the promotion path (which is fixed in the next commit).
9500aad
to
448387a
Compare
We need this to ensure that .mod files are created before we start compiling, and to ensure that the proper include directory arguments are generated.
What happens is this: - liba is a convenience static library - libb is an installed static library - libb links in liba with --link-whole - libc links to libb - we generate a link line with libb *and* liba, even though libb is a strict superset of liba This is a bug that has existed since the we stopped using link-whole to combine convenience libraries, and to instead propagate their dependencies up. For most linkers this is harmless, if inefficient. However, for apple's ld64 with the addition calling `ranlib -c`, this ends up causing multiple copies of symbols to clash (I think that other linkers recognize that these symbols are the same and combine them), and linking to fail. The fix is to stop adding libraries to a target's `link_whole_targets` when we take its objects instead. This is an all around win since it fixes this bug, shortens linker command lines, and avoids opening archives that no new symbols will be found in anyway.
448387a
to
5de0d16
Compare
This is getting delayed until either the point release after next, or until 0.64.0, because it causes this regression: #10745 |
Punted to 0.63.4 because #10745 is still not fixed. |
This is a regression test for: mesonbuild#11165. The test was initially merged as part of: mesonbuild#10628, but had to be reverted. A second attempt at fixing the root cause also had to be reverted: mesonbuild#10699. A 3rd attempt got merged but missed this unit test: mesonbuild#11742. Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
What happens is this:
strict superset of liba
This is a bug that has existed since the optimization was added to avoid
calling link-whole on convenience libraries, and to instead propagate
their dependencies up. For most linkers this is harmless, if
inefficient. However, for apple's ld64 with the addition calling
ranlib -c
, this ends up causing multiple copies of symbols to clash (I thinkthat other linkers recognize that these symbols are the same and combine
them), and linking to fail.
The fix is to stop adding libraries to a target's
link_whole_targets
when we take its objects instead. This is an all around win since it
fixes this bug, shortens linker command lines, and avoids opening
archives that no new symbols will be found in anyway.