Comments (2)
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 alwayslink
field on LibraryToLink
objects or is additional handling required?
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.
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 that haskell_library correctly detects the dependency, but adds it to the generated Cabal file as a linker argument.
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?
from rules_haskell.
Do you have a minimal repro that you could share that illustrates the use of the feature?
As a minimal repro, you can add alwayslink = True
to the cbits
cc_library
target of rules_haskell_tests/tests/indirect-link/BUILD.bazel
. Then try building the indirect-link-static
target. It will fail with a linker error about finding -ltests_Sindirect-link_Slibcbits
.
Is it sufficient to handle the alwayslink field on LibraryToLink objects or is additional handling required?
Possibly, but I'm not certain. You fix the linking error above by explicitly adding the explicit path to intf.pic.o
to the args returned by ghc_cc_program_args
in cc.bzl
. For example, lines 220-222 might look like
cc + " -E -undef -traditional",
"-optc-fno-stack-protector",
"/home/foo/bar/rules_haskell/rules_haskell_tests/bazel-out/k8-fastbuild/bin/tests/indirect-link/_objs/cbits/intf.pic.o"
]
I found out which pic.o
file to add here by calling nm bazel-out/k8-fastbuild/bin/tests/indirect-link/libcbits.lo
from therules_haskell_tests
directory. I believe the names of the pic.o
files should be available as outputs of the appropriate action for cbits
. You can see this, for example, by running
bazel aquery 'mnemonic("CppCompile",":cbits")' | grep Outputs
What I don't know is whether all the information that's available to Bazel is available in the CcInfo
object of haskell_library
dependencies. It looks to me like rules_haskell
constructs a custom CcInfo
object that may diverge from the object Bazel's rules_cc
would create. It may be necessary to do work in the haskell_library
implementation to pipe the appropriate info through.
rules_haskell doesn't generate Cabal files. Are you referring to the GHC package configuration files, i.e. what's generated here?
Yes sorry, that's my mistake. Once the appropriate pic.o
files are passed to GHC, you would need to remove the dependency from the GHC package configuration files. AFAICT from the GHC package config documentation, GHC doesn't support .lo
files, so they probably shouldn't be added there.
from rules_haskell.
Related Issues (20)
- Refactor `rules_haskell` CI workflow.
- Fix out-of-memory errors in CI when running `run-tests` in `rules_haskell_tests`. HOT 4
- Fix CI failures related to `Test GHC Patches` HOT 1
- Remove old GHC versions
- rts dependency in cc_library no longer works (can't find HsFFI.h) HOT 5
- Refactor Bazel configuration to reduce/eliminate platform-specific flags HOT 3
- `ghc_wrapper` is killed on MacOS arm64 running tests under `rules_haskell_tests` HOT 6
- Prepare release 0.19
- Update BCR presubmit to use `rules_haskell` instead of running the tests in `rules_haskell`
- Upgrade to new rules_nixpkgs release
- Buildifier support on NixOS with bzlmod HOT 1
- Haddock 2.30 faillure in profiling mode
- proto-len protoc plugin failures on windows with ghc 9.6.2 and 9.8.1
- Docker example should work on Darwin
- Dependency Dashboard
- Bazel 7.1.1 and nixpkgs GHC 9.8.2 produce dynamically linked haskell_cabal_binary's
- Avoid creating empty libraries
- [Bazel CI] Unrecognized option incompatible_struct_has_no_methods in bazel command HOT 3
- build on Bazel CI broken HOT 2
- [Bazel CI] library tests are failing with Bazel@HEAD HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rules_haskell.