-
Notifications
You must be signed in to change notification settings - Fork 79
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
Support for alwayslink
cc_library targets
#1902
Comments
Thanks for raising this @antsareeverywhere. Do you have a minimal repro that you could share that illustrates the use of the feature? rules_haskell implemenents most of the handling of CC libraries in this module. I'm not super familiar with the always link feature. Is it sufficient to handle the Adding support for this to rules_haskell will probably require a bit of thought. rules_haskell relies on the extra-libraries field in the GHC package configuration file. I'm not sure if that has support for the alwayslink concept.
Could you clarify what you mean by this? rules_haskell doesn't generate Cabal files. Are you referring to the GHC package configuration files, i.e. what's generated here? |
As a minimal repro, you can add
Possibly, but I'm not certain. You fix the linking error above by explicitly adding the explicit path to
I found out which
What I don't know is whether all the information that's available to Bazel is available in the
Yes sorry, that's my mistake. Once the appropriate |
Is your feature request related to a problem? Please describe.
alwayslink
cc_library targets create.lo
files, which rules_haskell doesn't appear to know how to find. I didn't see any mention of.lo
files oralwayslink
, so I'm not sure if this is a known limitation.Describe the solution you'd like
If a haskell_library depends transitively on a cc_library where alwayslink is set to true, then the rules_haskell library builds correctly, or alternately fails with an error indicating that alwayslink isn't currently supported.
Describe alternatives you've considered
I was able to get Bazel to build by creating a build target without
alwayslink
and making this target a direct dependency on all Haskell targets that indirectly include the original cc_target.I believe what Bazel does in the cc case is to treat the
.lo
file as a list of.o
files. Then Bazel passes these.o
files directly to the linker rather than passing the.lo
file itself. From reading the GHC docs, I think it may work for rules_haskell to do the same thing. Essentially, the.lo
files would need to be handled in the logic that passes arguments to GHC rather than the logic that generates Cabal files. Currently what happens is thathaskell_library
correctly detects the dependency, but adds it to the generated Cabal file as a linker argument. The linker isn't able to find a.so.*
or.a
file for the library, so the build fails with a linker error.Additional context
The relevant search term for understanding Bazel's handling of
.lo
files isalwayslink
: https://github.com/search?q=repo%3Abazelbuild%2Fbazel++alwayslink&type=codeThe text was updated successfully, but these errors were encountered: