crossgcc/buildgcc: Fix GMP-6.3.0 build with GCC 15 using proper prototypes

The old test code used outdated function declarations that break with
C23 in GCC 15. Instead of forcing C17 standard:

1. Add full prototype for g() function
2. Use 'void' for empty parameters
3. Clean up messy formatting

This keeps C23 compatibility while fixing the build.

Tested with GCC 15.1.0

The -std=gnu17 workaround is no longer needed.

Change-Id: I718a5ed5c11742b1c3448abf7198c96ac78bc98a
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/87995
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Martin L Roth <gaumless@gmail.com>
This commit is contained in:
Elyes Haouas 2025-06-07 08:49:39 +02:00
commit f9cde87f5a
2 changed files with 101 additions and 3 deletions

View file

@ -662,9 +662,7 @@ build_GMP() {
fi
# shellcheck disable=SC2086
# Bug: GMP currently does not support being build by GCC 15 (--std=gnu23)
# Remove CFLAGS once it works again.
CC="$(hostcc host)" CXX="$(hostcxx host)" CFLAGS="-std=gnu17" \
CC="$(hostcc host)" CXX="$(hostcxx host)" \
../${GMP_DIR}/configure \
--disable-shared \
--enable-fat \

View file

@ -0,0 +1,100 @@
Resolves compilation errors with GCC 15+ in C23 mode by:
. Adding explicit function prototypes for `g()`
. Modernizing K&R-style function declarations
. Fixing void parameter signatures
--- gmp-6.3.0/configure
+++ gmp-6.3.0/configure
@@ -6567,13 +6567,39 @@
1666 to segfault with e.g., -O2 -mpowerpc64. */
#if defined (__GNUC__) && ! defined (__cplusplus)
-typedef unsigned long long t1;typedef t1*t2;
-void g(){}
-void h(){}
-static __inline__ t1 e(t2 rp,t2 up,int n,t1 v0)
-{t1 c,x,r;int i;if(v0){c=1;for(i=1;i<n;i++){x=up[i];r=x+1;rp[i]=r;}}return c;}
-void f(){static const struct{t1 n;t1 src[9];t1 want[9];}d[]={{1,{0},{1}},};t1 got[9];int i;
-for(i=0;i<1;i++){if(e(got,got,9,d[i].n)==0)h();g(i,d[i].src,d[i].n,got,d[i].want,9);if(d[i].n)h();}}
+typedef unsigned long long t1;
+typedef t1 *t2;
+void g(void) { }
+void h(void) { }
+static __inline__ t1 e(t2 rp, t2 up, int n, t1 v0)
+{
+ t1 c, x, r;
+ int i;
+ if (v0) {
+ c = 1;
+ for (i = 1; i < n; i++) {
+ x = up[i];
+ r = x + 1;
+ rp[i] = r;
+ }
+ }
+ return c;
+}
+void f(void)
+{
+ static const struct { t1 n; t1 src[9]; t1 want[9]; } d[] = {
+ { 1, { 0 }, { 1 } },
+ };
+ t1 got[9];
+ int i;
+ for (i = 0; i < 1; i++) {
+ if (e(got, got, 9, d[i].n) == 0)
+ h();
+ g();
+ if (d[i].n)
+ h();
+ }
+}
#else
int dummy;
#endif
@@ -8186,13 +8212,39 @@
1666 to segfault with e.g., -O2 -mpowerpc64. */
#if defined (__GNUC__) && ! defined (__cplusplus)
-typedef unsigned long long t1;typedef t1*t2;
-void g(){}
-void h(){}
-static __inline__ t1 e(t2 rp,t2 up,int n,t1 v0)
-{t1 c,x,r;int i;if(v0){c=1;for(i=1;i<n;i++){x=up[i];r=x+1;rp[i]=r;}}return c;}
-void f(){static const struct{t1 n;t1 src[9];t1 want[9];}d[]={{1,{0},{1}},};t1 got[9];int i;
-for(i=0;i<1;i++){if(e(got,got,9,d[i].n)==0)h();g(i,d[i].src,d[i].n,got,d[i].want,9);if(d[i].n)h();}}
+typedef unsigned long long t1;
+typedef t1 *t2;
+void g(void) { }
+void h(void) { }
+static __inline__ t1 e(t2 rp, t2 up, int n, t1 v0)
+{
+ t1 c, x, r;
+ int i;
+ if (v0) {
+ c = 1;
+ for (i = 1; i < n; i++) {
+ x = up[i];
+ r = x + 1;
+ rp[i] = r;
+ }
+ }
+ return c;
+}
+void f(void)
+{
+ static const struct { t1 n; t1 src[9]; t1 want[9]; } d[] = {
+ { 1, { 0 }, { 1 } },
+ };
+ t1 got[9];
+ int i;
+ for (i = 0; i < 1; i++) {
+ if (e(got, got, 9, d[i].n) == 0)
+ h();
+ g();
+ if (d[i].n)
+ h();
+ }
+}
#else
int dummy;
#endif