From f9cde87f5a4fbe5081304444261fa0e706429da3 Mon Sep 17 00:00:00 2001 From: Elyes Haouas Date: Sat, 7 Jun 2025 08:49:39 +0200 Subject: [PATCH] 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 Reviewed-on: https://review.coreboot.org/c/coreboot/+/87995 Tested-by: build bot (Jenkins) Reviewed-by: Martin L Roth --- util/crossgcc/buildgcc | 4 +- .../gmp-6.3.0_fix-c23-prototypes.patch | 100 ++++++++++++++++++ 2 files changed, 101 insertions(+), 3 deletions(-) create mode 100644 util/crossgcc/patches/gmp-6.3.0_fix-c23-prototypes.patch diff --git a/util/crossgcc/buildgcc b/util/crossgcc/buildgcc index 3d570e009c..66fdf91c07 100755 --- a/util/crossgcc/buildgcc +++ b/util/crossgcc/buildgcc @@ -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 \ diff --git a/util/crossgcc/patches/gmp-6.3.0_fix-c23-prototypes.patch b/util/crossgcc/patches/gmp-6.3.0_fix-c23-prototypes.patch new file mode 100644 index 0000000000..4d8105bcfb --- /dev/null +++ b/util/crossgcc/patches/gmp-6.3.0_fix-c23-prototypes.patch @@ -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