Skip to content

Commit 43ff75c

Browse files
haskell.compiler: backport patch for unix 32bit type size issue
Cabal has recently introduced a lower bound for unix so a certain bug fix for 32bit platforms (in combination with a toolchain that sets _FILE_OFFSET_BITS=64) is included: haskell/cabal#10664 haskell/cabal#10677 I don't think it's actually possible to encounter this problem with nixpkgs since we haven't transitioned to 64bit time_t for 32bit platforms unlike Debian. To prevent confusing behavior in edge cases, backport the patch to all GHC versions that lack it and lift the bound on Cabal 3.14 (which is honestly a strange way to “fix” this problem).
1 parent 8f47155 commit 43ff75c

File tree

4 files changed

+58
-3
lines changed

4 files changed

+58
-3
lines changed

pkgs/development/compilers/ghc/8.10.7.nix

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,20 @@ stdenv.mkDerivation (
296296
sha256 = "0kmhfamr16w8gch0lgln2912r8aryjky1hfcda3jkcwa5cdzgjdv";
297297
})
298298

299+
# Determine size of time related types using hsc2hs instead of assuming CLong.
300+
# Prevents failures when e.g. stat(2)ing on 32bit systems with 64bit time_t etc.
301+
# https://github.com/haskell/ghcup-hs/issues/1107
302+
# https://gitlab.haskell.org/ghc/ghc/-/issues/25095
303+
# Note that in normal situations this shouldn't be the case since nixpkgs
304+
# doesn't set -D_FILE_OFFSET_BITS=64 and friends (yet).
305+
(fetchpatch {
306+
name = "unix-fix-ctimeval-size-32-bit.patch";
307+
url = "https://github.com/haskell/unix/commit/8183e05b97ce870dd6582a3677cc82459ae566ec.patch";
308+
sha256 = "17q5yyigqr5kxlwwzb95sx567ysfxlw6bp3j4ji20lz0947aw6gv";
309+
stripLen = 1;
310+
extraPrefix = "libraries/unix/";
311+
})
312+
299313
# See upstream patch at
300314
# https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4885. Since we build
301315
# from source distributions, the auto-generated configure script needs to be

pkgs/development/compilers/ghc/common-hadrian.nix

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,26 @@
182182
then ./docs-sphinx-7-ghc98.patch
183183
else ./docs-sphinx-7.patch )
184184
]
185+
186+
++ lib.optional (
187+
# 2025-01-16: unix >= 2.8.6.0 is unaffected which is shipped by GHC 9.12.1 and 9.8.4
188+
lib.versionOlder version "9.11"
189+
&& !(lib.versionAtLeast version "9.8.4" && lib.versionOlder version "9.9")
190+
) [
191+
# Determine size of time related types using hsc2hs instead of assuming CLong.
192+
# Prevents failures when e.g. stat(2)ing on 32bit systems with 64bit time_t etc.
193+
# https://github.com/haskell/ghcup-hs/issues/1107
194+
# https://gitlab.haskell.org/ghc/ghc/-/issues/25095
195+
# Note that in normal situations this shouldn't be the case since nixpkgs
196+
# doesn't set -D_FILE_OFFSET_BITS=64 and friends (yet).
197+
(fetchpatch {
198+
name = "unix-fix-ctimeval-size-32-bit.patch";
199+
url = "https://github.com/haskell/unix/commit/8183e05b97ce870dd6582a3677cc82459ae566ec.patch";
200+
sha256 = "17q5yyigqr5kxlwwzb95sx567ysfxlw6bp3j4ji20lz0947aw6gv";
201+
stripLen = 1;
202+
extraPrefix = "libraries/unix/";
203+
})
204+
]
185205
++ lib.optionals (lib.versionAtLeast version "9.6" && lib.versionOlder version "9.6.6") [
186206
(fetchpatch {
187207
name = "fix-fully_static.patch";

pkgs/development/compilers/ghc/common-make-native-bignum.nix

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,22 @@ stdenv.mkDerivation (
288288
];
289289

290290
patches =
291-
lib.optionals (lib.versionOlder version "9.4") [
291+
[
292+
# Determine size of time related types using hsc2hs instead of assuming CLong.
293+
# Prevents failures when e.g. stat(2)ing on 32bit systems with 64bit time_t etc.
294+
# https://github.com/haskell/ghcup-hs/issues/1107
295+
# https://gitlab.haskell.org/ghc/ghc/-/issues/25095
296+
# Note that in normal situations this shouldn't be the case since nixpkgs
297+
# doesn't set -D_FILE_OFFSET_BITS=64 and friends (yet).
298+
(fetchpatch {
299+
name = "unix-fix-ctimeval-size-32-bit.patch";
300+
url = "https://github.com/haskell/unix/commit/8183e05b97ce870dd6582a3677cc82459ae566ec.patch";
301+
sha256 = "17q5yyigqr5kxlwwzb95sx567ysfxlw6bp3j4ji20lz0947aw6gv";
302+
stripLen = 1;
303+
extraPrefix = "libraries/unix/";
304+
})
305+
]
306+
++ lib.optionals (lib.versionOlder version "9.4") [
292307
# fix hyperlinked haddock sources: https://github.com/haskell/haddock/pull/1482
293308
(fetchpatch {
294309
url = "https://patch-diff.githubusercontent.com/raw/haskell/haddock/pull/1482.patch";

pkgs/development/haskell-modules/configuration-common.nix

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,15 @@ self: super: {
2929
Cabal_3_12_1_0 = doDistribute (super.Cabal_3_12_1_0.override {
3030
Cabal-syntax = self.Cabal-syntax_3_12_1_0;
3131
});
32-
Cabal_3_14_1_1 = doDistribute (super.Cabal_3_14_1_1.override {
32+
Cabal_3_14_1_1 = overrideCabal (drv: {
33+
# Revert increased lower bound on unix since we have backported
34+
# the required patch to all GHC bundled versions of unix.
35+
postPatch = drv.postPatch or "" + ''
36+
substituteInPlace Cabal.cabal --replace-fail "unix >= 2.8.6.0" "unix >= 2.6.0.0"
37+
'';
38+
}) (doDistribute (super.Cabal_3_14_1_1.override {
3339
Cabal-syntax = self.Cabal-syntax_3_14_1_0;
34-
});
40+
}));
3541

3642
# cabal-install needs most recent versions of Cabal and Cabal-syntax,
3743
# so we need to put some extra work for non-latest GHCs

0 commit comments

Comments
 (0)