From 02746ead92b6d56d02fb22efacd59402d1a95878 Mon Sep 17 00:00:00 2001 From: ghpzin Date: Tue, 16 Sep 2025 17:45:30 +0300 Subject: [PATCH] haskell.compiler.ghc{948,967,984,9101,9121,9122}: fix build with gcc15 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 ` 9.12.3 - has latest fix with `#include ` 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(); | ^~~~~~~ ``` --- .../development/compilers/ghc/common-hadrian.nix | 16 ++++++++++++++++ .../compilers/ghc/common-make-native-bignum.nix | 11 +++++++++++ 2 files changed, 27 insertions(+) diff --git a/pkgs/development/compilers/ghc/common-hadrian.nix b/pkgs/development/compilers/ghc/common-hadrian.nix index b8064fd4ee79..9d2c4afef217 100644 --- a/pkgs/development/compilers/ghc/common-hadrian.nix +++ b/pkgs/development/compilers/ghc/common-hadrian.nix @@ -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 diff --git a/pkgs/development/compilers/ghc/common-make-native-bignum.nix b/pkgs/development/compilers/ghc/common-make-native-bignum.nix index 922875e6b4e1..cf9bd6e7e530 100644 --- a/pkgs/development/compilers/ghc/common-make-native-bignum.nix +++ b/pkgs/development/compilers/ghc/common-make-native-bignum.nix @@ -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