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

Support for GHC 8.10.1 #90

Closed
the-dr-lazy opened this issue Apr 16, 2020 · 8 comments
Closed

Support for GHC 8.10.1 #90

the-dr-lazy opened this issue Apr 16, 2020 · 8 comments
Labels
help wanted Extra attention is needed

Comments

@the-dr-lazy
Copy link

the-dr-lazy commented Apr 16, 2020

I have tried to build GHC 8.10.1 against musl in thebrodmann/soallpeach/next.

static.nix

{ compiler ? "ghc8101" }:
let
  static-haskell-nix = fetchTarball https://github.com/nh2/static-haskell-nix/archive/d1b20f35ec7d3761e59bd323bbe0cca23b3dfc82.tar.gz;

  nixpkgs = fetchTarball https://github.com/NixOS/nixpkgs/archive/ddc2f887f5f4b31128e8d4a56cb524c1d36d6fd4.tar.gz;

  pkgs = (import nixpkgs {}).pkgsMusl;

  static-haskell-nix-servay = static-haskell-nix + "/survey/default.nix";
  survey = import static-haskell-nix-servay {
    inherit compiler pkgs;
    approach = "pkgsMusl";
    defaultCabalPackageVersionComingWithGhc = "Cabal_3_0_0_0";
  };

  prime = import ./default.nix {
    inherit compiler pkgs;
    haskellPackages = survey.haskellPackages;
  };

  buildStatic = drv:
    with pkgs.haskell.lib;
    appendConfigureFlags
    (disableSharedExecutables (disableSharedLibraries drv)) [
      "--ghc-option=-optl=-static"
      "--ghc-option=-optl=-pthread"
      "--extra-lib-dirs=${pkgs.gmp6.override { withStatic = true; }}/lib"
      "--extra-lib-dirs=${pkgs.zlib.static}/lib"
      "--extra-lib-dirs=${
        pkgs.libffi.overrideAttrs (old: { dontDisableStatic = true; })
      }/lib"
    ];

in buildStatic prime.production

default.nix

{ pkgs ? import <nixpkgs> { }
, compiler ? "ghc8101"
, haskellPackages ? pkgs.haskell.packages.${compiler} }:
let
  prime = { mkDerivation, attoparsec, base, bzip2, conduit, conduit-algorithms
    , conduit-extra, lzma, stdenv, text, vector, bytestring, arithmoi }:
    mkDerivation {
      pname = "prime";
      version = "0.1.0.0";
      src = ./.;
      isLibrary = false;
      isExecutable = true;
      executableHaskellDepends = [
        attoparsec
        base
        bytestring
        arithmoi
      ];
      description = "Haskell primality test algorithm for soallpeach";
      license = stdenv.lib.licenses.gpl3;
    };

  overrides = self: super: { prime = super.callPackage prime {}; };

  haskellPackages' = haskellPackages.extend overrides;
in with pkgs.haskell.lib; {
  development = appendConfigureFlags (disableOptimization haskellPackages'.prime) [
    "--ghc-option=-threaded"
    "--ghc-option=-rtsopts"
  ];
  production = appendConfigureFlags haskellPackages'.prime [
    "--ghc-option=-Werror"
    "--ghc-option=-O2"
    "--ghc-option=-threaded"
    "--ghc-option=-rtsopts"
    "--ghc-option=-with-rtsopts=-N"
  ];
}

It failed with the following error:

