input-output-hk / haskell.nix

Alternative Haskell Infrastructure for Nixpkgs
https://input-output-hk.github.io/haskell.nix
Apache License 2.0
557 stars 239 forks source link

Can't build `libsecp256k1` for musl64 #1505

Closed KtorZ closed 2 years ago

KtorZ commented 2 years ago

Hey there. I use to be able to cross-compile (from Linux 64-bit) executable with the relatively simple following incantation:

let
  pkgs = import nixpkgsSrc (nixpkgsArgs // {
    overlays =
      # iohkNix overlay needed for cardano-api wich uses a patched libsodium
      haskellNix.overlays ++ iohkNix.overlays.crypto;
  });
  musl64 = pkgs.pkgsCross.musl64;
in
musl64.haskell-nix.project {
   ...
}

Yet, this no long works with cardano-node dependencies set corresponding to 1.35.0-rc1, and fails with:

checking how to run the C preprocessor... x86_64-unknown-linux-musl-gcc -E
checking for gcc... no
checking for cc... no
checking for cl.exe... no
checking for clang... no
checking whether C compiler accepts -msse4.1... yes
configure: error: in `/build/source':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
error: builder for '/nix/store/33r3ybkmn1zyp17cpv3a0f871y9a96nk-secp256k1-x86_64-unknown-linux-musl-unstable-2021-06-06.drv' failed with exit code 1
error: 1 dependencies of derivation '/nix/store/jm9gj73nsdzffrzkcdaffljg4qzdahz7-cardano-crypto-class-lib-cardano-crypto-class-x86_64-unknown-linux-musl-2.0.0.drv' failed to build

I am guessing I am missing some kind of overlay too for secp256k1? Any clue?


Note that I recently updated Haskell.nix & al to:

See entire default.nix for reference. ```nix { compiler ? "ghc8107" , system ? builtins.currentSystem , haskellNix ? import (builtins.fetchTarball "https://github.com/input-output-hk/haskell.nix/archive/974a61451bb1d41b32090eb51efd7ada026d16d9.tar.gz") { } , iohkNix ? import (builtins.fetchTarball "https://github.com/input-output-hk/iohk-nix/archive/edb2d2df2ebe42bbdf03a0711115cf6213c9d366.tar.gz") { } , nixpkgsSrc ? haskellNix.sources.nixpkgs-2111 , nixpkgsArgs ? haskellNix.nixpkgsArgs }: let pkgs = import nixpkgsSrc (nixpkgsArgs // { overlays = # iohkNix overlay needed for cardano-api wich uses a patched libsodium haskellNix.overlays ++ iohkNix.overlays.crypto; }); musl64 = pkgs.pkgsCross.musl64; in musl64.haskell-nix.project { compiler-nix-name = compiler; projectFileName = "cabal.project"; src = musl64.haskell-nix.haskellLib.cleanSourceWith { name = "ogmios-src"; src = ./.; subDir = "server"; filter = path: type: builtins.all (x: x) [ (baseNameOf path != "package.yaml") ]; }; } ```
hamishmack commented 2 years ago

Try switching nixpkgsSrc from nixpkgs-2111 to nixpkgs-unstable

KtorZ commented 2 years ago

@hamishmack thanks, the build seems to have gone through. Still building though. Is there some stable pin I could use instead of unstable that'd still make it work?

hamishmack commented 2 years ago

I was planning to update the nixpkgs pins and add a nixpkgs-2205 pin this weekend. It will take some time to build all the cached GHCs on hydra (so I'll start Saturday when hydra is less busy).

angerman commented 2 years ago

@KtorZ if you use the same pins as in input-output-hk/tools, it should be cached, as it's built here: https://ci.zw3rk.com/eval/1274, if you use

--option substituters http://cache.zw3rk.com/ --option trusted-public-keys "loony-tools:pr9m4BkM/5/eSTZlkQyRt57Jz7OMBxNSUiMC4FkcNfk="
KtorZ commented 2 years ago

Thanks @angerman (& @hamishmack), I am using my own cachix cache for Ogmios anyway so I've -- supposedly -- a shared cache. The build just finished with nixpkgs-unstable:

Building executable 'ogmios' for ogmios-5.4.0..
[1 of 2] Compiling Main             ( app/Main.hs, dist/build/ogmios/ogmios-tmp/Main.o )
[2 of 2] Compiling Paths_ogmios     ( dist/build/ogmios/autogen/Paths_ogmios.hs, dist/build/ogmios/ogmios-tmp/Paths_ogmios.o )
Linking dist/build/ogmios/ogmios ...
installing
Installing executable ogmios in /nix/store/156cmqzlnhzfnh9iqzz3szjyzmc94x9z-ogmios-exe-ogmios-x86_64-unknown-linux-musl-5.4.0/bin
Warning: The directory
/nix/store/156cmqzlnhzfnh9iqzz3szjyzmc94x9z-ogmios-exe-ogmios-x86_64-unknown-linux-musl-5.4.0/bin
is not in the system search path.
post-installation fixup
patching script interpreter paths in /nix/store/156cmqzlnhzfnh9iqzz3szjyzmc94x9z-ogmios-exe-ogmios-x86_64-unknown-linux-musl-5.4.0
checking for references to /build/ in /nix/store/156cmqzlnhzfnh9iqzz3szjyzmc94x9z-ogmios-exe-ogmios-x86_64-unknown-linux-musl-5.4.0...
patchelf: cannot find section '.dynamic'. The input file is most likely statically linked
patching script interpreter paths in /nix/store/5306pspf0a01zqfyvry4aqdn9l8asdsl-ogmios-exe-ogmios-x86_64-unknown-linux-musl-5.4.0-data
checking for references to /build/ in /nix/store/5306pspf0a01zqfyvry4aqdn9l8asdsl-ogmios-exe-ogmios-x86_64-unknown-linux-musl-5.4.0-data...
/nix/store/156cmqzlnhzfnh9iqzz3szjyzmc94x9z-ogmios-exe-ogmios-x86_64-unknown-linux-musl-5.4.0

Happy to stick to a different more stable pin for the nix packages though :+1: