Skip to content

Commit 9faf556

Browse files
committed
Fix the mingw build
1 parent acdc7d8 commit 9faf556

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

flake.nix

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@
8787
];
8888
});
8989

90+
# Static gmp for Windows builds
91+
gmpStatic = pkgsForHost.gmp.overrideAttrs (old: {
92+
dontDisableStatic = true;
93+
configureFlags = (old.configureFlags or [ ]) ++ [
94+
"--enable-static"
95+
"--disable-shared"
96+
];
97+
});
98+
9099
# libpng that uses zlib-ng instead of plain zlib
91100
libpngWithZlibNg = pkgsForHost.libpng.override {
92101
zlib = zlibNgStatic;
@@ -115,6 +124,7 @@
115124
withShared = false;
116125
withStatic = true;
117126
zlib = zlibNgStatic;
127+
gmp = gmpStatic;
118128

119129
# Disable CUDA/LLVM to avoid compiler-rt dependency
120130
withCuda = false;
@@ -201,10 +211,19 @@
201211
# Use static versions of libpng and libjpeg for Windows
202212
(
203213
if isWindows then
204-
libjpeg.override {
214+
(libjpeg.override {
205215
enableStatic = true;
206216
enableShared = false;
207-
}
217+
}).overrideAttrs
218+
(old: {
219+
cmakeFlags = (old.cmakeFlags or [ ]) ++ [
220+
"-DWITH_SIMD=0"
221+
];
222+
# Fix the existing mingw-boolean patch which leaves an unterminated #ifndef
223+
postPatch = (old.postPatch or "") + ''
224+
sed -i '/#ifndef HAVE_BOOLEAN/d' src/jmorecfg.h
225+
'';
226+
})
208227
else
209228
libjpeg
210229
)
@@ -253,6 +272,7 @@
253272
"-Denable_tests=false"
254273
];
255274
}))
275+
gmpStatic
256276
]
257277
++ pkgsForHost.lib.optionals (pkgsForHost.stdenv.isLinux && !isStatic) [
258278
glib

justfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
configure:
2+
cmake -S . -B build -G Ninja -DCMAKe_BUILT_TYPE=Release
3+
4+
build: configure
5+
cmake --build ./build
6+
7+
test: build
8+
ctest --test-dir ./build

0 commit comments

Comments
 (0)