"inplace/bin/ghc-stage1" -optc-Wall -optc-Wall -optc-Wextra -optc-Wstrict-prototypes -optc-Wmissing-prototypes -optc-Wmissing-declarations -optc-Winline -optc-Wpointer-arith -optc-Wmissing-noreturn -optc-Wnested-externs -optc-Wredundant-decls -optc-Wno-aggregate-return -optc-Iincludes -optc-Iincludes/dist -optc-Iincludes/dist-derivedconstants/header -optc-Iincludes/dist-ghcconstants/header -optc-Iincludes/dist-install/build -optc-Irts -optc-Irts/dist/build -optc-DCOMPILING_RTS -optc-DFS_NAMESPACE=rts -optc-fno-strict-aliasing -optc-fno-common -optc-Irts/dist/build/./autogen -optc-Werror=unused-but-set-variable -optc-Wno-error=inline -optc-O2 -optc-fomit-frame-pointer -optc-g -optc-DDYNAMIC -optc-DRtsWay=\"rts_thr_l_dyn\" -optc-ffunction-sections -optc-fdata-sections -fPIC -dynamic -optc-DTHREADED_RTS -eventlog  -H32m -O -Wall   -Iincludes -Iincludes/dist -Iincludes/dist-derivedconstants/header -Iincludes/dist-ghcconstants/header -Iincludes/dist-install/build -Irts -Irts/dist/build -DCOMPILING_RTS -DFS_NAMESPACE=rts -this-unit-id rts -dcmm-lint      -i -irts -irts/dist/build -Irts/dist/build -irts/dist/build/./autogen -Irts/dist/build/./autogen            -O2 -Wcpp-undef    -Wnoncanonical-monad-instances  -c rts/posix/OSThreads.c -o rts/dist/build/posix/OSThreads.thr_l_dyn_o
grep -v ' : [a-zA-Z]:/' libraries/Cabal/Cabal/dist-install/build/.depend-v-p-dyn.haskell.tmp > libraries/Cabal/Cabal/dist-install/build/.depend-v-p-dyn.haskell.tmp2
sed -e '/hs$/ p' -e '/hs$/ s/o /hi /g' -e '/hs$/ s/:/ : %hi: %o /' -e '/hs$/ s/^/$(eval $(call hi-rule,/' -e '/hs$/ s/$/))/' -e '/hs-boot$/ p' -e '/hs-boot$/ s/o-boot /hi-boot /g' -e '/hs-boot$/ s/:/ : %hi-boot: %o-boot /' -e '/hs-boot$/ s/^/$(eval $(call hi-rule,/' -e '/hs-boot$/ s/$/))/' libraries/Cabal/Cabal/dist-install/build/.depend-v-p-dyn.haskell.tmp2 > libraries/Cabal/Cabal/dist-install/build/.depend-v-p-dyn.haskell
"inplace/bin/mkdirhier" libraries/base/dist-install/build/GHC/IO/Handle/Lock//.
"inplace/bin/mkdirhier" libraries/base/dist-install/build/GHC/Event//.
"inplace/bin/mkdirhier" libraries/base/dist-install/build/System/CPUTime/Posix//.
"cp" libraries/base/./GHC/Stack/CCS.hs-boot libraries/base/dist-install/build/GHC/Stack/CCS.hs-boot
cp: cannot create regular file 'libraries/base/dist-install/build/GHC/Stack/CCS.hs-boot': No such file or directory
libraries/integer-gmp/ghc.mk:4: libraries/integer-gmp/dist-install/build/.depend-v-p-dyn.haskell: No such file or directory
make[1]: *** [libraries/base/ghc.mk:4: libraries/base/dist-install/build/GHC/Stack/CCS.hs-boot] Error 1
make: *** [Makefile:128: all] Error 2
builder for '/nix/store/0ca3z81zbc9r8drx7aqvc6g015pvvlr4-ghc-8.10.0.20200123.drv' failed with exit code 2
cannot build derivation '/nix/store/xf3iw6nqcrwgc4m0yh06k46vcqylpcj9-Cabal-3.0.0.0.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/igs8i30xhh35irrz4mzy5r09c50c7bym-ansi-terminal-0.9.1.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/zrqvm4mblmg40ch69gnk5fbgrgl0yzxv-ansi-wl-pprint-0.6.9.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/h952a3l1nf5bqrv6q53b1qgnz8x4ip1p-arithmoi-0.9.0.0.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/564ma7rbqryx189rfkhlcswcqzzyj35v-async-2.2.2.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/41gzizmba7nzc5afmdj3rwmnvbr5gsyd-hashable-1.2.7.0.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/3ix12jdyxgzx52yy2fv1m4rzjhkl3f5x-hspec-discover-2.7.1.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/gi4j2a9lk165rp2654h4wgy5xq5x7wga-hspec-meta-2.6.0.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/3fsp5scfc4h8c3dq1zbkzpad66ynz6w0-wcwidth-0.0.2.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/ydk4wq01snrsygqpgiq8s1azmgmmp7nc-prime-0.1.0.0.drv': 1 dependencies couldn't be built
error: build of '/nix/store/ydk4wq01snrsygqpgiq8s1azmgmmp7nc-prime-0.1.0.0.drv' failed

I know that GHC 8.10.1 is not supported yet, but I'm interested to see is it possible or not?

@nh2
Copy link
Owner

nh2 commented Apr 18, 2020

GHC 8.10 is brand new in nixpkgs, and there are many packages thta don't work with it yet, so I will probably have to wait until I can look into making that work.

@avanov
Copy link

avanov commented Jul 25, 2020

It's been 3 month since the issue was opened and 8.10 is not that brand new already. I am using it from nixpgs-unstable (both gmp and integer-simple ones) with dynamic linking, I think it's time for brining static linking to it. I'm happy to help if there's a known pattern to follow to bring a new compiler version to this project.

@nh2
Copy link
Owner

nh2 commented Jul 27, 2020

Hey, the approach I use is usually the following:

  • Update nixpkgs submodule to current master
  • Update defaultCabalPackageVersionComingWithGhc to include an entry for 8.10
  • Update compiler ? "ghc865", to the new GHC version (you can also set that via a nix-build --argStr
  • Run NIX_PATH=nixpkgs=nixpkgs nix-build --pure survey/default.nix --arg disableOptimization true -A haskellPackages.hello, make that work
  • Subsequently make work:
    • -A working
    • -A workingStackageExecutables
    • drop --arg disableOptimization true
  • Along the way,
    • Remove patches that may no longer be necessary/applicable
    • Fix issues that may come up, contributing them to nixpkgs where possible, or putting them into the submodule when it's difficult.

@nh2
Copy link
Owner

nh2 commented Jul 27, 2020

Another blocker for this: NixOS/nixpkgs#85924

@nh2 nh2 mentioned this issue Jul 27, 2020
5 tasks
@nh2 nh2 added the help wanted Extra attention is needed label Jul 27, 2020
@nh2
Copy link
Owner

nh2 commented Jul 27, 2020

I've made a WIP PR #98 in which we can work on this together.

I am currently quite busy so I would appreciate for others to join in the effort to make it work together.

Road blockers should also be posted there (instead of here).

@avanov
Copy link

avanov commented Jul 28, 2020

Awesome, thanks! Let me check how much time I can allocate from my working hours, but if not, I can spare some weekend time as I also have pet projects that run on 8.10 and that I'd like to bring static linking to.

@nh2
Copy link
Owner

nh2 commented Jul 30, 2020

@avanov I've put a lot of fixes in #98 by now so there is some chance for your packages to build on that now; however, a lot of packages simply have broken upper bounds and this will only be fixed when Stackage updates to an LTS with GHC 8.10 in, and nixpkgs updates to that Stackage version.

Nevertheless, there are more things that can be fixed independent of that, and I have listed them in the description of #98.

In particular, helping with #99 (comment) would be the biggest impact contribution (tracked at #99).

After that, it may also make sense to help improving GHC 8.8.3 support (which currently is also dependent on the above sentence).

@nh2
Copy link
Owner

nh2 commented Jul 23, 2021

PR #98 was merged, GHC 8.10 is now fully working.

@nh2 nh2 closed this as completed Jul 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants