Skip to content

Commit 9e3463d

Browse files
hamishmackthomasjm
andauthored
Switch to enableNativeBignum = true when available (input-output-hk#1784)
* Switch to enableNativeBignum = true when available * Fix bitvec dependency on gmp Adds Bodigrim/bitvec#61 * Fix dynamic linking tests (now GMP is not always linked) Co-authored-by: Tom McLaughlin <tom@codedown.io>
1 parent 2d0b230 commit 9e3463d

File tree

6 files changed

+42
-4
lines changed

6 files changed

+42
-4
lines changed

modules/configuration-nix.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,9 @@ in {
139139
packages.ghc.flags.internal-interpreter = true;
140140
packages.ghci.flags.ghci = true;
141141
packages.ghci.flags.internal-interpreter = true;
142+
143+
# See https://github.com/Bodigrim/bitvec/pull/61
144+
packages.bitvec.patches = [
145+
(fromUntil "1.1.3.0" "1.1.3.0.1" ../patches/bitvec-gmp-fix.patch)
146+
];
142147
}

overlays/ghc.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ final: prev: with prev;
55
hasNativeBignum = name: !lib.hasPrefix "ghc8" name;
66

77
ghcPkgOverrides = name: { enableIntegerSimple = false; } // lib.optionalAttrs (hasNativeBignum name) {
8-
enableNativeBignum = false;
8+
enableNativeBignum = true;
99
};
1010

1111
ghcDrvOverrides = drv: {

patches/bitvec-gmp-fix.patch

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
From 903561107640cdbe1fbb3669c58e006d8b658fb8 Mon Sep 17 00:00:00 2001
2+
From: Mikaela Allan <mikaela@vitalbio.com>
3+
Date: Sun, 31 Jul 2022 11:52:27 -0400
4+
Subject: [PATCH] include Data.Bit.Gmp only if libgmp flag is set
5+
6+
if this module is linked into the library when libgmp is not enabled,
7+
the foreign imports will lead to link failures when consuming the
8+
library.
9+
---
10+
bitvec.cabal | 3 ++-
11+
1 file changed, 2 insertions(+), 1 deletion(-)
12+
13+
diff --git a/bitvec.cabal b/bitvec.cabal
14+
index c6cb6c0..d4a28d6 100644
15+
--- a/bitvec.cabal
16+
+++ b/bitvec.cabal
17+
@@ -78,7 +78,6 @@ library
18+
other-modules:
19+
Data.Bit.F2Poly
20+
Data.Bit.F2PolyTS
21+
- Data.Bit.Gmp
22+
Data.Bit.Immutable
23+
Data.Bit.ImmutableTS
24+
Data.Bit.Internal
25+
@@ -98,6 +97,8 @@ library
26+
if flag(libgmp)
27+
extra-libraries: gmp
28+
cpp-options: -DUseLibGmp
29+
+ other-modules:
30+
+ Data.Bit.Gmp
31+
32+
test-suite bitvec-tests
33+
type: exitcode-stdio-1.0

test/cabal-22/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ in recurseIntoAttrs {
3939
optionalString (!stdenv.hostPlatform.isAarch32 && !stdenv.hostPlatform.isAarch64) (''
4040
printf "checking that executable is dynamically linked to system libraries... " >& 2
4141
'' + optionalString (stdenv.isLinux && !stdenv.hostPlatform.isMusl) ''
42-
ldd $exe | grep libgmp
42+
ldd $exe | grep 'libc[.]so'
4343
'' + optionalString stdenv.isDarwin ''
4444
otool -L $exe | grep "libSystem.B"
4545
'' + ''

test/cabal-sublib/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ in recurseIntoAttrs {
4747
optionalString (!stdenv.hostPlatform.isAarch32 && !stdenv.hostPlatform.isAarch64 && !stdenv.hostPlatform.isMusl) (''
4848
printf "checking that executable is dynamically linked to system libraries... " >& 2
4949
'' + optionalString (stdenv.isLinux && !stdenv.hostPlatform.isMusl) ''
50-
ldd $exe | grep libgmp
50+
ldd $exe | grep 'libc[.]so'
5151
'' + optionalString stdenv.isDarwin ''
5252
otool -L $exe |grep .dylib
5353
'') + ''

test/sublib-docs/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ in recurseIntoAttrs {
3939
optionalString (!stdenv.hostPlatform.isAarch32 && !stdenv.hostPlatform.isAarch64 && !stdenv.hostPlatform.isMusl) (''
4040
printf "checking that executable is dynamically linked to system libraries... " >& 2
4141
'' + optionalString (stdenv.isLinux && !stdenv.hostPlatform.isMusl) ''
42-
ldd $exe | grep libgmp
42+
ldd $exe | grep 'libc[.]so'
4343
'' + optionalString stdenv.isDarwin ''
4444
otool -L $exe |grep .dylib
4545
'') + ''

0 commit comments

Comments
 (0)