-
Notifications
You must be signed in to change notification settings - Fork 81
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
Bazel-built Shared C Libraries and the GHCi linker #720
Comments
For now, I managed to work around this by creating a rule that creates fat static and dynamic libraries. Since these don’t depend on any other libraries this avoids the problem but obviously it’s not pretty. Note also that while @Profpatsch tagged this as REPL improvements, this also affects TH so even if you’re willing to give up on a repl, this might mean that you are unable to build your code. |
Has this problem been solved by recent improvements to the REPL support in |
@Profpatsch As @moritzkiefer-da pointed this does not only concern the REPL but also template Haskell. The issue still persists.
This would indeed break static linking.
Using the new Starlark C++ API it's possible to create a custom |
In #1696 @jcpetruzza provided a great repro for this issue. |
Let’s say I have two
cc_library
sa
andb
wherea
depends onb
. The shared libraries built by Bazel underlink, i.e., the shared library doesn’t declare that it depends on other shared libraries instead this is tracked internally by Bazel.If I make a Haskell library that depends on
a
, I will end up withextra-libraries: a b
in my package config. The GHCi linker (triggered by TH) will go through those libraries and calldlopen(libname, RTLD_LAZY|RTLD_LOCAL)
. It respects the order inextra-libraries
so it will first try to loada
. If you are lucky,RTLD_LAZY
works and despitea
referencingb
. However, this won’t work in general asRTLD_LAZY
only works for function references and even then it can be overridden by things like-Wl,-z,now
which, to make matters worse, is passed by default by Bazel. In that casedlopen
will error out with anundefined symbol
error and builds fail.Sadly, I don’t know a nice solution to this:
extra-libraries
will break static linking afaict since in that casea
should come first.linkstatic = True
works sometimes but it is annoying to have to patch upstream rules and the GHCi linker is also fairly fragile (currently it’s failing for me on the official grpc library patched withlinkstatic = True
withlibgpr_base.a: unhandled ELF relocation(RelA) type 19
).I don’t have a self-contained test case that I can make public right now but we’re seeing this with the official grpc library, i.e.,
"@com_github_grpc_grpc//:grpc" which we get via
http_archive`:The text was updated successfully, but these errors were encountered: