-
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
User interface for fully statically linked Haskell binaries #1408
Comments
I think option 2 sounds the most attractive -- effectively swapping Playing devil's advocate, I do wonder if there are cases where the static linking of a particular binary really is specific to that target -- e.g. suppose I could make With regards to e.g. stack_snapshot(
...
components = {
"ghcide": struct(
build = True, # Replacing/making more verbose the existing feature
fully_static_link = True, # Giving us the new functionality
),
},
...
) I don't know whether this is possible/sensible (and indeed you might still want to pass feature flags down regardless of this), but it's a thought I had. Perhaps overly granular for the current use case. TL;DR -- 2 sounds good, happy to help 😄 |
Yes, for
One can probably always construct a case where dynamic linking is required. E.g. the
That's an interesting idea. There is precedent for something like this in
Implementation wise Bazel doesn't have attribute types for a list of structs directly, so the |
The packages as structs idea is tempting (and cute), but doesn't that point towards writing the same metadata in a new top-level target instead? That would feel more Bazely. |
@mboes Could you expand on what that would look like? |
Repository rules don't have providers, but they can read files. So we could have a |
That's true, but they cannot read files that are generated by build actions because of the different phases in which repository rules and regular rules are executed. I suppose we could make it another repository rule. Here's what a
However, I see a couple of issues with this approach.
|
Yes, making But come to think of it, do we really want to push so much configuration in the Either way, I'm not against structs in |
Configuring this in |
Moreover, it feels like we'd lose the original use case -- specifying per-package build/configuration options. I don't think one can do that in |
With custom stack snapshots it's possible to define per package flags and GHC options. The docs give the following examples:
Unfortunately, these are not exposed by |
Hm, do we have a feature request upstream? As things stand, using a snapshot file is going to be pretty confusing to users: part of the content will be ignored when Stack wouldn't have. |
I've opened commercialhaskell/stack#5372 to that end.
Indeed, we have a related issue on |
#1390 added support for fully statically linked Haskell binaries. As of that implementation users need to configure the GHC toolchain for fully static linking by setting
static_runtime = True
andfully_static_link = True
on the toolchain and they need to configurecompiler_flags = ["-optl-static"]
on thehaskell_binary
targets that they want to have fully statically linked. @mboes raised whether this flag is necessary and whether we could build on Bazel precedent and use thefully_static_link
feature flag instead. I figured it's best to have that discussion on this issue tracker.A related question was previously discussed to decide on the interface of the GHC toolchain, see #1390 (comment). As I argued in that discussion it is a property of the GHC distribution whether it is capable of fully static linking, so it makes sense to have a corresponding switch on the GHC toolchain rule. The remaining question is whether and how users control fully static linking on individual targets. These are the options I see:
fully_static_link = True
. I.e. always pass-optl-static
to GHC (or--ghc-option=-optl-static
to Cabal).fully_static_link
feature flag.-optl-static
to GHC (or--ghc-option=-optl-static
to Cabal).Here's my view on each of these options:
minirepo
but noticed that it then fails to build@ghcide-exe//ghcide
. The reason is that it depends onlibtinfo
ofncurses
which is only available dynamically in thestatic-haskell-nix
configuration. Trying to switch to a staticlibtinfo
fails due to missing symbols such as__memcpy_chk
. IIUC this is means thatlibtinfo
depends onglibc
and is incompatible withmusl
. This indicates that it is necessary to give users per target control of whether they want to link fully statically or not and rules this option out.stack_snapshot
we'd need to add a new attribute to enable forwarding feature flags to the generated targets (that's something that we may need at some point anyway). Note, as pointed out by @lunaris there are issues with thefully_static_link
feature flag oncc_binary
. However, these shouldn't affect a Haskell binary with that feature flag enabled.stack_snapshot
we'd need to add a new attribute to enable forwardingcabalopts
to the generated targets (that's also something that we may need at some point anyway). The advantage of this approach is that it's very simple and straight-forward. However, it doesn't allow for easy global or per package configuration asfeatures
does.I don't see a clear winner between 2 and 3. But, 2 seems preferable as it follows Bazel precedent and allows for convenient global or per package configuration.
@mboes @lunaris WDYT?
The text was updated successfully, but these errors were encountered: