Skip to content
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-updates: pretty-simple static cross build broken #124284

Closed
573 opened this issue May 24, 2021 · 9 comments
Closed

haskell-updates: pretty-simple static cross build broken #124284

573 opened this issue May 24, 2021 · 9 comments
Labels
0.kind: bug Something is broken 6.topic: cross-compilation Building packages on a different platform than they will be used on 6.topic: haskell 6.topic: static

Comments

@573
Copy link
Contributor

573 commented May 24, 2021

Describe the bug
pretty-simple breaks with (full log):

[3 of 7] Compiling Text.Pretty.Simple.Internal.ExprParser ( src/Text/Pretty/Simple/Internal/ExprParser.hs, dist/build/Text/Pretty/Simple/Internal/ExprParser.o, dist/build/Text/Pretty/Simple/Internal/ExprParser.dyn_o )
attempting to use module ‘pretty-simple-4.0.0.0-7XPG9KFSjjE3sIrbReVEek:Text.Pretty.Simple.Internal.Expr’ (src/Text/Pretty/Simple/Internal/Expr.hs) which is not loaded
builder for '/nix/store/0w5bsr5gv2jcbr6f2nr9i90cyl2pxjkz-pretty-simple-4.0.0.0-aarch64-unknown-linux-musl.drv' failed with exit code 1
cannot build derivation '/nix/store/hv2038drs08xyzanb4h42v1zmsb8fbvp-hledger-lib-1.21-aarch64-unknown-linux-musl.drv': 1 dependencies couldn't be built
building '/nix/store/i8qfka6jlkgzyym1c2c88k47xwl65ch7-regex-tdfa-1.3.1.0-aarch64-unknown-linux-musl.drv'...
cannot build derivation '/nix/store/rnbkxxi53wy066z1wlfb3a5mb8090mmg-hledger-1.21-aarch64-unknown-linux-musl.drv': 1 dependencies couldn't be built
error: build of '/nix/store/rnbkxxi53wy066z1wlfb3a5mb8090mmg-hledger-1.21-aarch64-unknown-linux-musl.drv' failed

To Reproduce
Steps to reproduce the behavior

LC_ALL=C NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs/archive/830ef6422f643d5c639fd79bca834c726787ec51.tar.gz nix-build -E 'import <nixpkgs> { compiler = (import <nixpkgs> {}).haskell.packages.ghc8104; system = "aarch64-linux";}' --arg crossSystem '(import <nixpkgs> {}).lib.systems.examples.aarch64-multiplatform-musl' -A pkgsStatic.haskellPackages.pretty-simple

Expected behavior
Static binary for aarch64 should be built.

Notify maintainers

@cdepillabout

