-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
OS X: Odd loader issues when a shared library depends on a static-only library #507
Comments
What's the error message from the linker? Wild guess: configure autoconf to generate a PIC static library (IIRC, pass -fPIC to the compiler); non-PIC code cannot be linked into dynamic libraries. |
That's a great guess, but I've already compiled most, if not all, of my static dependencies PIC. I'm out sick today, but one example is that dyld won't be able to find the shared library for gtest-main. Bizzarrely, that's a Bazel-built shared library completey unrelated to the other dependecy with the static child (which happens to be gRPC). So in this unit test example: ''' ... the so for gtest-main will not be found unless I set linkstatic=1 on gRPC. Strange but true. |
Can you post the actual error message? It would help immensely. Are you saying that gtest-main is found if you remove the gRPC dependency? |
Symbols are found when gRPC is compiled with without gRPC
With In this case,
Here, 'gpr' is another zlib's BUILD file:
|
I have no idea why that would happen. Can you run 'otool -L' on the test binary? |
Closing as obsolete without answers. Please ping back if you are still experiencing the issue. |
The bug didn't fix itself, no. I still have many examples of where
Another instance of the bug arises when a test depends on two or more shared libraries which share a dependency linked with
... is problematic. Removing |
We'll need help from someone who better understands C++ linking on OSX to fix this. I'm out of my depth here. |
Also see #492. |
I have a potentially related problem on RobotLocomotion/drake#4896 at RobotLocomotion/drake@360cf61. On OS X, I get
Here's my only clue so far. As you can see, the test executable is in |
A friendly ping on this issue as we are also facing this and it prevents us from switching of our old test flow to Bazel only. |
It seems to me that what @david-german-tri reported is actually #3450, for which I'm submitting the fix right now. @Helcaraxan are you affected by #3450 or #507? Can you please verify? Now to the original issue, @kayasoze is it still broken? Could you compose a repro case? I can take a look then. |
@mhlopko I am currently trying to reproduce it. That said some of our project structure has significantly changed since last April so not sure that I will be able to. If I am not giving any further updates here in the next days consider I was not able to reproduce it. |
Hi there! We're doing a clean up of old issues and will be closing this one. Please reopen if you’d like to discuss anything further. We’ll respond as soon as we have the bandwidth/resources to do so. |
I haven't narrowed down a succinct repro. case, but I've observed that in the following scenario, odd linker errors occur:
cc_test -> cc_library(foo) (supports both shared and static) -> cc_library(bar) (wraps autoconf built static library)
Adding
linkstatic=1
tofoo
fixes all linker issues. It seems that Bazel doesn't support a shared-library dependency itself depending on a static library.Note that in this case,
bar
is static because it is built via a cross-platform genrule, and Bazel can't support a.so
out
on Linux and a.dylib
out
on OS X;select()
is prohibted inouts
. Thus, it only produces a.a
The text was updated successfully, but these errors were encountered: