commit:     c12877706de776b01a12d40c0d03d310792078f5
Author:     Yiyang Wu <xgreenlandforwyy <AT> gmail <DOT> com>
AuthorDate: Fri May  2 13:20:15 2025 +0000
Commit:     Mark Wright <gienah <AT> gentoo <DOT> org>
CommitDate: Wed May 21 06:12:16 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c1287770

dev-lang/ghc: use stdlib malloc and realloc to gcc-15 compile error

Closes: https://bugs.gentoo.org/946695
Closes: https://github.com/gentoo/gentoo/pull/41899
Signed-off-by: Yiyang Wu <xgreenlandforwyy <AT> gmail.com>
Signed-off-by: Mark Wright <gienah <AT> gentoo.org>

 dev-lang/ghc/files/ghc-9.2.8-use-stdlib.patch | 25 +++++++++++++++++++++++++
 dev-lang/ghc/ghc-9.2.8.ebuild                 |  6 +++++-
 2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/dev-lang/ghc/files/ghc-9.2.8-use-stdlib.patch 
b/dev-lang/ghc/files/ghc-9.2.8-use-stdlib.patch
new file mode 100644
index 000000000000..424f0a5b9196
--- /dev/null
+++ b/dev-lang/ghc/files/ghc-9.2.8-use-stdlib.patch
@@ -0,0 +1,25 @@
+Use stdlib's malloc and realloc instead of extern to avoid conflict
+Reference: 
https://src.fedoraproject.org/rpms/ghc9.12/blob/12ecf74c5a603b552da365829135e5b62e252db1/f/hp2ps-C-gnu17.patch
+===================================================================
+--- ghc-9.2.8.orig/utils/hp2ps/Utilities.c
++++ ghc-9.2.8/utils/hp2ps/Utilities.c
+@@ -1,10 +1,9 @@
+ #include "Main.h"
+ #include <stdio.h>
+ #include <string.h>
++#include <stdlib.h>
+ #include "Error.h"
+ 
+-extern void* malloc();
+-
+ char*
+ Basename(char *name)
+ {
+@@ -89,7 +88,6 @@ void *
+ xrealloc(void *p, size_t n)
+ {
+     void *r;
+-    extern void *realloc();
+ 
+     r = realloc(p, n);
+     if (!r) {

diff --git a/dev-lang/ghc/ghc-9.2.8.ebuild b/dev-lang/ghc/ghc-9.2.8.ebuild
index eee40e3d3e0b..f07bb98c69b4 100644
--- a/dev-lang/ghc/ghc-9.2.8.ebuild
+++ b/dev-lang/ghc/ghc-9.2.8.ebuild
@@ -1,4 +1,4 @@
-# Copyright 1999-2024 Gentoo Authors
+# Copyright 1999-2025 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=7
@@ -701,6 +701,10 @@ src_prepare() {
                        eapply 
"${FILESDIR}"/${PN}-8.2.1_rc1-win32-cross-2-hack.patch # bad workaround
                popd
 
+               # https://bugs.gentoo.org/946695
+               # Fix for gnu17 (gcc-15)
+               eapply "${FILESDIR}/${PN}-9.2.8-use-stdlib.patch"
+
                bump_libs
 
                eapply_user

Reply via email to