Skip to content

Commit

Permalink
Add missing libblst to GHC options of wrapped-cabal in static mode. (#…
Browse files Browse the repository at this point in the history
…125)

* Add missing libblst to GHC options of wrapped-cabal in static mode.

* comment out post-fixup

* Overwrite buildPhase for libblst static

  The current buildPhase in NixOS/nixpkgs does something like this:

  ```
  ./build.sh ${lib.optionalString stdenv.hostPlatform.isWindows "flavour=mingw64"}
  ./build.sh -shared ${lib.optionalString stdenv.hostPlatform.isWindows "flavour=mingw64"}
  ```

  So we do build both a dynamic and static version, for convenience,
  which is then correctly visible in the nix store (both `.a` and
  `.dylib` are present).

  BUT, it seems that because of the presence of the dynamic lib, cabal
  or GHC (?) still chose to bundle the library dynamically despite the
  static flags. Removing the `.dylib` from the nix store recover the
  expected behavior (libblst being statically linked).

  This is odd, but the current fix is to not build the `-shared` version
  of the library at all when in the static shell.

  Co-authored-by: yvan-sraka <[email protected]>

* Enforce the use of static libraries in `-static` devshell

---------

Co-authored-by: Yvan Sraka <[email protected]>
  • Loading branch information
KtorZ and yvan-sraka authored Apr 4, 2024
1 parent 8dcb4f0 commit bb543f0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
9 changes: 9 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@
static-openssl = (final.openssl.override { static = true; });
static-zlib = final.zlib.override { shared = false; };
static-pcre = final.pcre.override { shared = false; };
static-libblst = final.libblst.overrideDerivation (old: {
configureFlags = old.configureFlags ++ [ "--enable-static" "--disable-shared" ];
buildPhase = ''
runHook preBuild
./build.sh
runHook postBuild
'';
postFixup = "";
});
});
# the haskell inline-r package depends on internals of the R
# project that have been hidden in R 4.2+. See
Expand Down
14 changes: 7 additions & 7 deletions static.nix
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ let tool-version-map = import ./tool-map.nix;
--ghc-option=-L${lib.getLib static-gmp}/lib \
--ghc-option=-L${lib.getLib static-libsodium-vrf}/lib \
--ghc-option=-L${lib.getLib static-secp256k1}/lib \
--ghc-option=-L${lib.getLib static-libblst}/lib \
--ghc-option=-L${lib.getLib static-openssl}/lib
;;
clean|unpack)
Expand Down Expand Up @@ -105,15 +106,14 @@ pkgs.mkShell (rec {
# it _should_ probably call out to a g++ or clang++ but doesn't.
stdenv.cc.cc.lib
]) ++ map lib.getDev ([
static-gmp

zlib
pcre
openssl
static-gmp
static-openssl
static-zlib
] ++ lib.optionals withIOG [
libblst
libsodium-vrf
secp256k1
static-libblst
static-libsodium-vrf
static-secp256k1
#R_4_1_3 # for plutus
postgresql # for db-sync
icu # for cardano-cli
Expand Down

0 comments on commit bb543f0

Please sign in to comment.