From: Claudio Jeker Subject: gcc15: dial down the erros and c-std a bit To: ports@openbsd.org Date: Wed, 5 Nov 2025 16:03:54 +0100 gcc15 is very bleading edge, it is ahead of base clang when it comes to support C23 and that just breaks too much. This diff reduces the pain by switching back to C17 by default and turning -Wimplicit-function-declaration and -Wincompatible-pointer-types back into simple warnings. There is still an open issue with -Wimplicit-int and the fact that some old configure script like to compile 'main() { return 0; }' as minimal C program. Right now I want to see how far we get with gcc15 as ports-gcc and the above fixes. I added a hack to devel/smpeg to workaround that since it is a dependency for some 20+ ports. -- :wq Claudio Index: Makefile =================================================================== RCS file: /cvs/ports/lang/gcc/15/Makefile,v diff -u -p -r1.7 Makefile --- Makefile 15 Sep 2025 00:54:20 -0000 1.7 +++ Makefile 3 Nov 2025 20:00:16 -0000 @@ -16,7 +16,7 @@ V = 15.2.0 FULL_VERSION = $V FULL_PKGVERSION = $V -REVISION = 0 +REVISION = 1 ADASTRAP-amd64 = adastrap-amd64-11.2.0-5.tar.xz ADASTRAP-arm = adastrap-arm-4.9.4-0.tar.xz Index: patches/patch-gcc_c-family_c-opts_cc =================================================================== RCS file: patches/patch-gcc_c-family_c-opts_cc diff -N patches/patch-gcc_c-family_c-opts_cc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-gcc_c-family_c-opts_cc 3 Nov 2025 19:56:50 -0000 @@ -0,0 +1,16 @@ +Default to c17 like clang. + +Index: gcc/c-family/c-opts.cc +--- gcc/c-family/c-opts.cc.orig ++++ gcc/c-family/c-opts.cc +@@ -261,8 +261,8 @@ c_common_init_options (unsigned int decoded_options_co + + if (c_language == clk_c) + { +- /* The default for C is gnu23. */ +- set_std_c23 (false /* ISO */); ++ /* The default for C is gnu17. */ ++ set_std_c17 (false /* ISO */); + + /* If preprocessing assembly language, accept any of the C-family + front end options since the driver may pass them through. */ Index: patches/patch-gcc_c_c-decl_cc =================================================================== RCS file: /cvs/ports/lang/gcc/15/patches/patch-gcc_c_c-decl_cc,v diff -u -p -r1.1.1.1 patch-gcc_c_c-decl_cc --- patches/patch-gcc_c_c-decl_cc 18 Aug 2025 19:49:22 -0000 1.1.1.1 +++ patches/patch-gcc_c_c-decl_cc 4 Nov 2025 20:11:31 -0000 @@ -1,6 +1,24 @@ +Revert turning -Wimplicit-function-declaration into a permerror + Index: gcc/c/c-decl.cc --- gcc/c/c-decl.cc.orig +++ gcc/c/c-decl.cc +@@ -3585,13 +3585,13 @@ implicit_decl_permerror (location_t loc, tree id, tree + { + gcc_rich_location richloc (loc); + richloc.add_fixit_replace (suggestion); +- warned = permerror_opt (&richloc, OPT_Wimplicit_function_declaration, ++ warned = pedwarn (&richloc, OPT_Wimplicit_function_declaration, + "implicit declaration of function %qE;" + " did you mean %qs?", + id, suggestion); + } + else +- warned = permerror_opt (loc, OPT_Wimplicit_function_declaration, ++ warned = pedwarn (loc, OPT_Wimplicit_function_declaration, + "implicit declaration of function %qE", id); + } + else if (const char *suggestion = hint.suggestion ()) @@ -6719,6 +6719,8 @@ warn_variable_length_array (tree name, tree size) pedwarn_c90 (input_location, OPT_Wvla, "ISO C90 forbids variable " "length array"); Index: patches/patch-gcc_c_c-typeck_cc =================================================================== RCS file: patches/patch-gcc_c_c-typeck_cc diff -N patches/patch-gcc_c_c-typeck_cc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-gcc_c_c-typeck_cc 4 Nov 2025 13:35:28 -0000 @@ -0,0 +1,63 @@ +Make -Wincompatible-pointer-types just a warning. Reverting part of +https://gcc.gnu.org/cgit/gcc/commit/?id=9715c545d33b3a32ddc1ae817ba9356ade1fb9df + +Index: gcc/c/c-typeck.cc +--- gcc/c/c-typeck.cc.orig ++++ gcc/c/c-typeck.cc +@@ -8573,7 +8573,7 @@ convert_for_assignment (location_t location, location_ + gcc_rich_location richloc (expr_loc, &rhs_label, + highlight_colors::actual); + warned +- = permerror_opt (&richloc, OPT_Wincompatible_pointer_types, ++ = pedwarn (&richloc, OPT_Wincompatible_pointer_types, + "passing argument %d of %qE from " + "incompatible pointer type", + parmnum, rname); +@@ -8584,13 +8584,13 @@ convert_for_assignment (location_t location, location_ + case ic_assign: + if (bltin) + warned +- = permerror_opt (location, OPT_Wincompatible_pointer_types, ++ = pedwarn (location, OPT_Wincompatible_pointer_types, + "assignment to %e from pointer to " + "%qD with incompatible type %e", + &e_type, bltin, &e_rhstype); + else + warned +- = permerror_opt (location, OPT_Wincompatible_pointer_types, ++ = pedwarn (location, OPT_Wincompatible_pointer_types, + "assignment to %e from incompatible " + "pointer type %e", + &e_type, &e_rhstype); +@@ -8599,13 +8599,13 @@ convert_for_assignment (location_t location, location_ + case ic_init_const: + if (bltin) + warned +- = permerror_init (location, OPT_Wincompatible_pointer_types, ++ = pedwarn_init (location, OPT_Wincompatible_pointer_types, + "initialization of %e from pointer to " + "%qD with incompatible type %e", + &e_type, bltin, &e_rhstype); + else + warned +- = permerror_init (location, OPT_Wincompatible_pointer_types, ++ = pedwarn_init (location, OPT_Wincompatible_pointer_types, + "initialization of %e from incompatible " + "pointer type %e", + &e_type, &e_rhstype); +@@ -8613,13 +8613,13 @@ convert_for_assignment (location_t location, location_ + case ic_return: + if (bltin) + warned +- = permerror_opt (location, OPT_Wincompatible_pointer_types, ++ = pedwarn (location, OPT_Wincompatible_pointer_types, + "returning pointer to %qD of type %e from " + "a function with incompatible type %e", + bltin, &e_rhstype, &e_type); + else + warned +- = permerror_opt (location, OPT_Wincompatible_pointer_types, ++ = pedwarn (location, OPT_Wincompatible_pointer_types, + "returning %e from a function with " + "incompatible return type %e", + &e_rhstype, &e_type);