haskell.compiler.ghc{948,967,984,9101,9121,9122}: fix build with gcc15

- add patch from fedora (rebase of latest fix from upstream):
https://gitlab.haskell.org/ghc/ghc/-/issues/25662
https://gitlab.haskell.org/ghc/ghc/-/merge_requests/13863

ghc versions excluded from patch:
9.10.2 - has previous fix with `extern void* malloc(size_t);`
9.10.3 - has latest fix with `#include <stdlib.h>`
9.12.3 - has latest fix with `#include <stdlib.h>`

Fixes build failure with gcc15, building utils/hp2ps/Utilities.c:
```
utils/hp2ps/Utilities.c:6:14: error:
warning: conflicting types for built-in function ‘malloc’;
expected ‘void *(long unsigned int)’ [-Wbuiltin-declaration-mismatch]
        6 | extern void* malloc();
          |              ^~~~~~
...
utils/hp2ps/Utilities.c:92:18: error:
warning: conflicting types for built-in function ‘realloc’;
expected ‘void *(void *, long unsigned int)’ [-Wbuiltin-declaration-mismatch]
       92 |     extern void *realloc();
          |                  ^~~~~~~
```
This commit is contained in:
ghpzin
2025-09-30 19:16:07 +02:00
committed by sternenseemann
parent 10a4dec731
commit 02746ead92
2 changed files with 27 additions and 0 deletions
@@ -261,6 +261,22 @@
hash = "sha256-L3FQvcm9QB59BOiR2g5/HACAufIG08HiT53EIOjj64g=";
})
]
# Fix build with gcc15
# https://gitlab.haskell.org/ghc/ghc/-/issues/25662
# https://gitlab.haskell.org/ghc/ghc/-/merge_requests/13863
++
lib.optionals
(
lib.versionOlder version "9.12.3"
&& !(lib.versionAtLeast version "9.10.2" && lib.versionOlder version "9.12")
)
[
(fetchpatch {
name = "ghc-hp2ps-c-gnu17.patch";
url = "https://src.fedoraproject.org/rpms/ghc/raw/9c26d7c3c3de73509a25806e5663b37bcf2e0b4e/f/hp2ps-C-gnu17.patch";
hash = "sha256-Vr5wkiSE1S5e+cJ8pWUvG9KFpxtmvQ8wAy08ElGNp5E=";
})
]
# Fixes stack overrun in rts which crashes an process whenever
# freeHaskellFunPtr is called with nixpkgs' hardening flags.
# https://gitlab.haskell.org/ghc/ghc/-/issues/25485
@@ -345,6 +345,17 @@ stdenv.mkDerivation (
})
]
# Fix build with gcc15
# https://gitlab.haskell.org/ghc/ghc/-/issues/25662
# https://gitlab.haskell.org/ghc/ghc/-/merge_requests/13863
++ lib.optionals (lib.versions.majorMinor version == "9.4") [
(fetchpatch {
name = "ghc-hp2ps-c-gnu17.patch";
url = "https://src.fedoraproject.org/rpms/ghc/raw/9c26d7c3c3de73509a25806e5663b37bcf2e0b4e/f/hp2ps-C-gnu17.patch";
hash = "sha256-Vr5wkiSE1S5e+cJ8pWUvG9KFpxtmvQ8wAy08ElGNp5E=";
})
]
++ [
# Don't generate code that doesn't compile when --enable-relocatable is passed to Setup.hs
# Can be removed if the Cabal library included with ghc backports the linked fix