-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
call ranlib -c after static linking on macos #10628
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
Conversation
Which is old and annoying and doesn't expose global symbols by default, so we need a work around. see: mesonbuild#10587 see: https://lists.gnu.org/archive/html/libtool/2002-07/msg00025.html
9da65d7
to
5f91646
Compare
This pull request introduces 2 alerts when merging 5f91646 into ec388fe - view on LGTM.com new alerts:
|
Apple's AR is old, and doesn't add externed symbols to the symbol table, instead relying on the user calling ranlib with -c. We need to do that for the user
Codecov Report
@@ Coverage Diff @@
## master #10628 +/- ##
===========================================
- Coverage 68.83% 58.05% -10.78%
===========================================
Files 406 203 -203
Lines 88038 44002 -44036
Branches 19550 9612 -9938
===========================================
- Hits 60598 25547 -35051
+ Misses 22868 16185 -6683
+ Partials 4572 2270 -2302
Continue to review full report at Codecov.
|
5f91646
to
b1d1b23
Compare
This forces the use of the Apple archiver, since that archiver doesn't add extern'd variables to the symbol table automatically, and instead requires that ranlib be used. A native file is used to ensure that Apple's ar is used even in the presence of llvm or gcc in the path with their superior archivers. Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
b1d1b23
to
87a36cd
Compare
@nirbheek this should get backported |
As per #10628 (comment) the real fix will be in 0.64. This reverts commits: Revert "linkers: Add a representation for the Apple AR Linker" ee16f01. Revert "backends/ninja: run `ranlib -c $out` when using the apple ar" 77e589c. Revert "tests: Test extern'd globals on MacOS with the Apple Archiver" bcb382b.
This reverts commit d285be7. This is part of mesonbuild#10628 and needs to be reverted, as it breaks other things. See mesonbuild#10628 (comment)
This reverts commit bdc6f24. This is part of mesonbuild#10628 and needs to be reverted, as it breaks other things. See mesonbuild#10628 (comment)
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>
Apple, for some reason, decided that ranlib should not, by default, include extern'd variables in the symbol table when running ar with the
-s
option (run ranlib). So we must additionally callranlib -c $out
when linking a static archive, so that behavior is consistant between the Apple archiver and every other archvier other (including llvm-ar).Incidently we never caught this because we have code to specifically chose llvm-ar when using any variaty of clang if it's available, and apple's clang is a variety of clang, and we install llvm for running llvm tests. Because of that I've modifed a test for apple that forces the use of the
ar
archiver, even whenllvm-ar
orgcc-ar
are installed, and don't have this behavior.