Metadata
Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

 - system: `"x86_64-linux"`
 - host os: `Linux 5.11.13-arch1-1, Arch Linux, noversion`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.3.8`
 - channels(root): `"nixpkgs-21.03pre250093.0da76dab4c2"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixpkgs`

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute:
# a list of nixos modules affected by the problem
module:
@cdepillabout
Copy link
Member

pretty-simple also fails to build in pkgsStatic:

$ nix-build -A pkgsStatic.haskellPackages.pretty-simple
these derivations will be built:
  /nix/store/3n72nymdzdmkdih26pchgslh3xw3xxvi-pretty-simple-4.0.0.0-x86_64-unknown-linux-musl.drv
building '/nix/store/3n72nymdzdmkdih26pchgslh3xw3xxvi-pretty-simple-4.0.0.0-x86_64-unknown-linux-musl.drv'...
...
Building library for pretty-simple-4.0.0.0..
[1 of 7] Compiling Text.Pretty.Simple.Internal.Color ( src/Text/Pretty/Simple/Internal/Color.hs, dist/build/Text/Pretty/Simple/Internal/Color.o, dist/build/Text/Pretty/Simple/Internal/Color.
dyn_o )
[2 of 7] Compiling Text.Pretty.Simple.Internal.Expr ( src/Text/Pretty/Simple/Internal/Expr.hs, dist/build/Text/Pretty/Simple/Internal/Expr.o, dist/build/Text/Pretty/Simple/Internal/Expr.dyn_
o )
[3 of 7] Compiling Text.Pretty.Simple.Internal.ExprParser ( src/Text/Pretty/Simple/Internal/ExprParser.hs, dist/build/Text/Pretty/Simple/Internal/ExprParser.o, dist/build/Text/Pretty/Simple/
Internal/ExprParser.dyn_o )
attempting to use module ‘pretty-simple-4.0.0.0-7XPG9KFSjjE3sIrbReVEek:Text.Pretty.Simple.Internal.Expr’ (src/Text/Pretty/Simple/Internal/Expr.hs) which is not loaded
builder for '/nix/store/3n72nymdzdmkdih26pchgslh3xw3xxvi-pretty-simple-4.0.0.0-x86_64-unknown-linux-musl.drv' failed with exit code 1
error: build of '/nix/store/3n72nymdzdmkdih26pchgslh3xw3xxvi-pretty-simple-4.0.0.0-x86_64-unknown-linux-musl.drv' failed

This is run on commit 34de748.

Maybe @sternenseemann or @rnhmjoj would have some idea of what is happening here.

@rnhmjoj
Copy link
Contributor

rnhmjoj commented May 25, 2021

Uhm, in ghci this error seems to happen when importing a module that is not loaded, not sure what it means in this context. If I had to guess, it has something to do with TemplateHaskell, which is not working in pkgsStatic (see #61575).

@573
Copy link
Contributor Author

573 commented May 25, 2021

Without really knowing what to do with this, already stumpled upon the TemplateHaskell topic before (#123860) while trying to statically build hledger to aarch64.

Yeah I was hoping we could use -fexternal-interpreter for this case.

Originally posted by @matthewbauer in #61575 (comment)

@domenkozar
Copy link
Member

Maybe @angerman has some insights into this.

@sternenseemann sternenseemann added the 6.topic: cross-compilation Building packages on a different platform than they will be used on label Jun 15, 2021
@domenkozar
Copy link
Member

https://www.tweag.io/blog/2020-11-25-asterius-th/ to demonstrate what this involves and https://input-output-hk.github.io/haskell.nix/motivation/ that implements it.

@573
Copy link
Contributor Author

573 commented Jun 17, 2021

EDIT: Still seems unrelated for me now that I gave it more thought.

Using

LC_ALL=C NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs/archive/830ef6422f643d5c639fd79bca834c726787ec51.tar.gz \
nix-build '<nixpkgs>' -A pkgsCross.aarch64-multiplatform-musl.pkgsStatic.haskellPackages.pretty-simple

I got this built.

Just for reference, current master/nixos-unstable also builds

LC_ALL=C NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs/archive/b0cf786b967590e577a63d6732dba656bb2fd25a.tar.gz \
nix-build '<nixpkgs>' -A pkgsCross.aarch64-multiplatform-musl.pkgsStatic.haskellPackages.pretty-simple

@573
Copy link
Contributor Author

573 commented Jun 18, 2021

@domenkozar As far as I understand it the following might be worth mentioning as @facundominguez was able to faciliate the use of iserv/-proxy to achieve the TH challenge ?

Here's my best attempt so far:

let crossPkgs = pkgs.pkgsCross.aarch64-multiplatform;
    haskellNix = import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/b406bb1d5bed581f651ae18a5d3ed07f47ace2b9.tar.gz) {};
    pkgs = import haskellNix.sources.nixpkgs haskellNix.nixpkgsArgs;
in
pkgs.mkShell {
  buildInputs = 
    [ pkgs.buildPackages.ghc-extra-packages.ghc8102.iserv-proxy.components.exes.iserv-proxy
      crossPkgs.ghc-extra-packages.ghc8102.remote-iserv.components.exes.remote-iserv
      crossPkgs.buildPackages.haskell-nix.compiler.ghc8102
      pkgs.buildPackages.qemu
    ];
} 

Originally posted by @facundominguez in input-output-hk/haskell.nix#868 (comment)

@domenkozar
Copy link
Member

I'm still puzzled how pretty-simple used to build statically a month ago.

rnhmjoj added a commit to rnhmjoj/nixpkgs that referenced this issue Mar 9, 2022
This change allows loading statically compiled libreries into a running
GHC, thus fixing the build of haskell packages that use TemplateHaskell.
See [1] for the details.

Fixes issue NixOS#61575, NixOS#124284.

[1]: https://www.tweag.io/blog/2020-09-30-bazel-static-haskell/
sternenseemann pushed a commit that referenced this issue Mar 17, 2022
This change allows loading statically compiled libreries into a running
GHC, thus fixing the build of haskell packages that use TemplateHaskell.
See [1] for the details.

Fixes issue #61575, #124284.

[1]: https://www.tweag.io/blog/2020-09-30-bazel-static-haskell/
@cdepillabout
Copy link
Member

cdepillabout commented Apr 9, 2022

This has been fixed by #162374, which is included in #160733.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken 6.topic: cross-compilation Building packages on a different platform than they will be used on 6.topic: haskell 6.topic: static
Projects
None yet
Development

No branches or pull requests

6 participants