-
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
Test cannot load other library target at runtime via dlopen #4218
Comments
CC: @mhlopko |
Library outputs of cc_library shouldn't be relied on, and should be considered as a implementation detail and are toolchain dependent (e.g. if you're using gold linker, we don't produce .a libs at all and use lib-groups instead, also linkstatic=0 on cc_test is something that might change in the future). Ideally you should wait for cc_shared_library (https://docs.google.com/document/d/1d4SPgVX-OTCiEK_l24DNWiFlT14XS5ZxD7XhttFbvrI/edit#heading=h.jwrigiapdkr2) or use |
@hlopko could you so kind to give an update regarding if anything done in this direction or if there are any plans? |
I'm sorry, I'm no longer working on Bazel. CC @comius @oquenchil |
A possible workaround:
However, if plugin B depends on a plugin A, it can only depend on the cc_library target. But during runtime, on windows, it'll look for plugin_A_impl.dll, not plugin_A.dll (at that point, plugin_A.dll is already loaded). It'd be great if the complete linking of a cc_library were possible. |
Is the situation for this much better with the current version of cc_shared_library? You can put the cc_shared_library target as a data dependency of another library, but there's two issues with this:
1 could probably be fixed by specifying the correct linkopts in the library. |
It you dlopen anyway, it might be a good idea to use the C++ runfiles library ( That won't statically prevent ODR violations, but that seems hard to get right in an automated way. |
Description of the problem / feature request / question:
There is no easy way for a test to load another target at runtime using dynloading.
The only solution I have found so far is to add the library to
deps
and then reference via e.g. "$CWD + /../_solib_local/libtests_Slibmylib.so
" but this is an ugly hack. There seems to exist no way to add the output of acc_library
target to the test's runfiles directory.One example use case for this is testing a module ABI for run-time plugins.
If possible, provide a minimal example to reproduce the problem:
This is a sketch and not a runnable example. I can provide one if preferred.
with
test.c
containing:This will work fine when run from the workspace dir after a
bazel build
but not viabazel test
because the library can't be found.Environment info
Operating System:
Linux / OS-independent
Bazel version (output of
bazel info release
):release 0.8.0
Have you found anything relevant by searching the web?
No.
The text was updated successfully, but these errors were encountered: