-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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
Haskell: ghc-options are lost when cross-compiling (including pkgsStatic) #286285
Labels
Comments
wolfgangwalther
added a commit
to wolfgangwalther/nixpkgs
that referenced
this issue
Feb 4, 2024
This works around NixOS#286285 by passing --enable-split-sections instead of ghc-options.
This was referenced Feb 4, 2024
wolfgangwalther
added a commit
to wolfgangwalther/postgrest
that referenced
this issue
Feb 4, 2024
…aller again This works around NixOS/nixpkgs#286285 to use -split-sections in a cross-compiling scenario. This will reduce the size of the static executable and also remove the remaining references to /nix/store/.. reducing closure size dramatically. This also fixes the docker image blowing up in size since we switched to pkgsStatic.
wolfgangwalther
added a commit
to PostgREST/postgrest
that referenced
this issue
Feb 6, 2024
…aller again This works around NixOS/nixpkgs#286285 to use -split-sections in a cross-compiling scenario. This will reduce the size of the static executable and also remove the remaining references to /nix/store/.. reducing closure size dramatically. This also fixes the docker image blowing up in size since we switched to pkgsStatic.
wolfgangwalther
added a commit
to wolfgangwalther/nixpkgs
that referenced
this issue
Feb 8, 2024
This works around NixOS#286285 by passing --enable-split-sections instead of ghc-options.
Was able to reproduce this with plain cabal in haskell/cabal#10069. |
wolfgangwalther
added a commit
to wolfgangwalther/nixpkgs
that referenced
this issue
Jun 4, 2024
…ling The following sequence of operations loses ghc-options: Setup.hs configure --ghc-options Setup.hs build --with-ghc=... This is described in [1]. The fix is simple: Don't pass --with-ghc in the build phase. The values are taken from the configure step anyway. This seems to have been introduced all the way back in 64ec4dd about 8 years ago for unknown reasons. Resolves NixOS#286285 [1]: haskell/cabal#10069
13 tasks
github-actions bot
pushed a commit
that referenced
this issue
Jun 20, 2024
…ling The following sequence of operations loses ghc-options: Setup.hs configure --ghc-options Setup.hs build --with-ghc=... This is described in [1]. The fix is simple: Don't pass --with-ghc in the build phase. The values are taken from the configure step anyway. This seems to have been introduced all the way back in 64ec4dd about 8 years ago for unknown reasons. Resolves #286285 [1]: haskell/cabal#10069 (cherry picked from commit 5dbf665)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
When cross-compiling haskell packages custom
ghc-options
are not passed to the compiler. This includes those passed in:nixpkgs/pkgs/development/haskell-modules/generic-builder.nix
Lines 232 to 235 in 4ec0020
nixpkgs/pkgs/development/haskell-modules/generic-builder.nix
Lines 248 to 249 in 4ec0020
nixpkgs/pkgs/development/haskell-modules/generic-builder.nix
Lines 260 to 261 in 4ec0020
Steps To Reproduce
Run the following to see the invocation of GHC when cross-compiling to musl64:
The configureFlags line will look like this:
Note the
--ghc-options=-j16
and--ghc-option=-split-sections
.The call to GHC:
None of the two options are passed to GHC.
Expected behavior
Run the same without cross-compiling for pkgsMusl:
The configure flags are similar, but the GHC invocation looks like this:
Note the
-j16 -split-sections
at the end.Additional context
I assume this is a bug in cabal somehow, but I was not able to reproduce this with plain cabal outside nixpkgs, yet. I tried many variations of configureFlags, but the only thing that actually made a difference is
pkgsCross
/pkgsStatic
.This affects
pkgsStatic
and results in all statically built haskell executables being larger than they should be, because dead code elimination is not happening. This was already observed in static-haskell-nix (@nh2):https://github.com/nh2/static-haskell-nix/blob/88f1e2d57e3f4cd6d980eb3d8f99d5e60040ad54/survey/default.nix#L15-L17
It also means that static executables can't strip auto-generated
Paths_xxx
modules, which are never required at run-time, I think. But they contain references to/nix/store/...
paths of their own module. When trying to create a minimal docker image, with just a single static executable, this will then pull in all of those modules and their dependencies, resulting in a huge image. This was observed after switching PostgREST's build from static-haskell-nix to pkgsStatic.Dead code elimination /
-split-sections
can be worked around by passing--enable-split-sections
to cabal instead. This will pass on-split-sections
correctly, even when cross compiling. However, that doesn't solve the problem for other ghc options.Notify maintainers
@cdepillabout @expipiplus1 @maralorn @ncfavier @sternenseemann
Add a 👍 reaction to issues you find important.
The text was updated successfully, but these errors were encountered: