-
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
macOS-only runtime dyld error with dynamically-linked binary indirectly depending on linkstatic=True library #11552
Comments
PiperOrigin-RevId: 314961517
PiperOrigin-RevId: 314962528
PiperOrigin-RevId: 314961517
PiperOrigin-RevId: 314985889
PiperOrigin-RevId: 315313209 Change-Id: I5d86e271b7733cf16d9b8de98d1c2ee69764608f
@keith @googlewalt Hello Keith and Walt, I'm not sure if what's happening here is a Bazel bug or a limitation of linkers on macOS. This is the command line I got on Linux:
This is the command line my colleague got on macOS:
I see that liba.a is passed rather than the object file but that should not matter (that's enabled with the feature SUPPORTS_START_END_LIB). What is happening here is that a shared object ( If that limitation exists, then this just won't work. If the reason why you have this setup is because you have a precompiled archive that you don't control and they won't provide you with a shared object instead, then what you can do is wrap the precompiled archive in a cc_binary(linkshared=1). If that's not the case and you are compiling everything from source, why do you need this setup?
|
this isn't particularly true, I don't fully understand your repro case, but can you try to use |
This essentially boils down to:
For this test case to work, the linker needs to pull in symbols from a into the c binary to satisfy undefined symbols in b. This has to be done by the linker (as opposed to anything bazel can do), and ld64 (Apple's linker) does not appear to support this use case.
I think the error still remains, for the same reason. |
It's 2024. This looks like P1 issue since 2021? Is it still relevant? |
Yeah I think we can close this. I don't think this was a supported use case, and it's WAI. |
Summary: See attached minimal testcase. On macOS, Bazel produces a binary that fails at runtime to dynamically link to its dependency. This happens in the following scenario: a binary "c" with linkstatic=False depends on a library "b" with linkstatic=False, itself depending on a library "a" with linkstatic=True. Each of these aspects is necessary to reproduce the issue:
Minimal testcase attached: bazel_link_error.tar.gz
BUILD file from the testcase pasted here for your convenience:
To reproduce, untar the archive and run
//:c
Actual result:
The text was updated successfully, but these errors were encountered: