Skip to content

Tracking issue for GHC bootstrapping compilers being broken with musl in nixpkgs #99

Closed
@talw

Description

@talw

First of all, a big thanks for all the work on this big project!

I am trying to build a project statically with GHC 8.8.3 and I get the following error:

/nix/store/nrdv3qhafvxnvbxqksahnffw47ymafh7-ghc-8.6.5-binary/lib/ghc-8.6.5/bin/ghc-pkg: /nix/store/pk12rld0n6g6k74s0c0j9wmr7glpfnrj-ncurses-6.2-abi5-compat/lib/libtinfo.so.5: no version information available (required by /nix/store/nrdv3qhafvxnvbxqksahnffw47ymafh7-ghc-8.6.5-binary/lib/ghc-8.6.5/bin/../terminfo-0.4.1.2/libHSterminfo-0.4.1.2-ghc8.6.5.so)
Inconsistency detected by ld.so: dl-lookup.c: 111: check_match: Assertion `version->filename == NULL || ! _dl_name_match_p (version->filename, map)' failed!
make[1]: *** [ghc.mk:991: install_packages] Error 127
make: *** [Makefile:51: install] Error 2
builder for '/nix/store/4xb1js32jx9a1iwa1b4l3zb5vqm81cvy-ghc-8.6.5-binary.drv' failed with exit code 2
cannot build derivation '/nix/store/jkjqd7fwgv18mqlm8zrpm95cz17h313a-ghc-8.8.3.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/p75l86x5qapq0grk7a3cj2lwi52db9qr-myProj-0.1.0.drv': 1 dependencies couldn't be built

The involved files are:

default.nix:

let
  compiler = "ghc883";

  pkgs = import ./nix/pkgs.nix compiler;

  static-haskell-nix = fetchGit (builtins.fromJSON (builtins.readFile ./nix/static-haskell-rev.json));
  static-pkgs = (import (static-haskell-nix + "/survey/default.nix") {
      pkgs = pkgs.pkgsMusl;
      inherit compiler;
      defaultCabalPackageVersionComingWithGhc = "Cabal_3_0_0_0";
    }).pkgs;

  haskPkgs = pkgs.haskell.packages.${compiler};

  gitignore = pkgs.nix-gitignore.gitignoreSourcePure [ ./.gitignore ];

  static-drv = static-pkgs.haskell.lib.overrideCabal
            (static-pkgs.haskell.packages.${compiler}.callPackage ./proj.nix {})
            (old: {
                  configureFlags = [
                    "-flambda"
                    "--ghc-option=-fPIC"
                    "--ghc-option=-optl-static"
                    "--ghc-option=-optc-static"
                    "--ghc-option=-optl-pthread"
                    "--ld-option=-static"
                    "--ld-option=-pthread"
                    "--extra-lib-dirs=${static-pkgs.gmp6.override { withStatic = true; }}/lib"
                    "--extra-lib-dirs=${static-pkgs.zlib.static}/lib"
                    "--extra-lib-dirs=${static-pkgs.libffi.overrideAttrs (old: { dontDisableStatic = true; })}/lib"
                    "--disable-executable-stripping"
                  ];
            });

in
  {
    inherit static-drv;
  }

proj.nix:

{ mkDerivation, aeson, amazonka, amazonka-core, amazonka-dynamodb
, amazonka-sqs, aws-lambda-haskell-runtime, base, bytestring
, composition, containers, either, generic-lens, iproute, microlens
, random, rio, stdenv, text, time, unordered-containers, uuid
, vector
}:
mkDerivation {
  pname = "myProj";
  version = "0.1.0";
  src = ./.;
  isLibrary = true;
  isExecutable = true;
  libraryHaskellDepends = [
    aeson amazonka amazonka-core amazonka-dynamodb amazonka-sqs
    aws-lambda-haskell-runtime base bytestring composition containers
    either generic-lens iproute microlens random rio text time
    unordered-containers uuid vector
  ];
  executableHaskellDepends = [
    amazonka aws-lambda-haskell-runtime base iproute
  ];
  license = "unknown";
  hydraPlatforms = stdenv.lib.platforms.none;
}

nix/pkgs-rev.json:

{
  "url": "git://github.com/NixOS/nixpkgs-channels",
  "ref": "nixos-unstable",
  "rev": "4cdd64d9078181e8fcb6132909dc2835059a09bd"
}

nix/static-haskell-rev.json:

{
  "url": "git://github.com/nh2/static-haskell-nix",
  "ref": "master",
  "rev": "dbce18f4808d27f6a51ce31585078b49c86bd2b5"
}

I tried many other permutations of options for configureFlags, as well as
adding stuff to the cabal file like ld-options: -static and cc-options: -static.

ghc-options: -threaded -rtsopts -O2 -static -with-rtsopts=-N
ld-options: -static -pthread
cc-options: -static

While, this is not enough to reproduce the problem yourselves, If I could receive
as much as a clue as to a possible direction I should head towards, or a thing
I should try, I will do it and reply with the results, so feel free to suggest anything!

Why is GHC 8.6.5 involved in the building of this? Is this related to the version
mismatch? I tried stating a build with compiler = "ghc865"
It gave an error about a dependency time not found at the correct version for rebase,
so I jailbroken it and continued building but again, once the last module for the project finishes compiling I get an error about that crtbeginT.o but this time the message is different:

/nix/store/x4hjqhnzfbzh4f333xh1sq31zak3dab1-binutils-2.31.1/bin/ld: /nix/store/p9q71abn3zxpbqrr1k4f35j3k6kx8ayk-gcc-9.3.0/lib/gcc/x86_64-unknown-linux-musl/9.3.0/crtbeginT.o: relocation R_X86_64_32 against hidden symbol `__TMC_END__' can not be used when making a shared object
/nix/store/x4hjqhnzfbzh4f333xh1sq31zak3dab1-binutils-2.31.1/bin/ld: /nix/store/p9q71abn3zxpbqrr1k4f35j3k6kx8ayk-gcc-9.3.0/lib/gcc/x86_64-unknown-linux-musl/9.3.0/crtend.o: relocation R_X86_64_32 against `.ctors' can not be used when making a shared object; recompile with -fPIC
/nix/store/x4hjqhnzfbzh4f333xh1sq31zak3dab1-binutils-2.31.1/bin/ld: final link failed: nonrepresentable section on output
collect2: error: ld returned 1 exit status
`cc' failed in phase `Linker'. (Exit code: 1)

Anyone got a static build working with GHC 8.8.x?

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions