From 9410b27f55d6fa20120e2ea0b7945d0cb29fccf2 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Wed, 19 Oct 2022 11:40:52 +0200 Subject: [PATCH 01/21] Log implicit int/function declaration errors to /var/log/gcc-errors --- gcc.spec | 10 ++- gcc12-c99-fixes-1.patch | 62 ++++++++++++++++++ gcc12-c99-fixes-2.patch | 139 ++++++++++++++++++++++++++++++++++++++++ gcc12-implicits.patch | 118 ++++++++++++++++++++++++++++++++++ 4 files changed, 328 insertions(+), 1 deletion(-) create mode 100644 gcc12-c99-fixes-1.patch create mode 100644 gcc12-c99-fixes-2.patch create mode 100644 gcc12-implicits.patch diff --git a/gcc.spec b/gcc.spec index a9f8755..7107278 100644 --- a/gcc.spec +++ b/gcc.spec @@ -4,7 +4,7 @@ %global gcc_major 12 # Note, gcc_release must be integer, if you want to add suffixes to # %%{release}, append them after %%{gcc_release} on Release: line. -%global gcc_release 2 +%global gcc_release 2.implicits.1 %global nvptx_tools_gitrev 5f6f343a302d620b0868edab376c00b15741e39e %global newlib_cygwin_gitrev 50e2a63b04bdd018484605fbb954fd1bd5147fa0 %global _unpackaged_files_terminate_build 0 @@ -283,6 +283,10 @@ Patch101: gcc12-fortran-flogical-as-integer.patch Patch102: gcc12-fortran-fdec-override-kind.patch Patch103: gcc12-fortran-fdec-non-logical-if.patch +Patch990: gcc12-implicits.patch +Patch991: gcc12-c99-fixes-1.patch +Patch992: gcc12-c99-fixes-2.patch + # On ARM EABI systems, we do want -gnueabi to be part of the # target triple. %ifnarch %{arm} @@ -814,6 +818,10 @@ so that there cannot be any synchronization problems. %patch103 -p1 -b .fortran-fdec-non-logical-if~ %endif +%patch990 -p1 -b .implicits +%patch991 -p1 -b .c99-fixes-1 +%patch992 -p1 -b .c99-fixes-2 + %ifarch %{arm} rm -f gcc/testsuite/go.test/test/fixedbugs/issue19182.go %endif diff --git a/gcc12-c99-fixes-1.patch b/gcc12-c99-fixes-1.patch new file mode 100644 index 0000000..b14a168 --- /dev/null +++ b/gcc12-c99-fixes-1.patch @@ -0,0 +1,62 @@ +Submitted upstream as: + +commit 6be2672e4ee41c566a9e072088cccca263bab5f7 +Author: Florian Weimer +Date: Tue Oct 18 16:58:48 2022 +0200 + + libsanitizer: Avoid implicit function declaration in configure test + + libsanitizer/ + + * configure.ac (sanitizer_supported): Include for + syscall prototype. + * configure: Regenerate. + + +diff --git a/libsanitizer/configure b/libsanitizer/configure +index 771b135573a..6ef90d80eec 100755 +--- a/libsanitizer/configure ++++ b/libsanitizer/configure +@@ -12359,7 +12359,7 @@ else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<_LT_EOF +-#line 12362 "configure" ++#line 12374 "configure" + #include "confdefs.h" + + #if HAVE_DLFCN_H +@@ -12465,7 +12465,7 @@ else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<_LT_EOF +-#line 12468 "configure" ++#line 12480 "configure" + #include "confdefs.h" + + #if HAVE_DLFCN_H +@@ -16028,6 +16028,7 @@ case "$target" in + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + #include ++#include + int + main () + { +diff --git a/libsanitizer/configure.ac b/libsanitizer/configure.ac +index 7f1ef3979c4..ad49f29db7e 100644 +--- a/libsanitizer/configure.ac ++++ b/libsanitizer/configure.ac +@@ -161,7 +161,8 @@ case "$target" in + *-*-linux*) + # Some old Linux distributions miss required syscalls. + sanitizer_supported=no +- AC_TRY_COMPILE([#include ],[ ++ AC_TRY_COMPILE([#include ++#include ],[ + syscall (__NR_gettid); + syscall (__NR_futex); + syscall (__NR_exit_group); +-- +2.37.3 + diff --git a/gcc12-c99-fixes-2.patch b/gcc12-c99-fixes-2.patch new file mode 100644 index 0000000..adaa368 --- /dev/null +++ b/gcc12-c99-fixes-2.patch @@ -0,0 +1,139 @@ +Submitted upstream as: + +commit 885b6660c17fb91980b5682514ef54668e544b02 +Author: Florian Weimer +Date: Tue Oct 18 16:58:48 2022 +0200 + + libiberty: Fix C89-isms in configure tests + + libiberty/ + + * acinclude.m4 (ac_cv_func_strncmp_works): Add missing + int return type and parameter list to the definition of main. + Include and for prototypes. + (ac_cv_c_stack_direction): Add missing + int return type and parameter list to the definitions of + main, find_stack_direction. Include for exit + prototype. + * configure: Regenerate. + + +diff --git a/libiberty/acinclude.m4 b/libiberty/acinclude.m4 +index 6bd127e9826..6e23ae906fc 100644 +--- a/libiberty/acinclude.m4 ++++ b/libiberty/acinclude.m4 +@@ -24,6 +24,7 @@ AC_CACHE_CHECK([for working strncmp], ac_cv_func_strncmp_works, + [AC_TRY_RUN([ + /* Test by Jim Wilson and Kaveh Ghazi. + Check whether strncmp reads past the end of its string parameters. */ ++#include + #include + + #ifdef HAVE_FCNTL_H +@@ -51,7 +52,8 @@ AC_CACHE_CHECK([for working strncmp], ac_cv_func_strncmp_works, + + #define MAP_LEN 0x10000 + +-main () ++int ++main (void) + { + #if defined(HAVE_MMAP) || defined(HAVE_MMAP_ANYWHERE) + char *p; +@@ -59,7 +61,7 @@ main () + + dev_zero = open ("/dev/zero", O_RDONLY); + if (dev_zero < 0) +- exit (1); ++ return 1; + + p = (char *) mmap (0, MAP_LEN, PROT_READ|PROT_WRITE, + MAP_ANON|MAP_PRIVATE, dev_zero, 0); +@@ -67,7 +69,7 @@ main () + p = (char *) mmap (0, MAP_LEN, PROT_READ|PROT_WRITE, + MAP_ANON|MAP_PRIVATE, -1, 0); + if (p == (char *)-1) +- exit (2); ++ return 2; + else + { + char *string = "__si_type_info"; +@@ -79,7 +81,7 @@ main () + strncmp (r, q, 14); + } + #endif /* HAVE_MMAP || HAVE_MMAP_ANYWHERE */ +- exit (0); ++ return 0; + } + ], ac_cv_func_strncmp_works=yes, ac_cv_func_strncmp_works=no, + ac_cv_func_strncmp_works=yes) +@@ -171,7 +173,7 @@ AC_CACHE_CHECK(stack direction for C alloca, ac_cv_c_stack_direction, + } + main () + { +- exit (find_stack_direction() < 0); ++ return find_stack_direction() < 0; + }], + ac_cv_c_stack_direction=1, + ac_cv_c_stack_direction=-1, +diff --git a/libiberty/configure b/libiberty/configure +index 0a797255c70..fba4e7b307d 100755 +--- a/libiberty/configure ++++ b/libiberty/configure +@@ -6794,7 +6794,7 @@ find_stack_direction () + } + main () + { +- exit (find_stack_direction() < 0); ++ return find_stack_direction() < 0; + } + _ACEOF + if ac_fn_c_try_run "$LINENO"; then : +@@ -7617,6 +7617,7 @@ else + + /* Test by Jim Wilson and Kaveh Ghazi. + Check whether strncmp reads past the end of its string parameters. */ ++#include + #include + + #ifdef HAVE_FCNTL_H +@@ -7644,7 +7645,8 @@ else + + #define MAP_LEN 0x10000 + +-main () ++int ++main (void) + { + #if defined(HAVE_MMAP) || defined(HAVE_MMAP_ANYWHERE) + char *p; +@@ -7652,7 +7654,7 @@ main () + + dev_zero = open ("/dev/zero", O_RDONLY); + if (dev_zero < 0) +- exit (1); ++ return 1; + + p = (char *) mmap (0, MAP_LEN, PROT_READ|PROT_WRITE, + MAP_ANON|MAP_PRIVATE, dev_zero, 0); +@@ -7660,7 +7662,7 @@ main () + p = (char *) mmap (0, MAP_LEN, PROT_READ|PROT_WRITE, + MAP_ANON|MAP_PRIVATE, -1, 0); + if (p == (char *)-1) +- exit (2); ++ return 2; + else + { + char *string = "__si_type_info"; +@@ -7672,7 +7674,7 @@ main () + strncmp (r, q, 14); + } + #endif /* HAVE_MMAP || HAVE_MMAP_ANYWHERE */ +- exit (0); ++ return 0; + } + + _ACEOF +-- +2.37.3 + diff --git a/gcc12-implicits.patch b/gcc12-implicits.patch new file mode 100644 index 0000000..045f691 --- /dev/null +++ b/gcc12-implicits.patch @@ -0,0 +1,118 @@ +Log implicit ints/implicit function declarations to /var/log/gcc-errors + +Only do so for C99 and later language modes. Both features were part +of C89. + +A corresponding change to redhat-rpm-config reads /var/log/gcc-errors +and may fail the build if critical errors have been logged. + +diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc +index c701f07befe..2010621ab78 100644 +--- a/gcc/c/c-decl.cc ++++ b/gcc/c/c-decl.cc +@@ -3368,6 +3368,14 @@ pushdecl (tree x) + static void + implicit_decl_warning (location_t loc, tree id, tree olddecl) + { ++ if (flag_isoc99) ++ { ++ log_error_to_directory (loc, "implicit function declaration", ++ IDENTIFIER_POINTER (id)); ++ error_at (loc, "implicit declaration of function %qE", id); ++ return; ++ } ++ + if (!warn_implicit_function_declaration) + return; + +@@ -6402,7 +6410,15 @@ grokdeclarator (const struct c_declarator *declarator, + + /* Diagnose defaulting to "int". */ + +- if (declspecs->default_int_p && !in_system_header_at (input_location)) ++ if (declspecs->default_int_p && flag_isoc99) ++ { ++ log_error_to_directory (loc, "defaulting to int"); ++ if (name) ++ error_at (loc, "type defaults to % in declaration of %qE", name); ++ else ++ error_at (loc, "type defaults to % in type name"); ++ } ++ else if (declspecs->default_int_p && !in_system_header_at (input_location)) + { + /* Issue a warning if this is an ISO C 99 program or if + -Wreturn-type and this is a function, or if -Wimplicit; +@@ -9887,9 +9903,12 @@ store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info) + warn_if_shadowing (decl); + + if (flag_isoc99) +- pedwarn (DECL_SOURCE_LOCATION (decl), +- OPT_Wimplicit_int, "type of %qD defaults to %", +- decl); ++ { ++ log_error_to_directory (DECL_SOURCE_LOCATION (decl), ++ "type defaults to int"); ++ error_at (DECL_SOURCE_LOCATION (decl), ++ "type of %qD defaults to %", decl); ++ } + else + warning_at (DECL_SOURCE_LOCATION (decl), + OPT_Wmissing_parameter_type, +diff --git a/gcc/diagnostic.cc b/gcc/diagnostic.cc +index 73324a728fe..5ec5ba6d60e 100644 +--- a/gcc/diagnostic.cc ++++ b/gcc/diagnostic.cc +@@ -2492,3 +2492,38 @@ c_diagnostic_cc_tests () + #if __GNUC__ >= 10 + # pragma GCC diagnostic pop + #endif ++ ++/* Magic code to emit diagnostics to a log directory. */ ++void ++log_error_to_directory (location_t loc, const char *message, ++ const char *identifier) ++{ ++ static const char magic_path[] = "/var/log/gcc-errors"; ++ ++ // Do not log anything if the directory does not exist. ++ if (access (magic_path, R_OK | W_OK | X_OK) < 0) ++ return; ++ ++ char *templ = xasprintf ("%s/gccXXXXXX", magic_path); ++ int fd = mkstemp (templ); ++ if (fd < 0) ++ abort(); ++ ++ auto exploc = expand_location (loc); ++ const char *file = exploc.file; ++ if (file == nullptr) ++ file = ""; ++ char *formatted; ++ if (identifier != nullptr) ++ formatted = xasprintf ("%s:%d: %s: %s\n", ++ file, exploc.line, message, identifier); ++ else ++ formatted = xasprintf ("%s:%d: %s\n", file, exploc.line, message); ++ ssize_t len = strlen (formatted); ++ if (write (fd, formatted, len) != len ++ || close (fd) < 0) ++ abort (); ++ ++ free (formatted); ++ free (templ); ++} +diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h +index 3ca32979dde..4122a875c0b 100644 +--- a/gcc/diagnostic.h ++++ b/gcc/diagnostic.h +@@ -587,4 +587,7 @@ extern json::value *json_from_expanded_location (diagnostic_context *context, + + extern bool warning_enabled_at (location_t, int); + ++void log_error_to_directory (location_t loc, const char *message, ++ const char *identifier = nullptr); ++ + #endif /* ! GCC_DIAGNOSTIC_H */ +-- +2.37.3 + From b42210e2f0b53ac11f6aa0072b7ddbb6a4873d13 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Thu, 20 Oct 2022 16:35:19 +0200 Subject: [PATCH 02/21] Fix Release: handling (follow recommendation in spec file comment) --- gcc.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc.spec b/gcc.spec index 7107278..d5648d4 100644 --- a/gcc.spec +++ b/gcc.spec @@ -4,7 +4,7 @@ %global gcc_major 12 # Note, gcc_release must be integer, if you want to add suffixes to # %%{release}, append them after %%{gcc_release} on Release: line. -%global gcc_release 2.implicits.1 +%global gcc_release 2 %global nvptx_tools_gitrev 5f6f343a302d620b0868edab376c00b15741e39e %global newlib_cygwin_gitrev 50e2a63b04bdd018484605fbb954fd1bd5147fa0 %global _unpackaged_files_terminate_build 0 @@ -125,7 +125,7 @@ Summary: Various compilers (C, C++, Objective-C, ...) Name: gcc Version: %{gcc_version} -Release: %{gcc_release}%{?dist} +Release: %{gcc_release}.implicits.2%{?dist} # libgcc, libgfortran, libgomp, libstdc++ and crtstuff have # GCC Runtime Exception. License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD From 24eaf98e044a79cf07a785237ae008df5a1855a1 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Thu, 20 Oct 2022 16:38:43 +0200 Subject: [PATCH 03/21] Switch error log directory to /usr/lib/gcc/errors /var/log disappears during buildroot setup, so the special subdirectory is not present, and no errors are logged. --- gcc12-implicits.patch | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/gcc12-implicits.patch b/gcc12-implicits.patch index 045f691..91263f9 100644 --- a/gcc12-implicits.patch +++ b/gcc12-implicits.patch @@ -1,10 +1,15 @@ -Log implicit ints/implicit function declarations to /var/log/gcc-errors +commit 23c1e6ba35f3f0c6ea0ff825c0b5cb35cd11a160 +Author: Florian Weimer +Date: Tue Oct 18 16:28:33 2022 +0200 -Only do so for C99 and later language modes. Both features were part -of C89. - -A corresponding change to redhat-rpm-config reads /var/log/gcc-errors -and may fail the build if critical errors have been logged. + Log implicit ints/implicit function declarations to /usr/lib/gcc/errors + + Only do so for C99 and later language modes, both features were part + of C89. + + The directory and the file name prefix for files within can be + controlled using the GCC_ERROR_LOG_DIRECTORY and GCC_ERROR_LOG_PREFIX + environment variables. diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc index c701f07befe..2010621ab78 100644 @@ -59,10 +64,10 @@ index c701f07befe..2010621ab78 100644 warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wmissing_parameter_type, diff --git a/gcc/diagnostic.cc b/gcc/diagnostic.cc -index 73324a728fe..5ec5ba6d60e 100644 +index 73324a728fe..6e79903259d 100644 --- a/gcc/diagnostic.cc +++ b/gcc/diagnostic.cc -@@ -2492,3 +2492,38 @@ c_diagnostic_cc_tests () +@@ -2492,3 +2492,44 @@ c_diagnostic_cc_tests () #if __GNUC__ >= 10 # pragma GCC diagnostic pop #endif @@ -72,13 +77,19 @@ index 73324a728fe..5ec5ba6d60e 100644 +log_error_to_directory (location_t loc, const char *message, + const char *identifier) +{ -+ static const char magic_path[] = "/var/log/gcc-errors"; ++ const char *magic_path = getenv ("GCC_ERROR_LOG_DIRECTORY"); ++ if (magic_path == nullptr) ++ magic_path = "/usr/lib/gcc/errors"; + + // Do not log anything if the directory does not exist. + if (access (magic_path, R_OK | W_OK | X_OK) < 0) + return; + -+ char *templ = xasprintf ("%s/gccXXXXXX", magic_path); ++ const char *log_prefix = getenv ("GCC_ERROR_LOG_PREFIX"); ++ if (log_prefix == nullptr) ++ log_prefix = "gcc"; ++ ++ char *templ = xasprintf ("%s/%sXXXXXX", magic_path, log_prefix); + int fd = mkstemp (templ); + if (fd < 0) + abort(); @@ -113,6 +124,3 @@ index 3ca32979dde..4122a875c0b 100644 + const char *identifier = nullptr); + #endif /* ! GCC_DIAGNOSTIC_H */ --- -2.37.3 - From aa1f06c095cb36b77e70418a5b1494aff6ca33ee Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Thu, 20 Oct 2022 16:38:55 +0200 Subject: [PATCH 04/21] Re-backport C99 fixes from upstream --- gcc12-c99-fixes-1.patch | 29 +-------- gcc12-c99-fixes-2.patch | 131 ++++++++++++++++------------------------ 2 files changed, 54 insertions(+), 106 deletions(-) diff --git a/gcc12-c99-fixes-1.patch b/gcc12-c99-fixes-1.patch index b14a168..583200b 100644 --- a/gcc12-c99-fixes-1.patch +++ b/gcc12-c99-fixes-1.patch @@ -1,6 +1,3 @@ -Submitted upstream as: - -commit 6be2672e4ee41c566a9e072088cccca263bab5f7 Author: Florian Weimer Date: Tue Oct 18 16:58:48 2022 +0200 @@ -11,30 +8,13 @@ Date: Tue Oct 18 16:58:48 2022 +0200 * configure.ac (sanitizer_supported): Include for syscall prototype. * configure: Regenerate. - + + (cherry picked from commit 6be2672e4ee41c566a9e072088cccca263bab5f7) diff --git a/libsanitizer/configure b/libsanitizer/configure -index 771b135573a..6ef90d80eec 100755 +index 771b135573a..ae8c1bd7e83 100755 --- a/libsanitizer/configure +++ b/libsanitizer/configure -@@ -12359,7 +12359,7 @@ else - lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 - lt_status=$lt_dlunknown - cat > conftest.$ac_ext <<_LT_EOF --#line 12362 "configure" -+#line 12374 "configure" - #include "confdefs.h" - - #if HAVE_DLFCN_H -@@ -12465,7 +12465,7 @@ else - lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 - lt_status=$lt_dlunknown - cat > conftest.$ac_ext <<_LT_EOF --#line 12468 "configure" -+#line 12480 "configure" - #include "confdefs.h" - - #if HAVE_DLFCN_H @@ -16028,6 +16028,7 @@ case "$target" in cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -57,6 +37,3 @@ index 7f1ef3979c4..ad49f29db7e 100644 syscall (__NR_gettid); syscall (__NR_futex); syscall (__NR_exit_group); --- -2.37.3 - diff --git a/gcc12-c99-fixes-2.patch b/gcc12-c99-fixes-2.patch index adaa368..953c6ce 100644 --- a/gcc12-c99-fixes-2.patch +++ b/gcc12-c99-fixes-2.patch @@ -1,6 +1,3 @@ -Submitted upstream as: - -commit 885b6660c17fb91980b5682514ef54668e544b02 Author: Florian Weimer Date: Tue Oct 18 16:58:48 2022 +0200 @@ -16,21 +13,23 @@ Date: Tue Oct 18 16:58:48 2022 +0200 main, find_stack_direction. Include for exit prototype. * configure: Regenerate. - + + (cherry picked from commit 885b6660c17fb91980b5682514ef54668e544b02) diff --git a/libiberty/acinclude.m4 b/libiberty/acinclude.m4 -index 6bd127e9826..6e23ae906fc 100644 +index 6bd127e9826..6bb690597bf 100644 --- a/libiberty/acinclude.m4 +++ b/libiberty/acinclude.m4 -@@ -24,6 +24,7 @@ AC_CACHE_CHECK([for working strncmp], ac_cv_func_strncmp_works, +@@ -24,6 +24,8 @@ AC_CACHE_CHECK([for working strncmp], ac_cv_func_strncmp_works, [AC_TRY_RUN([ /* Test by Jim Wilson and Kaveh Ghazi. Check whether strncmp reads past the end of its string parameters. */ ++#include +#include #include #ifdef HAVE_FCNTL_H -@@ -51,7 +52,8 @@ AC_CACHE_CHECK([for working strncmp], ac_cv_func_strncmp_works, +@@ -51,7 +53,8 @@ AC_CACHE_CHECK([for working strncmp], ac_cv_func_strncmp_works, #define MAP_LEN 0x10000 @@ -40,64 +39,66 @@ index 6bd127e9826..6e23ae906fc 100644 { #if defined(HAVE_MMAP) || defined(HAVE_MMAP_ANYWHERE) char *p; -@@ -59,7 +61,7 @@ main () +@@ -157,7 +160,10 @@ if test $ac_cv_os_cray = yes; then + fi - dev_zero = open ("/dev/zero", O_RDONLY); - if (dev_zero < 0) -- exit (1); -+ return 1; - - p = (char *) mmap (0, MAP_LEN, PROT_READ|PROT_WRITE, - MAP_ANON|MAP_PRIVATE, dev_zero, 0); -@@ -67,7 +69,7 @@ main () - p = (char *) mmap (0, MAP_LEN, PROT_READ|PROT_WRITE, - MAP_ANON|MAP_PRIVATE, -1, 0); - if (p == (char *)-1) -- exit (2); -+ return 2; - else - { - char *string = "__si_type_info"; -@@ -79,7 +81,7 @@ main () - strncmp (r, q, 14); - } - #endif /* HAVE_MMAP || HAVE_MMAP_ANYWHERE */ -- exit (0); -+ return 0; - } - ], ac_cv_func_strncmp_works=yes, ac_cv_func_strncmp_works=no, - ac_cv_func_strncmp_works=yes) -@@ -171,7 +173,7 @@ AC_CACHE_CHECK(stack direction for C alloca, ac_cv_c_stack_direction, - } - main () + AC_CACHE_CHECK(stack direction for C alloca, ac_cv_c_stack_direction, +-[AC_TRY_RUN([find_stack_direction () ++[AC_TRY_RUN([#include ++ ++int ++find_stack_direction (void) { -- exit (find_stack_direction() < 0); -+ return find_stack_direction() < 0; + static char *addr = 0; + auto char dummy; +@@ -169,7 +175,9 @@ AC_CACHE_CHECK(stack direction for C alloca, ac_cv_c_stack_direction, + else + return (&dummy > addr) ? 1 : -1; + } +-main () ++ ++int ++main (void) + { + exit (find_stack_direction() < 0); }], - ac_cv_c_stack_direction=1, - ac_cv_c_stack_direction=-1, diff --git a/libiberty/configure b/libiberty/configure -index 0a797255c70..fba4e7b307d 100755 +index 0a797255c70..ca83f89da6d 100755 --- a/libiberty/configure +++ b/libiberty/configure -@@ -6794,7 +6794,7 @@ find_stack_direction () - } - main () +@@ -6780,7 +6780,10 @@ else + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +-find_stack_direction () ++#include ++ ++int ++find_stack_direction (void) { -- exit (find_stack_direction() < 0); -+ return find_stack_direction() < 0; + static char *addr = 0; + auto char dummy; +@@ -6792,7 +6795,9 @@ find_stack_direction () + else + return (&dummy > addr) ? 1 : -1; } - _ACEOF - if ac_fn_c_try_run "$LINENO"; then : -@@ -7617,6 +7617,7 @@ else +-main () ++ ++int ++main (void) + { + exit (find_stack_direction() < 0); + } +@@ -7617,6 +7622,8 @@ else /* Test by Jim Wilson and Kaveh Ghazi. Check whether strncmp reads past the end of its string parameters. */ ++#include +#include #include #ifdef HAVE_FCNTL_H -@@ -7644,7 +7645,8 @@ else +@@ -7644,7 +7651,8 @@ else #define MAP_LEN 0x10000 @@ -107,33 +108,3 @@ index 0a797255c70..fba4e7b307d 100755 { #if defined(HAVE_MMAP) || defined(HAVE_MMAP_ANYWHERE) char *p; -@@ -7652,7 +7654,7 @@ main () - - dev_zero = open ("/dev/zero", O_RDONLY); - if (dev_zero < 0) -- exit (1); -+ return 1; - - p = (char *) mmap (0, MAP_LEN, PROT_READ|PROT_WRITE, - MAP_ANON|MAP_PRIVATE, dev_zero, 0); -@@ -7660,7 +7662,7 @@ main () - p = (char *) mmap (0, MAP_LEN, PROT_READ|PROT_WRITE, - MAP_ANON|MAP_PRIVATE, -1, 0); - if (p == (char *)-1) -- exit (2); -+ return 2; - else - { - char *string = "__si_type_info"; -@@ -7672,7 +7674,7 @@ main () - strncmp (r, q, 14); - } - #endif /* HAVE_MMAP || HAVE_MMAP_ANYWHERE */ -- exit (0); -+ return 0; - } - - _ACEOF --- -2.37.3 - From 87464ae8e47800df2963aab3e81e3a115914cac1 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Thu, 20 Oct 2022 16:39:10 +0200 Subject: [PATCH 05/21] Bump release --- gcc.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc.spec b/gcc.spec index d5648d4..d97bdcd 100644 --- a/gcc.spec +++ b/gcc.spec @@ -125,7 +125,7 @@ Summary: Various compilers (C, C++, Objective-C, ...) Name: gcc Version: %{gcc_version} -Release: %{gcc_release}.implicits.2%{?dist} +Release: %{gcc_release}.implicits.3%{?dist} # libgcc, libgfortran, libgomp, libstdc++ and crtstuff have # GCC Runtime Exception. License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD From 4cfa2459d2427dded7de89c94a1a5e0d4724d3ce Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Thu, 17 Nov 2022 14:53:19 +0100 Subject: [PATCH 06/21] Do not run testsuite during build --- gcc.spec | 56 -------------------------------------------------------- 1 file changed, 56 deletions(-) diff --git a/gcc.spec b/gcc.spec index 720ce2d..8896c47 100644 --- a/gcc.spec +++ b/gcc.spec @@ -2050,62 +2050,6 @@ ln -sf gcc-annobin.so.0.0.0 $FULLPATH/plugin/gcc-annobin.so.0 ln -sf gcc-annobin.so.0.0.0 $FULLPATH/plugin/gcc-annobin.so %endif -%check -cd obj-%{gcc_target_platform} - -# run the tests. -LC_ALL=C make %{?_smp_mflags} -k check ALT_CC_UNDER_TEST=gcc ALT_CXX_UNDER_TEST=g++ \ -%if 0%{?fedora} >= 20 || 0%{?rhel} > 7 - RUNTESTFLAGS="--target_board=unix/'{,-fstack-protector-strong}'" || : -%else - RUNTESTFLAGS="--target_board=unix/'{,-fstack-protector}'" || : -%endif -%if !%{build_annobin_plugin} -if [ -f %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_major}/plugin/annobin.so ]; then - # Test whether current annobin plugin won't fail miserably with the newly built gcc. - echo -e '#include \nint main () { printf ("Hello, world!\\n"); return 0; }' > annobin-test.c - echo -e '#include \nint main () { std::cout << "Hello, world!" << std::endl; return 0; }' > annobin-test.C - `%{gcc_target_platform}/libstdc++-v3/scripts/testsuite_flags --build-cc` \ - -O2 -g -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS \ - -fexceptions -fstack-protector-strong -grecord-gcc-switches -o annobin-test{c,.c} \ - -Wl,-rpath,%{gcc_target_platform}/libgcc/ \ - -fplugin=%{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_major}/plugin/annobin.so \ - 2> ANNOBINOUT1 || echo Annobin test 1 FAIL > ANNOBINOUT2; - `%{gcc_target_platform}/libstdc++-v3/scripts/testsuite_flags --build-cxx` \ - `%{gcc_target_platform}/libstdc++-v3/scripts/testsuite_flags --build-includes` \ - -O2 -g -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS \ - -fexceptions -fstack-protector-strong -grecord-gcc-switches -o annobin-test{C,.C} \ - -Wl,-rpath,%{gcc_target_platform}/libgcc/:%{gcc_target_platform}/libstdc++-v3/src/.libs/ \ - -fplugin=%{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_major}/plugin/annobin.so \ - -B %{gcc_target_platform}/libstdc++-v3/src/.libs/ \ - 2> ANNOBINOUT3 || echo Annobin test 2 FAIL > ANNOBINOUT4; - [ -f ./annobin-testc ] || echo Annobin test 1 MISSING > ANNOBINOUT5; - [ -f ./annobin-testc ] && \ - ( ./annobin-testc > ANNOBINRES1 2>&1 || echo Annobin test 1 RUNFAIL > ANNOBINOUT6 ); - [ -f ./annobin-testC ] || echo Annobin test 2 MISSING > ANNOBINOUT7; - [ -f ./annobin-testC ] && \ - ( ./annobin-testC > ANNOBINRES2 2>&1 || echo Annobin test 2 RUNFAIL > ANNOBINOUT8 ); - cat ANNOBINOUT[1-8] > ANNOBINOUT - touch ANNOBINRES1 ANNOBINRES2 - [ -s ANNOBINOUT ] && echo Annobin testing FAILed > ANNOBINRES - cat ANNOBINOUT ANNOBINRES[12] >> ANNOBINRES - rm -f ANNOBINOUT* ANNOBINRES[12] annobin-test{c,C} -fi -%endif -echo ====================TESTING========================= -( LC_ALL=C ../contrib/test_summary || : ) 2>&1 | sed -n '/^cat.*EOF/,/^EOF/{/^cat.*EOF/d;/^EOF/d;/^LAST_UPDATED:/d;p;}' -%if !%{build_annobin_plugin} -[ -f ANNOBINRES ] && cat ANNOBINRES -%endif -echo ====================TESTING END===================== -mkdir testlogs-%{_target_platform}-%{version}-%{release} -for i in `find . -name \*.log | grep -F testsuite/ | grep -v 'config.log\|acats.*/tests/'`; do - ln $i testlogs-%{_target_platform}-%{version}-%{release}/ || : -done -tar cf - testlogs-%{_target_platform}-%{version}-%{release} | xz -9e \ - | uuencode testlogs-%{_target_platform}.tar.xz || : -rm -rf testlogs-%{_target_platform}-%{version}-%{release} - %post go %{_sbindir}/update-alternatives --install \ %{_prefix}/bin/go go %{_prefix}/bin/go.gcc 92 \ From bca5d900099e1f99614583fbc08745ae55337a9a Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Mon, 21 Nov 2022 16:21:20 +0100 Subject: [PATCH 07/21] Disable instrumentation for building GCC itself for now --- gcc.spec | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gcc.spec b/gcc.spec index 8896c47..7dcd3a3 100644 --- a/gcc.spec +++ b/gcc.spec @@ -856,6 +856,9 @@ fi rm -f gcc/testsuite/go.test/test/chan/goroutines.go %build +# Do not write the failures anywhere. Currently required for rebuilding +# with an instrumented GCC. +export GCC_ERROR_LOG_DIRECTORY=/disabled # Undo the broken autoconf change in recent Fedora versions export CONFIG_SITE=NONE From a1979f63e77ce09afd487a7f11e541ac994f13e7 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Tue, 22 Nov 2022 23:46:53 +0100 Subject: [PATCH 08/21] Treat __declspec as a keyword, recognize redefined types in declarations This reduces the number of spurious implict int errors. --- gcc.spec | 6 +++- gcc12-declspec-keyword.patch | 38 +++++++++++++++++++++++ gcc12-pr107805.patch | 60 ++++++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 gcc12-declspec-keyword.patch create mode 100644 gcc12-pr107805.patch diff --git a/gcc.spec b/gcc.spec index 8c480c7..61cba50 100644 --- a/gcc.spec +++ b/gcc.spec @@ -125,7 +125,7 @@ Summary: Various compilers (C, C++, Objective-C, ...) Name: gcc Version: %{gcc_version} -Release: %{gcc_release}.implicits.3%{?dist} +Release: %{gcc_release}.implicits.4%{?dist} # libgcc, libgfortran, libgomp, libstdc++ and crtstuff have # GCC Runtime Exception. License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD @@ -285,6 +285,8 @@ Patch103: gcc12-fortran-fdec-non-logical-if.patch Patch990: gcc12-implicits.patch Patch991: gcc12-c99-fixes-1.patch Patch992: gcc12-c99-fixes-2.patch +Patch993: gcc12-declspec-keyword.patch +Patch994: gcc12-pr107805.patch # On ARM EABI systems, we do want -gnueabi to be part of the # target triple. @@ -819,6 +821,8 @@ so that there cannot be any synchronization problems. %patch990 -p1 -b .implicits %patch991 -p1 -b .c99-fixes-1 %patch992 -p1 -b .c99-fixes-2 +%patch993 -p1 -b .declspec-keyword +%patch994 -p1 -b .pr107805 %ifarch %{arm} rm -f gcc/testsuite/go.test/test/fixedbugs/issue19182.go diff --git a/gcc12-declspec-keyword.patch b/gcc12-declspec-keyword.patch new file mode 100644 index 0000000..700118e --- /dev/null +++ b/gcc12-declspec-keyword.patch @@ -0,0 +1,38 @@ +commit 48ec7dc1792d4e80e9b3b43783f4d013c64498d7 +Author: Florian Weimer +Date: Tue Nov 22 10:50:09 2022 +0100 + + Turn __declspec into a keyword + + This avoids diagnosing + + __declspec(thread) int foo; + + as an old-style function definition with an implicit int. + +diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc +index bb0544eeaea..f688944a986 100644 +--- a/gcc/c-family/c-common.cc ++++ b/gcc/c-family/c-common.cc +@@ -455,6 +455,7 @@ const struct c_common_resword c_common_reswords[] = + { "__GIMPLE", RID_GIMPLE, D_CONLY }, + { "__PHI", RID_PHI, D_CONLY }, + { "__RTL", RID_RTL, D_CONLY }, ++ { "__declspec", RID_DECLTYPE, D_CONLY }, + { "alignas", RID_ALIGNAS, D_CXXONLY | D_CXX11 | D_CXXWARN }, + { "alignof", RID_ALIGNOF, D_CXXONLY | D_CXX11 | D_CXXWARN }, + { "asm", RID_ASM, D_ASM }, +diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h +index 52a85bfb783..44f35574b80 100644 +--- a/gcc/c-family/c-common.h ++++ b/gcc/c-family/c-common.h +@@ -135,6 +135,9 @@ enum rid + /* "__RTL", for the RTL-parsing extension to the C frontend. */ + RID_RTL, + ++ /* MSVC extension. */ ++ RID_DECLSPEC, ++ + /* C11 */ + RID_ALIGNAS, RID_GENERIC, + diff --git a/gcc12-pr107805.patch b/gcc12-pr107805.patch new file mode 100644 index 0000000..6d28351 --- /dev/null +++ b/gcc12-pr107805.patch @@ -0,0 +1,60 @@ +commit 117188f89471d19cd6c985201da5efc1bb3efb61 +Author: Florian Weimer +Date: Tue Nov 22 13:17:42 2022 +0100 + + c: Propagate erroneous types to declaration specifiers [PR107805] + + Without this change, finish_declspecs cannot tell that whether there + was an erroneous type specified, or no type at all. This may result + in additional diagnostics for implicit ints, or missing diagnostics + for multiple types. + + PR c/107805 + + gcc/c/ + * c-decl.cc (declspecs_add_type): Propagate error_mark_bode + from type to specs. + + gcc/testsuite/ + * gcc.dg/pr107805-1.c: New test. + * gcc.dg/pr107805-1.c: Likewise. + +diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc +index 2010621ab78..ef585fb97cb 100644 +--- a/gcc/c/c-decl.cc ++++ b/gcc/c/c-decl.cc +@@ -11678,11 +11678,9 @@ declspecs_add_type (location_t loc, struct c_declspecs *specs, + error_at (loc, "two or more data types in declaration specifiers"); + else if (TREE_CODE (type) == TYPE_DECL) + { +- if (TREE_TYPE (type) == error_mark_node) +- ; /* Allow the type to default to int to avoid cascading errors. */ +- else ++ specs->type = TREE_TYPE (type); ++ if (TREE_TYPE (type) != error_mark_node) + { +- specs->type = TREE_TYPE (type); + specs->decl_attr = DECL_ATTRIBUTES (type); + specs->typedef_p = true; + specs->explicit_signed_p = C_TYPEDEF_EXPLICITLY_SIGNED (type); +diff --git a/gcc/testsuite/gcc.dg/pr107805-1.c b/gcc/testsuite/gcc.dg/pr107805-1.c +new file mode 100644 +index 00000000000..559b6a5586e +--- /dev/null ++++ b/gcc/testsuite/gcc.dg/pr107805-1.c +@@ -0,0 +1,5 @@ ++/* { dg-do compile } */ ++typedef int t; ++typedef struct { double a; int b; } t; /* { dg-error "conflicting types" } */ ++t x; /* No warning here. */ ++ +diff --git a/gcc/testsuite/gcc.dg/pr107805-2.c b/gcc/testsuite/gcc.dg/pr107805-2.c +new file mode 100644 +index 00000000000..fa5fa4ce273 +--- /dev/null ++++ b/gcc/testsuite/gcc.dg/pr107805-2.c +@@ -0,0 +1,4 @@ ++/* { dg-do compile } */ ++typedef int t; ++typedef struct { double a; int b; } t; /* { dg-error "conflicting types" } */ ++t char x; /* { dg-error "two or more data types" } */ From caea58a62a40fac64983df4b9f663ffadd511c50 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Sat, 18 Mar 2023 20:28:09 +0100 Subject: [PATCH 09/21] Fixup incorrect merge --- gcc.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc.spec b/gcc.spec index 138d9c2..072450a 100644 --- a/gcc.spec +++ b/gcc.spec @@ -135,6 +135,7 @@ %endif Summary: Various compilers (C, C++, Objective-C, ...) Name: gcc +Version: %{gcc_version} Release: %{gcc_release}.8.implicits.4%{?dist} # libgcc, libgfortran, libgomp, libstdc++ and crtstuff have # GCC Runtime Exception. From a9b15d7950993cafd8f98b35bd242352d2cef0d1 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Tue, 18 Apr 2023 19:07:23 +0200 Subject: [PATCH 10/21] NVR fix --- gcc.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc.spec b/gcc.spec index 4629a77..ed6e925 100644 --- a/gcc.spec +++ b/gcc.spec @@ -136,7 +136,7 @@ Summary: Various compilers (C, C++, Objective-C, ...) Name: gcc Version: %{gcc_version} -Release: %{gcc_release}.15.implicits.4%{?dist} +Release: %{gcc_release}.14.implicits.4%{?dist} # libgcc, libgfortran, libgomp, libstdc++ and crtstuff have # GCC Runtime Exception. License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD From b1db644be87257da94774dabca090c778e729e47 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Thu, 4 May 2023 09:35:43 +0200 Subject: [PATCH 11/21] Log int-conversion errors --- gcc-int-conversion.patch | 165 +++++++++++++++++++++++++++++++++++++++ gcc.spec | 8 +- 2 files changed, 170 insertions(+), 3 deletions(-) create mode 100644 gcc-int-conversion.patch diff --git a/gcc-int-conversion.patch b/gcc-int-conversion.patch new file mode 100644 index 0000000..e20a08b --- /dev/null +++ b/gcc-int-conversion.patch @@ -0,0 +1,165 @@ +commit 520084d2d6cacd355fecd05da374bea9bb52c792 +Author: Florian Weimer +Date: Thu May 4 09:30:24 2023 +0200 + + Enable error logging for -Wint-conversion + + Only for C99 and later language modes. + +diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc +index a17879698ec..b1c4fbf77f8 100644 +--- a/gcc/c/c-typeck.cc ++++ b/gcc/c/c-typeck.cc +@@ -7749,27 +7749,67 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, + auto_diagnostic_group d; + range_label_for_type_mismatch rhs_label (rhstype, type); + gcc_rich_location richloc (expr_loc, &rhs_label); +- if (pedwarn (&richloc, OPT_Wint_conversion, ++ if (flag_isoc99) ++ { ++ log_error_to_directory (location, ++ "pointer-from-int-conversion" ++ " in argument"); ++ error_at (&richloc, ++ "passing argument %d of %qE makes pointer from " ++ "integer without a cast", parmnum, rname); ++ inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype); ++ } ++ else if (pedwarn (&richloc, OPT_Wint_conversion, + "passing argument %d of %qE makes pointer from " + "integer without a cast", parmnum, rname)) + inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype); + } + break; + case ic_assign: +- pedwarn (location, OPT_Wint_conversion, +- "assignment to %qT from %qT makes pointer from integer " +- "without a cast", type, rhstype); ++ if (flag_isoc99) ++ { ++ log_error_to_directory (location, ++ "pointer-from-int-conversion" ++ " in assignment"); ++ error_at (location, ++ "assignment to %qT from %qT makes pointer from integer " ++ "without a cast", type, rhstype); ++ } ++ else ++ pedwarn (location, OPT_Wint_conversion, ++ "assignment to %qT from %qT makes pointer from integer " ++ "without a cast", type, rhstype); + break; + case ic_init: + case ic_init_const: +- pedwarn_init (location, OPT_Wint_conversion, ++ if (flag_isoc99) ++ { ++ log_error_to_directory (location, ++ "pointer-from-int-conversion" ++ " in initialization"); ++ error_at (location, + "initialization of %qT from %qT makes pointer from " + "integer without a cast", type, rhstype); ++ } ++ else ++ pedwarn_init (location, OPT_Wint_conversion, ++ "initialization of %qT from %qT makes pointer from " ++ "integer without a cast", type, rhstype); + break; + case ic_return: +- pedwarn (location, OPT_Wint_conversion, "returning %qT from a " +- "function with return type %qT makes pointer from " +- "integer without a cast", rhstype, type); ++ if (flag_isoc99) ++ { ++ log_error_to_directory (location, ++ "pointer-from-int-conversion" ++ " in return"); ++ error_at (location, "returning %qT from a " ++ "function with return type %qT makes pointer from " ++ "integer without a cast", rhstype, type); ++ } ++ else ++ pedwarn (location, OPT_Wint_conversion, "returning %qT from a " ++ "function with return type %qT makes pointer from " ++ "integer without a cast", rhstype, type); + break; + default: + gcc_unreachable (); +@@ -7786,27 +7826,66 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, + auto_diagnostic_group d; + range_label_for_type_mismatch rhs_label (rhstype, type); + gcc_rich_location richloc (expr_loc, &rhs_label); +- if (pedwarn (&richloc, OPT_Wint_conversion, +- "passing argument %d of %qE makes integer from " +- "pointer without a cast", parmnum, rname)) ++ if (flag_isoc99) ++ { ++ log_error_to_directory (location, ++ "pointer-to-int-conversion" ++ " in argument"); ++ error_at (&richloc, ++ "passing argument %d of %qE makes integer from " ++ "pointer without a cast", parmnum, rname); ++ inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype); ++ } ++ else if (pedwarn (&richloc, OPT_Wint_conversion, ++ "passing argument %d of %qE makes integer from " ++ "pointer without a cast", parmnum, rname)) + inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype); + } + break; + case ic_assign: +- pedwarn (location, OPT_Wint_conversion, +- "assignment to %qT from %qT makes integer from pointer " +- "without a cast", type, rhstype); ++ if (flag_isoc99) ++ { ++ log_error_to_directory (location, ++ "pointer-to-int-conversion" ++ " in assignment"); ++ error_at (location, ++ "assignment to %qT from %qT makes integer from pointer " ++ "without a cast", type, rhstype); ++ } ++ else ++ pedwarn (location, OPT_Wint_conversion, ++ "assignment to %qT from %qT makes integer from pointer " ++ "without a cast", type, rhstype); + break; + case ic_init: + case ic_init_const: +- pedwarn_init (location, OPT_Wint_conversion, ++ if (flag_isoc99) ++ { ++ log_error_to_directory (location, ++ "pointer-to-int-conversion" ++ " in initialization"); ++ error_at (location, + "initialization of %qT from %qT makes integer from " + "pointer without a cast", type, rhstype); ++ } ++ else ++ pedwarn_init (location, OPT_Wint_conversion, ++ "initialization of %qT from %qT makes integer from " ++ "pointer without a cast", type, rhstype); + break; + case ic_return: +- pedwarn (location, OPT_Wint_conversion, "returning %qT from a " +- "function with return type %qT makes integer from " +- "pointer without a cast", rhstype, type); ++ if (flag_isoc99) ++ { ++ log_error_to_directory (location, ++ "pointer-to-int-conversion" ++ " in return"); ++ error_at (location, "returning %qT from a " ++ "function with return type %qT makes integer from " ++ "pointer without a cast", rhstype, type); ++ } ++ else pedwarn (location, OPT_Wint_conversion, "returning %qT from a " ++ "function with return type %qT makes integer from " ++ "pointer without a cast", rhstype, type); + break; + default: + gcc_unreachable (); diff --git a/gcc.spec b/gcc.spec index 1655fa2..85b0ceb 100644 --- a/gcc.spec +++ b/gcc.spec @@ -136,7 +136,7 @@ Summary: Various compilers (C, C++, Objective-C, ...) Name: gcc Version: %{gcc_version} -Release: %{gcc_release}.implicits.4%{?dist} +Release: %{gcc_release}.implicits.5%{?dist} # libgcc, libgfortran, libgomp, libstdc++ and crtstuff have # GCC Runtime Exception. License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD @@ -296,6 +296,7 @@ Patch103: gcc13-fortran-fdec-non-logical-if.patch Patch990: gcc12-implicits.patch Patch993: gcc12-declspec-keyword.patch +Patch994: gcc-int-conversion.patch # On ARM EABI systems, we do want -gnueabi to be part of the # target triple. @@ -876,8 +877,9 @@ touch -r isl-0.24/m4/ax_prog_cxx_for_build.m4 isl-0.24/m4/ax_prog_cc_for_build.m %patch -P103 -p1 -b .fortran-fdec-non-logical-if~ %endif -%patch990 -p1 -b .implicits -%patch993 -p1 -b .declspec-keyword +%patch -P 990 -p1 -b .implicits +%patch -P 993 -p1 -b .declspec-keyword +%patch -P 994 -p1 -b .int-conversion %ifarch %{arm} rm -f gcc/testsuite/go.test/test/fixedbugs/issue19182.go From e66bb65ab36c2137352e15ecfdd5d68cb478722d Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Thu, 4 May 2023 15:36:41 +0200 Subject: [PATCH 12/21] Avoid logging cascading errors --- gcc-no-cascaded-error-logging.patch | 28 ++++++++++++++++++++++++++++ gcc.spec | 4 +++- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 gcc-no-cascaded-error-logging.patch diff --git a/gcc-no-cascaded-error-logging.patch b/gcc-no-cascaded-error-logging.patch new file mode 100644 index 0000000..0906d27 --- /dev/null +++ b/gcc-no-cascaded-error-logging.patch @@ -0,0 +1,28 @@ +commit 8a159bb3a42576d0c8c8e0c8c00de5d7c2892068 +Author: Florian Weimer +Date: Thu May 4 15:18:28 2023 +0200 + + Do not log cascading errors + +diff --git a/gcc/diagnostic.cc b/gcc/diagnostic.cc +index 73070cc11f9..6fd14862179 100644 +--- a/gcc/diagnostic.cc ++++ b/gcc/diagnostic.cc +@@ -2743,6 +2743,17 @@ void + log_error_to_directory (location_t loc, const char *message, + const char *identifier) + { ++ static bool already_logged; ++ ++ /* Do not log the errors after another (unrelated) error. Cascading ++ errors not critical because they do not alter the build result. ++ But if we have logged an error already, log all the other ones as ++ well, to provide more information from the same compiler run. */ ++ if (diagnostic_kind_count (global_dc, DK_ERROR) > 0 && !already_logged) ++ return; ++ ++ already_logged = true; ++ + const char *magic_path = getenv ("GCC_ERROR_LOG_DIRECTORY"); + if (magic_path == nullptr) + magic_path = "/usr/lib/gcc/errors"; diff --git a/gcc.spec b/gcc.spec index 85b0ceb..1db1b2b 100644 --- a/gcc.spec +++ b/gcc.spec @@ -136,7 +136,7 @@ Summary: Various compilers (C, C++, Objective-C, ...) Name: gcc Version: %{gcc_version} -Release: %{gcc_release}.implicits.5%{?dist} +Release: %{gcc_release}.implicits.6%{?dist} # libgcc, libgfortran, libgomp, libstdc++ and crtstuff have # GCC Runtime Exception. License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD @@ -297,6 +297,7 @@ Patch103: gcc13-fortran-fdec-non-logical-if.patch Patch990: gcc12-implicits.patch Patch993: gcc12-declspec-keyword.patch Patch994: gcc-int-conversion.patch +Patch995: gcc-no-cascaded-error-logging.patch # On ARM EABI systems, we do want -gnueabi to be part of the # target triple. @@ -880,6 +881,7 @@ touch -r isl-0.24/m4/ax_prog_cxx_for_build.m4 isl-0.24/m4/ax_prog_cc_for_build.m %patch -P 990 -p1 -b .implicits %patch -P 993 -p1 -b .declspec-keyword %patch -P 994 -p1 -b .int-conversion +%patch -P 995 -p1 -b .no-cascaded-error-logging %ifarch %{arm} rm -f gcc/testsuite/go.test/test/fixedbugs/issue19182.go From d40573479e0d03f1458996456d37a9085c4928b6 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Wed, 15 Nov 2023 10:24:36 +0100 Subject: [PATCH 13/21] More comprehensive error logging, to match upstream plans Also some heuristics for not logging irrelevant errors. --- gcc-error-logging.patch | 877 ++++++++++++++++++++++++++++ gcc-int-conversion.patch | 165 ------ gcc-no-cascaded-error-logging.patch | 28 - gcc.spec | 14 +- gcc12-declspec-keyword.patch | 38 -- gcc12-implicits.patch | 126 ---- 6 files changed, 881 insertions(+), 367 deletions(-) create mode 100644 gcc-error-logging.patch delete mode 100644 gcc-int-conversion.patch delete mode 100644 gcc-no-cascaded-error-logging.patch delete mode 100644 gcc12-declspec-keyword.patch delete mode 100644 gcc12-implicits.patch diff --git a/gcc-error-logging.patch b/gcc-error-logging.patch new file mode 100644 index 0000000..06421f3 --- /dev/null +++ b/gcc-error-logging.patch @@ -0,0 +1,877 @@ +commit 423455963df19041b8dbea86fca8c1bb0549ccf0 +Author: Florian Weimer +Date: Tue Oct 18 16:28:33 2022 +0200 + + Log implicit ints/implicit function declarations to /usr/lib/gcc/errors + + Only do so for C99 and later language modes, both features were part + of C89. + + The directory and the file name prefix for files within can be + controlled using the GCC_ERROR_LOG_DIRECTORY and GCC_ERROR_LOG_PREFIX + environment variables. + +diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc +index 1b53f2d0785..4bf3b4a4c2a 100644 +--- a/gcc/c/c-decl.cc ++++ b/gcc/c/c-decl.cc +@@ -3468,6 +3468,14 @@ pushdecl (tree x) + static void + implicit_decl_warning (location_t loc, tree id, tree olddecl) + { ++ if (flag_isoc99) ++ { ++ log_error_to_directory (loc, "implicit function declaration", ++ IDENTIFIER_POINTER (id)); ++ error_at (loc, "implicit declaration of function %qE", id); ++ return; ++ } ++ + if (!warn_implicit_function_declaration) + return; + +@@ -6705,7 +6713,15 @@ grokdeclarator (const struct c_declarator *declarator, + + /* Diagnose defaulting to "int". */ + +- if (declspecs->default_int_p && !in_system_header_at (input_location)) ++ if (declspecs->default_int_p && flag_isoc99) ++ { ++ log_error_to_directory (loc, "defaulting to int"); ++ if (name) ++ error_at (loc, "type defaults to % in declaration of %qE", name); ++ else ++ error_at (loc, "type defaults to % in type name"); ++ } ++ else if (declspecs->default_int_p && !in_system_header_at (input_location)) + { + /* Issue a warning if this is an ISO C 99 program or if + -Wreturn-type and this is a function, or if -Wimplicit; +@@ -10469,9 +10485,12 @@ store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info) + warn_if_shadowing (decl); + + if (flag_isoc99) +- pedwarn (DECL_SOURCE_LOCATION (decl), +- OPT_Wimplicit_int, "type of %qD defaults to %", +- decl); ++ { ++ log_error_to_directory (DECL_SOURCE_LOCATION (decl), ++ "type defaults to int"); ++ error_at (DECL_SOURCE_LOCATION (decl), ++ "type of %qD defaults to %", decl); ++ } + else + warning_at (DECL_SOURCE_LOCATION (decl), + OPT_Wmissing_parameter_type, +diff --git a/gcc/diagnostic.cc b/gcc/diagnostic.cc +index 0f093081161..73070cc11f9 100644 +--- a/gcc/diagnostic.cc ++++ b/gcc/diagnostic.cc +@@ -2737,3 +2737,44 @@ c_diagnostic_cc_tests () + #if __GNUC__ >= 10 + # pragma GCC diagnostic pop + #endif ++ ++/* Magic code to emit diagnostics to a log directory. */ ++void ++log_error_to_directory (location_t loc, const char *message, ++ const char *identifier) ++{ ++ const char *magic_path = getenv ("GCC_ERROR_LOG_DIRECTORY"); ++ if (magic_path == nullptr) ++ magic_path = "/usr/lib/gcc/errors"; ++ ++ // Do not log anything if the directory does not exist. ++ if (access (magic_path, R_OK | W_OK | X_OK) < 0) ++ return; ++ ++ const char *log_prefix = getenv ("GCC_ERROR_LOG_PREFIX"); ++ if (log_prefix == nullptr) ++ log_prefix = "gcc"; ++ ++ char *templ = xasprintf ("%s/%sXXXXXX", magic_path, log_prefix); ++ int fd = mkstemp (templ); ++ if (fd < 0) ++ abort(); ++ ++ auto exploc = expand_location (loc); ++ const char *file = exploc.file; ++ if (file == nullptr) ++ file = ""; ++ char *formatted; ++ if (identifier != nullptr) ++ formatted = xasprintf ("%s:%d: %s: %s\n", ++ file, exploc.line, message, identifier); ++ else ++ formatted = xasprintf ("%s:%d: %s\n", file, exploc.line, message); ++ ssize_t len = strlen (formatted); ++ if (write (fd, formatted, len) != len ++ || close (fd) < 0) ++ abort (); ++ ++ free (formatted); ++ free (templ); ++} +diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h +index 9a51097f146..b520de263ab 100644 +--- a/gcc/diagnostic.h ++++ b/gcc/diagnostic.h +@@ -619,4 +619,7 @@ extern bool warning_enabled_at (location_t, int); + + extern char *get_cwe_url (int cwe); + ++void log_error_to_directory (location_t loc, const char *message, ++ const char *identifier = nullptr); ++ + #endif /* ! GCC_DIAGNOSTIC_H */ + +commit 06d52570382a3b9e6041d58d10127ecc466af3b7 +Author: Florian Weimer +Date: Tue Nov 22 10:50:09 2022 +0100 + + Turn __declspec into a keyword + + This avoids diagnosing + + __declspec(thread) int foo; + + as an old-style function definition with an implicit int. + +diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc +index aae397ed755..fdc1f163ed0 100644 +--- a/gcc/c-family/c-common.cc ++++ b/gcc/c-family/c-common.cc +@@ -425,6 +425,7 @@ const struct c_common_resword c_common_reswords[] = + { "__GIMPLE", RID_GIMPLE, D_CONLY }, + { "__PHI", RID_PHI, D_CONLY }, + { "__RTL", RID_RTL, D_CONLY }, ++ { "__declspec", RID_DECLTYPE, D_CONLY }, + { "alignas", RID_ALIGNAS, D_C2X | D_CXX11 | D_CXXWARN }, + { "alignof", RID_ALIGNOF, D_C2X | D_CXX11 | D_CXXWARN }, + { "asm", RID_ASM, D_ASM }, +diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h +index f96350b64af..61cb0dfadf9 100644 +--- a/gcc/c-family/c-common.h ++++ b/gcc/c-family/c-common.h +@@ -136,6 +136,9 @@ enum rid + /* "__RTL", for the RTL-parsing extension to the C frontend. */ + RID_RTL, + ++ /* MSVC extension. */ ++ RID_DECLSPEC, ++ + /* C11 */ + RID_ALIGNAS, RID_GENERIC, + + +commit eda435e65520e4b58e7d407cca17c1fb810e02a9 +Author: Florian Weimer +Date: Thu May 4 09:30:24 2023 +0200 + + Enable error logging for -Wint-conversion + + Only for C99 and later language modes. + +diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc +index a17879698ec..b1c4fbf77f8 100644 +--- a/gcc/c/c-typeck.cc ++++ b/gcc/c/c-typeck.cc +@@ -7749,27 +7749,67 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, + auto_diagnostic_group d; + range_label_for_type_mismatch rhs_label (rhstype, type); + gcc_rich_location richloc (expr_loc, &rhs_label); +- if (pedwarn (&richloc, OPT_Wint_conversion, ++ if (flag_isoc99) ++ { ++ log_error_to_directory (location, ++ "pointer-from-int-conversion" ++ " in argument"); ++ error_at (&richloc, ++ "passing argument %d of %qE makes pointer from " ++ "integer without a cast", parmnum, rname); ++ inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype); ++ } ++ else if (pedwarn (&richloc, OPT_Wint_conversion, + "passing argument %d of %qE makes pointer from " + "integer without a cast", parmnum, rname)) + inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype); + } + break; + case ic_assign: +- pedwarn (location, OPT_Wint_conversion, +- "assignment to %qT from %qT makes pointer from integer " +- "without a cast", type, rhstype); ++ if (flag_isoc99) ++ { ++ log_error_to_directory (location, ++ "pointer-from-int-conversion" ++ " in assignment"); ++ error_at (location, ++ "assignment to %qT from %qT makes pointer from integer " ++ "without a cast", type, rhstype); ++ } ++ else ++ pedwarn (location, OPT_Wint_conversion, ++ "assignment to %qT from %qT makes pointer from integer " ++ "without a cast", type, rhstype); + break; + case ic_init: + case ic_init_const: +- pedwarn_init (location, OPT_Wint_conversion, ++ if (flag_isoc99) ++ { ++ log_error_to_directory (location, ++ "pointer-from-int-conversion" ++ " in initialization"); ++ error_at (location, + "initialization of %qT from %qT makes pointer from " + "integer without a cast", type, rhstype); ++ } ++ else ++ pedwarn_init (location, OPT_Wint_conversion, ++ "initialization of %qT from %qT makes pointer from " ++ "integer without a cast", type, rhstype); + break; + case ic_return: +- pedwarn (location, OPT_Wint_conversion, "returning %qT from a " +- "function with return type %qT makes pointer from " +- "integer without a cast", rhstype, type); ++ if (flag_isoc99) ++ { ++ log_error_to_directory (location, ++ "pointer-from-int-conversion" ++ " in return"); ++ error_at (location, "returning %qT from a " ++ "function with return type %qT makes pointer from " ++ "integer without a cast", rhstype, type); ++ } ++ else ++ pedwarn (location, OPT_Wint_conversion, "returning %qT from a " ++ "function with return type %qT makes pointer from " ++ "integer without a cast", rhstype, type); + break; + default: + gcc_unreachable (); +@@ -7786,27 +7826,66 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, + auto_diagnostic_group d; + range_label_for_type_mismatch rhs_label (rhstype, type); + gcc_rich_location richloc (expr_loc, &rhs_label); +- if (pedwarn (&richloc, OPT_Wint_conversion, +- "passing argument %d of %qE makes integer from " +- "pointer without a cast", parmnum, rname)) ++ if (flag_isoc99) ++ { ++ log_error_to_directory (location, ++ "pointer-to-int-conversion" ++ " in argument"); ++ error_at (&richloc, ++ "passing argument %d of %qE makes integer from " ++ "pointer without a cast", parmnum, rname); ++ inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype); ++ } ++ else if (pedwarn (&richloc, OPT_Wint_conversion, ++ "passing argument %d of %qE makes integer from " ++ "pointer without a cast", parmnum, rname)) + inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype); + } + break; + case ic_assign: +- pedwarn (location, OPT_Wint_conversion, +- "assignment to %qT from %qT makes integer from pointer " +- "without a cast", type, rhstype); ++ if (flag_isoc99) ++ { ++ log_error_to_directory (location, ++ "pointer-to-int-conversion" ++ " in assignment"); ++ error_at (location, ++ "assignment to %qT from %qT makes integer from pointer " ++ "without a cast", type, rhstype); ++ } ++ else ++ pedwarn (location, OPT_Wint_conversion, ++ "assignment to %qT from %qT makes integer from pointer " ++ "without a cast", type, rhstype); + break; + case ic_init: + case ic_init_const: +- pedwarn_init (location, OPT_Wint_conversion, ++ if (flag_isoc99) ++ { ++ log_error_to_directory (location, ++ "pointer-to-int-conversion" ++ " in initialization"); ++ error_at (location, + "initialization of %qT from %qT makes integer from " + "pointer without a cast", type, rhstype); ++ } ++ else ++ pedwarn_init (location, OPT_Wint_conversion, ++ "initialization of %qT from %qT makes integer from " ++ "pointer without a cast", type, rhstype); + break; + case ic_return: +- pedwarn (location, OPT_Wint_conversion, "returning %qT from a " +- "function with return type %qT makes integer from " +- "pointer without a cast", rhstype, type); ++ if (flag_isoc99) ++ { ++ log_error_to_directory (location, ++ "pointer-to-int-conversion" ++ " in return"); ++ error_at (location, "returning %qT from a " ++ "function with return type %qT makes integer from " ++ "pointer without a cast", rhstype, type); ++ } ++ else pedwarn (location, OPT_Wint_conversion, "returning %qT from a " ++ "function with return type %qT makes integer from " ++ "pointer without a cast", rhstype, type); + break; + default: + gcc_unreachable (); + +commit 586f855010cd171d8ec9bcc0864bfbf12b88adbf +Author: Florian Weimer +Date: Wed Nov 15 09:16:01 2023 +0100 + + Implement suppression of error logging + +diff --git a/gcc/diagnostic.cc b/gcc/diagnostic.cc +index 73070cc11f9..a162caf1f0a 100644 +--- a/gcc/diagnostic.cc ++++ b/gcc/diagnostic.cc +@@ -2738,11 +2738,48 @@ c_diagnostic_cc_tests () + # pragma GCC diagnostic pop + #endif + ++#include ++#include ++ ++static bool suppress_logging; ++static std::vector logged_error_files; ++static std::vector logged_error_files_with_identifier; ++ ++static void ++remove_file_list (std::vector &files) ++{ ++ for (const std::string &path : files) ++ unlink (path.c_str ()); ++ files.clear(); ++} ++ ++void ++suppress_error_logging () ++{ ++ suppress_logging = true; ++ remove_file_list (logged_error_files); ++ remove_file_list (logged_error_files_with_identifier); ++} ++ + /* Magic code to emit diagnostics to a log directory. */ + void + log_error_to_directory (location_t loc, const char *message, + const char *identifier) + { ++ if (suppress_logging) ++ return; ++ ++ /* If logging with an identifier, remove the previous error reports ++ without an identifier. */ ++ if (identifier) ++ remove_file_list (logged_error_files); ++ ++ /* If already errored with an identifier, do not record ++ non-identifier errors. This enables ignoring errors based on ++ identifiers. */ ++ if (!identifier && !logged_error_files_with_identifier.empty()) ++ return; ++ + const char *magic_path = getenv ("GCC_ERROR_LOG_DIRECTORY"); + if (magic_path == nullptr) + magic_path = "/usr/lib/gcc/errors"; +@@ -2759,6 +2796,10 @@ log_error_to_directory (location_t loc, const char *message, + int fd = mkstemp (templ); + if (fd < 0) + abort(); ++ if (identifier) ++ logged_error_files_with_identifier.emplace_back(templ); ++ else ++ logged_error_files.emplace_back(templ); + + auto exploc = expand_location (loc); + const char *file = exploc.file; +diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h +index b520de263ab..249cfd87d78 100644 +--- a/gcc/diagnostic.h ++++ b/gcc/diagnostic.h +@@ -622,4 +622,9 @@ extern char *get_cwe_url (int cwe); + void log_error_to_directory (location_t loc, const char *message, + const char *identifier = nullptr); + ++/* Stop logging future errors and delete the existing reported errors. ++ This can be used for errors that happen unconditionally (e.g., ++ wrong number of function arguments). */ ++void suppress_error_logging (); ++ + #endif /* ! GCC_DIAGNOSTIC_H */ + +commit b23335868b5219e7c13c45a70714df75debfbd23 +Author: Florian Weimer +Date: Wed Nov 15 09:16:23 2023 +0100 + + Switch to warning names in error logs and more int-conversion coverage + +diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc +index 4bf3b4a4c2a..20b49a9d371 100644 +--- a/gcc/c/c-decl.cc ++++ b/gcc/c/c-decl.cc +@@ -3470,7 +3470,7 @@ implicit_decl_warning (location_t loc, tree id, tree olddecl) + { + if (flag_isoc99) + { +- log_error_to_directory (loc, "implicit function declaration", ++ log_error_to_directory (loc, "implicit-function-declaration", + IDENTIFIER_POINTER (id)); + error_at (loc, "implicit declaration of function %qE", id); + return; +@@ -6715,7 +6715,7 @@ grokdeclarator (const struct c_declarator *declarator, + + if (declspecs->default_int_p && flag_isoc99) + { +- log_error_to_directory (loc, "defaulting to int"); ++ log_error_to_directory (loc, "implicit-int"); + if (name) + error_at (loc, "type defaults to % in declaration of %qE", name); + else +@@ -10487,7 +10487,7 @@ store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info) + if (flag_isoc99) + { + log_error_to_directory (DECL_SOURCE_LOCATION (decl), +- "type defaults to int"); ++ "implicit-int"); + error_at (DECL_SOURCE_LOCATION (decl), + "type of %qD defaults to %", decl); + } +diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc +index b1c4fbf77f8..c0b723970ed 100644 +--- a/gcc/c/c-typeck.cc ++++ b/gcc/c/c-typeck.cc +@@ -5611,8 +5611,17 @@ build_conditional_expr (location_t colon_loc, tree ifexp, bool ifexp_bcp, + else if (code1 == POINTER_TYPE && code2 == INTEGER_TYPE) + { + if (!null_pointer_constant_p (orig_op2)) +- pedwarn (colon_loc, 0, +- "pointer/integer type mismatch in conditional expression"); ++ { ++ if (flag_isoc99) ++ { ++ log_error_to_directory (colon_loc, "int-conversion"); ++ error_at (colon_loc, ++ "pointer/integer type mismatch in conditional expression"); ++ } ++ else ++ pedwarn (colon_loc, 0, ++ "pointer/integer type mismatch in conditional expression"); ++ } + else + { + op2 = null_pointer_node; +@@ -5622,8 +5631,17 @@ build_conditional_expr (location_t colon_loc, tree ifexp, bool ifexp_bcp, + else if (code2 == POINTER_TYPE && code1 == INTEGER_TYPE) + { + if (!null_pointer_constant_p (orig_op1)) +- pedwarn (colon_loc, 0, +- "pointer/integer type mismatch in conditional expression"); ++ { ++ if (flag_isoc99) ++ { ++ log_error_to_directory (colon_loc, "int-conversion"); ++ error_at (colon_loc, ++ "pointer/integer type mismatch in conditional expression"); ++ } ++ else ++ pedwarn (colon_loc, 0, ++ "pointer/integer type mismatch in conditional expression"); ++ } + else + { + op1 = null_pointer_node; +@@ -7751,9 +7769,7 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, + gcc_rich_location richloc (expr_loc, &rhs_label); + if (flag_isoc99) + { +- log_error_to_directory (location, +- "pointer-from-int-conversion" +- " in argument"); ++ log_error_to_directory (location, "int-conversion"); + error_at (&richloc, + "passing argument %d of %qE makes pointer from " + "integer without a cast", parmnum, rname); +@@ -7768,9 +7784,7 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, + case ic_assign: + if (flag_isoc99) + { +- log_error_to_directory (location, +- "pointer-from-int-conversion" +- " in assignment"); ++ log_error_to_directory (location, "int-conversion"); + error_at (location, + "assignment to %qT from %qT makes pointer from integer " + "without a cast", type, rhstype); +@@ -7784,9 +7798,7 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, + case ic_init_const: + if (flag_isoc99) + { +- log_error_to_directory (location, +- "pointer-from-int-conversion" +- " in initialization"); ++ log_error_to_directory (location, "int-conversion"); + error_at (location, + "initialization of %qT from %qT makes pointer from " + "integer without a cast", type, rhstype); +@@ -7799,9 +7811,7 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, + case ic_return: + if (flag_isoc99) + { +- log_error_to_directory (location, +- "pointer-from-int-conversion" +- " in return"); ++ log_error_to_directory (location, "int-conversion"); + error_at (location, "returning %qT from a " + "function with return type %qT makes pointer from " + "integer without a cast", rhstype, type); +@@ -7828,9 +7838,7 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, + gcc_rich_location richloc (expr_loc, &rhs_label); + if (flag_isoc99) + { +- log_error_to_directory (location, +- "pointer-to-int-conversion" +- " in argument"); ++ log_error_to_directory (location, "int-conversion"); + error_at (&richloc, + "passing argument %d of %qE makes integer from " + "pointer without a cast", parmnum, rname); +@@ -7845,9 +7853,7 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, + case ic_assign: + if (flag_isoc99) + { +- log_error_to_directory (location, +- "pointer-to-int-conversion" +- " in assignment"); ++ log_error_to_directory (location, "int-conversion"); + error_at (location, + "assignment to %qT from %qT makes integer from pointer " + "without a cast", type, rhstype); +@@ -7861,9 +7867,7 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, + case ic_init_const: + if (flag_isoc99) + { +- log_error_to_directory (location, +- "pointer-to-int-conversion" +- " in initialization"); ++ log_error_to_directory (location, "int-conversion"); + error_at (location, + "initialization of %qT from %qT makes integer from " + "pointer without a cast", type, rhstype); +@@ -7876,9 +7880,7 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, + case ic_return: + if (flag_isoc99) + { +- log_error_to_directory (location, +- "pointer-to-int-conversion" +- " in return"); ++ log_error_to_directory (location, "int-conversion"); + error_at (location, "returning %qT from a " + "function with return type %qT makes integer from " + "pointer without a cast", rhstype, type); + +commit 9a928ad657abd0843fd9362d93c3572b134270f5 +Author: Florian Weimer +Date: Wed Nov 15 09:21:18 2023 +0100 + + Introduce and log return-mismatch errors + +diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc +index c0b723970ed..3c509ea9428 100644 +--- a/gcc/c/c-typeck.cc ++++ b/gcc/c/c-typeck.cc +@@ -11376,9 +11376,11 @@ c_finish_return (location_t loc, tree retval, tree origtype) + { + bool warned_here; + if (flag_isoc99) +- warned_here = pedwarn +- (loc, warn_return_type >= 0 ? OPT_Wreturn_type : 0, +- "% with no value, in function returning non-void"); ++ { ++ log_error_to_directory (loc, "return-mismatch"); ++ warned_here = true; ++ error_at (loc, "% with no value, in function returning non-void"); ++ } + else + warned_here = warning_at + (loc, OPT_Wreturn_type, +@@ -11394,9 +11396,18 @@ c_finish_return (location_t loc, tree retval, tree origtype) + current_function_returns_null = 1; + bool warned_here; + if (TREE_CODE (TREE_TYPE (retval)) != VOID_TYPE) +- warned_here = pedwarn +- (xloc, warn_return_type >= 0 ? OPT_Wreturn_type : 0, +- "% with a value, in function returning void"); ++ if (flag_isoc99) ++ { ++ warned_here = true; ++ log_error_to_directory (loc, "return-mismatch"); ++ error_at (xloc, "% with a value, in function returning void"); ++ } ++ else ++ { ++ warned_here = pedwarn ++ (xloc, warn_return_type >= 0 ? OPT_Wreturn_type : 0, ++ "% with a value, in function returning void"); ++ } + else + warned_here = pedwarn + (xloc, OPT_Wpedantic, "ISO C forbids " + +commit 19cba38204b90e1e03618bf4cc574584fe53a124 +Author: Florian Weimer +Date: Wed Nov 15 09:32:46 2023 +0100 + + Log incompatible-pointer-types errors + +diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc +index 3c509ea9428..93724e38dea 100644 +--- a/gcc/c/c-typeck.cc ++++ b/gcc/c/c-typeck.cc +@@ -5596,14 +5596,23 @@ build_conditional_expr (location_t colon_loc, tree ifexp, bool ifexp_bcp, + else + { + int qual = ENCODE_QUAL_ADDR_SPACE (as_common); +- if (bltin1 && bltin2) +- warning_at (colon_loc, OPT_Wincompatible_pointer_types, +- "pointer type mismatch between %qT and %qT " +- "of %qD and %qD in conditional expression", +- type1, type2, bltin1, bltin2); ++ if (flag_isoc99) ++ { ++ log_error_to_directory (colon_loc, "incompatible-pointer-types"); ++ error_at (colon_loc, ++ "pointer type mismatch in conditional expression"); ++ } + else +- pedwarn (colon_loc, 0, +- "pointer type mismatch in conditional expression"); ++ { ++ if (bltin1 && bltin2) ++ warning_at (colon_loc, OPT_Wincompatible_pointer_types, ++ "pointer type mismatch between %qT and %qT " ++ "of %qD and %qD in conditional expression", ++ type1, type2, bltin1, bltin2); ++ else ++ pedwarn (colon_loc, 0, ++ "pointer type mismatch in conditional expression"); ++ } + result_type = build_pointer_type + (build_qualified_type (void_type_node, qual)); + } +@@ -7690,13 +7699,32 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, + auto_diagnostic_group d; + range_label_for_type_mismatch rhs_label (rhstype, type); + gcc_rich_location richloc (expr_loc, &rhs_label); +- if (pedwarn (&richloc, OPT_Wincompatible_pointer_types, +- "passing argument %d of %qE from incompatible " +- "pointer type", parmnum, rname)) ++ bool warned; ++ if (flag_isoc99) ++ { ++ warned = true; ++ log_error_to_directory (expr_loc, "incompatible-pointer-types"); ++ error_at (&richloc, ++ "passing argument %d of %qE from incompatible " ++ "pointer type", parmnum, rname); ++ } ++ else ++ warned = pedwarn (&richloc, OPT_Wincompatible_pointer_types, ++ "passing argument %d of %qE from incompatible " ++ "pointer type", parmnum, rname); ++ if (warned) + inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype); + } + break; + case ic_assign: ++ if (flag_isoc99) ++ { ++ log_error_to_directory (location, "incompatible-pointer-types"); ++ error_at (location, ++ "assignment to %qT from incompatible pointer type %qT", ++ type, rhstype); ++ break; ++ } + if (bltin) + pedwarn (location, OPT_Wincompatible_pointer_types, + "assignment to %qT from pointer to " +@@ -7709,6 +7737,15 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, + break; + case ic_init: + case ic_init_const: ++ if (flag_isoc99) ++ { ++ log_error_to_directory (location, "incompatible-pointer-types"); ++ error_at (location, ++ "initialization of %qT from incompatible " ++ "pointer type %qT", ++ type, rhstype); ++ break; ++ } + if (bltin) + pedwarn_init (location, OPT_Wincompatible_pointer_types, + "initialization of %qT from pointer to " +@@ -7721,6 +7758,14 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, + type, rhstype); + break; + case ic_return: ++ if (flag_isoc99) ++ { ++ log_error_to_directory (location, "incompatible-pointer-types"); ++ error_at (location, ++ "returning %qT from a function with incompatible " ++ "return type %qT", rhstype, type); ++ break; ++ } + if (bltin) + pedwarn (location, OPT_Wincompatible_pointer_types, + "returning pointer to %qD of type %qT from " + +commit 5036b5df1a80a56cb56f0a905c1df0a8c3665aaa +Author: Florian Weimer +Date: Wed Nov 15 09:35:18 2023 +0100 + + Log declaration-missing-parameter-type errors + +diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc +index 20b49a9d371..64b62572144 100644 +--- a/gcc/c/c-decl.cc ++++ b/gcc/c/c-decl.cc +@@ -8231,8 +8231,15 @@ grokparms (struct c_arg_info *arg_info, bool funcdef_flag) + { + if (!funcdef_flag) + { +- pedwarn (input_location, 0, "parameter names (without types) in " +- "function declaration"); ++ if (flag_isoc99) ++ { ++ log_error_to_directory (input_location, "declaration-missing-parameter-type"); ++ error_at (input_location, "parameter names (without types) in " ++ "function declaration"); ++ } ++ else ++ pedwarn (input_location, 0, "parameter names (without types) in " ++ "function declaration"); + arg_info->parms = NULL_TREE; + } + else + +commit a266e38389e37233e1bcd05edeb72f5771f516c1 +Author: Florian Weimer +Date: Wed Nov 15 09:53:33 2023 +0100 + + Suppress error logging in case of a few common autoconf failures + +diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc +index fdc1f163ed0..1206bdfdf27 100644 +--- a/gcc/c-family/c-common.cc ++++ b/gcc/c-family/c-common.cc +@@ -6224,11 +6224,13 @@ builtin_function_validate_nargs (location_t loc, tree fndecl, int nargs, + { + if (nargs < required) + { ++ suppress_error_logging (); + error_at (loc, "too few arguments to function %qE", fndecl); + return false; + } + else if (nargs > required) + { ++ suppress_error_logging (); + error_at (loc, "too many arguments to function %qE", fndecl); + return false; + } +@@ -7075,6 +7077,7 @@ speculation_safe_value_resolve_call (tree function, vec *params) + + if (vec_safe_is_empty (params)) + { ++ suppress_error_logging (); + error ("too few arguments to function %qE", function); + return BUILT_IN_NONE; + } +@@ -7122,12 +7125,14 @@ speculation_safe_value_resolve_params (location_t loc, tree orig_function, + + if (params->length () == 0) + { ++ suppress_error_logging (); + error_at (loc, "too few arguments to function %qE", orig_function); + return false; + } + + else if (params->length () > 2) + { ++ suppress_error_logging (); + error_at (loc, "too many arguments to function %qE", orig_function); + return false; + } +@@ -7197,6 +7202,7 @@ sync_resolve_size (tree function, vec *params, bool fetch) + + if (vec_safe_is_empty (params)) + { ++ suppress_error_logging (); + error ("too few arguments to function %qE", function); + return 0; + } +@@ -7270,6 +7276,7 @@ sync_resolve_params (location_t loc, tree orig_function, tree function, + ++parmnum; + if (params->length () <= parmnum) + { ++ suppress_error_logging (); + error_at (loc, "too few arguments to function %qE", orig_function); + return false; + } +@@ -7296,6 +7303,7 @@ sync_resolve_params (location_t loc, tree orig_function, tree function, + /* __atomic routines are not variadic. */ + if (!orig_format && params->length () != parmnum + 1) + { ++ suppress_error_logging (); + error_at (loc, "too many arguments to function %qE", orig_function); + return false; + } +diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc +index 64b62572144..dafa70435c1 100644 +--- a/gcc/c/c-decl.cc ++++ b/gcc/c/c-decl.cc +@@ -3874,6 +3874,8 @@ undeclared_variable (location_t loc, tree id) + static bool already = false; + struct c_scope *scope; + ++ suppress_error_logging (); ++ + auto_diagnostic_group d; + if (current_function_decl == NULL_TREE) + { +diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc +index 93724e38dea..1943c232e70 100644 +--- a/gcc/c/c-typeck.cc ++++ b/gcc/c/c-typeck.cc +@@ -2576,6 +2576,7 @@ build_component_ref (location_t loc, tree datum, tree component, + + if (!field) + { ++ suppress_error_logging (); + tree guessed_id = lookup_field_fuzzy (type, component); + if (guessed_id) + { +@@ -9785,6 +9786,7 @@ set_init_label (location_t loc, tree fieldname, location_t fieldname_loc, + + if (field == NULL_TREE) + { ++ suppress_error_logging (); + tree guessed_id = lookup_field_fuzzy (constructor_type, fieldname); + if (guessed_id) + { diff --git a/gcc-int-conversion.patch b/gcc-int-conversion.patch deleted file mode 100644 index e20a08b..0000000 --- a/gcc-int-conversion.patch +++ /dev/null @@ -1,165 +0,0 @@ -commit 520084d2d6cacd355fecd05da374bea9bb52c792 -Author: Florian Weimer -Date: Thu May 4 09:30:24 2023 +0200 - - Enable error logging for -Wint-conversion - - Only for C99 and later language modes. - -diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc -index a17879698ec..b1c4fbf77f8 100644 ---- a/gcc/c/c-typeck.cc -+++ b/gcc/c/c-typeck.cc -@@ -7749,27 +7749,67 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, - auto_diagnostic_group d; - range_label_for_type_mismatch rhs_label (rhstype, type); - gcc_rich_location richloc (expr_loc, &rhs_label); -- if (pedwarn (&richloc, OPT_Wint_conversion, -+ if (flag_isoc99) -+ { -+ log_error_to_directory (location, -+ "pointer-from-int-conversion" -+ " in argument"); -+ error_at (&richloc, -+ "passing argument %d of %qE makes pointer from " -+ "integer without a cast", parmnum, rname); -+ inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype); -+ } -+ else if (pedwarn (&richloc, OPT_Wint_conversion, - "passing argument %d of %qE makes pointer from " - "integer without a cast", parmnum, rname)) - inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype); - } - break; - case ic_assign: -- pedwarn (location, OPT_Wint_conversion, -- "assignment to %qT from %qT makes pointer from integer " -- "without a cast", type, rhstype); -+ if (flag_isoc99) -+ { -+ log_error_to_directory (location, -+ "pointer-from-int-conversion" -+ " in assignment"); -+ error_at (location, -+ "assignment to %qT from %qT makes pointer from integer " -+ "without a cast", type, rhstype); -+ } -+ else -+ pedwarn (location, OPT_Wint_conversion, -+ "assignment to %qT from %qT makes pointer from integer " -+ "without a cast", type, rhstype); - break; - case ic_init: - case ic_init_const: -- pedwarn_init (location, OPT_Wint_conversion, -+ if (flag_isoc99) -+ { -+ log_error_to_directory (location, -+ "pointer-from-int-conversion" -+ " in initialization"); -+ error_at (location, - "initialization of %qT from %qT makes pointer from " - "integer without a cast", type, rhstype); -+ } -+ else -+ pedwarn_init (location, OPT_Wint_conversion, -+ "initialization of %qT from %qT makes pointer from " -+ "integer without a cast", type, rhstype); - break; - case ic_return: -- pedwarn (location, OPT_Wint_conversion, "returning %qT from a " -- "function with return type %qT makes pointer from " -- "integer without a cast", rhstype, type); -+ if (flag_isoc99) -+ { -+ log_error_to_directory (location, -+ "pointer-from-int-conversion" -+ " in return"); -+ error_at (location, "returning %qT from a " -+ "function with return type %qT makes pointer from " -+ "integer without a cast", rhstype, type); -+ } -+ else -+ pedwarn (location, OPT_Wint_conversion, "returning %qT from a " -+ "function with return type %qT makes pointer from " -+ "integer without a cast", rhstype, type); - break; - default: - gcc_unreachable (); -@@ -7786,27 +7826,66 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, - auto_diagnostic_group d; - range_label_for_type_mismatch rhs_label (rhstype, type); - gcc_rich_location richloc (expr_loc, &rhs_label); -- if (pedwarn (&richloc, OPT_Wint_conversion, -- "passing argument %d of %qE makes integer from " -- "pointer without a cast", parmnum, rname)) -+ if (flag_isoc99) -+ { -+ log_error_to_directory (location, -+ "pointer-to-int-conversion" -+ " in argument"); -+ error_at (&richloc, -+ "passing argument %d of %qE makes integer from " -+ "pointer without a cast", parmnum, rname); -+ inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype); -+ } -+ else if (pedwarn (&richloc, OPT_Wint_conversion, -+ "passing argument %d of %qE makes integer from " -+ "pointer without a cast", parmnum, rname)) - inform_for_arg (fundecl, expr_loc, parmnum, type, rhstype); - } - break; - case ic_assign: -- pedwarn (location, OPT_Wint_conversion, -- "assignment to %qT from %qT makes integer from pointer " -- "without a cast", type, rhstype); -+ if (flag_isoc99) -+ { -+ log_error_to_directory (location, -+ "pointer-to-int-conversion" -+ " in assignment"); -+ error_at (location, -+ "assignment to %qT from %qT makes integer from pointer " -+ "without a cast", type, rhstype); -+ } -+ else -+ pedwarn (location, OPT_Wint_conversion, -+ "assignment to %qT from %qT makes integer from pointer " -+ "without a cast", type, rhstype); - break; - case ic_init: - case ic_init_const: -- pedwarn_init (location, OPT_Wint_conversion, -+ if (flag_isoc99) -+ { -+ log_error_to_directory (location, -+ "pointer-to-int-conversion" -+ " in initialization"); -+ error_at (location, - "initialization of %qT from %qT makes integer from " - "pointer without a cast", type, rhstype); -+ } -+ else -+ pedwarn_init (location, OPT_Wint_conversion, -+ "initialization of %qT from %qT makes integer from " -+ "pointer without a cast", type, rhstype); - break; - case ic_return: -- pedwarn (location, OPT_Wint_conversion, "returning %qT from a " -- "function with return type %qT makes integer from " -- "pointer without a cast", rhstype, type); -+ if (flag_isoc99) -+ { -+ log_error_to_directory (location, -+ "pointer-to-int-conversion" -+ " in return"); -+ error_at (location, "returning %qT from a " -+ "function with return type %qT makes integer from " -+ "pointer without a cast", rhstype, type); -+ } -+ else pedwarn (location, OPT_Wint_conversion, "returning %qT from a " -+ "function with return type %qT makes integer from " -+ "pointer without a cast", rhstype, type); - break; - default: - gcc_unreachable (); diff --git a/gcc-no-cascaded-error-logging.patch b/gcc-no-cascaded-error-logging.patch deleted file mode 100644 index 0906d27..0000000 --- a/gcc-no-cascaded-error-logging.patch +++ /dev/null @@ -1,28 +0,0 @@ -commit 8a159bb3a42576d0c8c8e0c8c00de5d7c2892068 -Author: Florian Weimer -Date: Thu May 4 15:18:28 2023 +0200 - - Do not log cascading errors - -diff --git a/gcc/diagnostic.cc b/gcc/diagnostic.cc -index 73070cc11f9..6fd14862179 100644 ---- a/gcc/diagnostic.cc -+++ b/gcc/diagnostic.cc -@@ -2743,6 +2743,17 @@ void - log_error_to_directory (location_t loc, const char *message, - const char *identifier) - { -+ static bool already_logged; -+ -+ /* Do not log the errors after another (unrelated) error. Cascading -+ errors not critical because they do not alter the build result. -+ But if we have logged an error already, log all the other ones as -+ well, to provide more information from the same compiler run. */ -+ if (diagnostic_kind_count (global_dc, DK_ERROR) > 0 && !already_logged) -+ return; -+ -+ already_logged = true; -+ - const char *magic_path = getenv ("GCC_ERROR_LOG_DIRECTORY"); - if (magic_path == nullptr) - magic_path = "/usr/lib/gcc/errors"; diff --git a/gcc.spec b/gcc.spec index 9fb3d7a..9ed96dd 100644 --- a/gcc.spec +++ b/gcc.spec @@ -136,7 +136,7 @@ Summary: Various compilers (C, C++, Objective-C, ...) Name: gcc Version: %{gcc_version} -Release: %{gcc_release}.implicits.6%{?dist} +Release: %{gcc_release}.implicits.7%{?dist} # libgcc, libgfortran, libgomp, libstdc++ and crtstuff have # GCC Runtime Exception. License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD @@ -292,10 +292,7 @@ Patch50: isl-rh2155127.patch Patch100: gcc13-fortran-fdec-duplicates.patch -Patch990: gcc12-implicits.patch -Patch993: gcc12-declspec-keyword.patch -Patch994: gcc-int-conversion.patch -Patch995: gcc-no-cascaded-error-logging.patch +Patch990: gcc-error-logging.patch # On ARM EABI systems, we do want -gnueabi to be part of the # target triple. @@ -878,10 +875,7 @@ touch -r isl-0.24/m4/ax_prog_cxx_for_build.m4 isl-0.24/m4/ax_prog_cc_for_build.m %patch -P100 -p1 -b .fortran-fdec-duplicates~ %endif -%patch -P 990 -p1 -b .implicits -%patch -P 993 -p1 -b .declspec-keyword -%patch -P 994 -p1 -b .int-conversion -%patch -P 995 -p1 -b .no-cascaded-error-logging +%patch -P 990 -p1 -b .error-logging %ifarch %{arm} rm -f gcc/testsuite/go.test/test/fixedbugs/issue19182.go @@ -1198,7 +1192,7 @@ CC="$CC" CXX="$CXX" CFLAGS="$OPT_FLAGS" \ %ifarch sparc sparcv9 sparc64 make %{?_smp_mflags} BOOT_CFLAGS="$OPT_FLAGS" LDFLAGS_FOR_TARGET=-Wl,-z,relro,-z,now bootstrap %else -make %{?_smp_mflags} BOOT_CFLAGS="$OPT_FLAGS" LDFLAGS_FOR_TARGET=-Wl,-z,relro,-z,now profiledbootstrap +make %{?_smp_mflags} BOOT_CFLAGS="$OPT_FLAGS" LDFLAGS_FOR_TARGET=-Wl,-z,relro,-z,now bootstrap %endif CC="`%{gcc_target_platform}/libstdc++-v3/scripts/testsuite_flags --build-cc`" diff --git a/gcc12-declspec-keyword.patch b/gcc12-declspec-keyword.patch deleted file mode 100644 index 574790d..0000000 --- a/gcc12-declspec-keyword.patch +++ /dev/null @@ -1,38 +0,0 @@ -commit 078a9b4881cf93805b98b61bcf396a4143a611ab -Author: Florian Weimer -Date: Tue Nov 22 10:50:09 2022 +0100 - - Turn __declspec into a keyword - - This avoids diagnosing - - __declspec(thread) int foo; - - as an old-style function definition with an implicit int. - -diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc -index f08c89142e5..f5e875b27d3 100644 ---- a/gcc/c-family/c-common.cc -+++ b/gcc/c-family/c-common.cc -@@ -425,6 +425,7 @@ const struct c_common_resword c_common_reswords[] = - { "__GIMPLE", RID_GIMPLE, D_CONLY }, - { "__PHI", RID_PHI, D_CONLY }, - { "__RTL", RID_RTL, D_CONLY }, -+ { "__declspec", RID_DECLTYPE, D_CONLY }, - { "alignas", RID_ALIGNAS, D_C2X | D_CXX11 | D_CXXWARN }, - { "alignof", RID_ALIGNOF, D_C2X | D_CXX11 | D_CXXWARN }, - { "asm", RID_ASM, D_ASM }, -diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h -index f9d0d2945a5..6b3f66d3795 100644 ---- a/gcc/c-family/c-common.h -+++ b/gcc/c-family/c-common.h -@@ -136,6 +136,9 @@ enum rid - /* "__RTL", for the RTL-parsing extension to the C frontend. */ - RID_RTL, - -+ /* MSVC extension. */ -+ RID_DECLSPEC, -+ - /* C11 */ - RID_ALIGNAS, RID_GENERIC, - diff --git a/gcc12-implicits.patch b/gcc12-implicits.patch deleted file mode 100644 index 37fd4a3..0000000 --- a/gcc12-implicits.patch +++ /dev/null @@ -1,126 +0,0 @@ -commit e5e22f5c0b4a9189b1a6a98b15f73eac0490931e -Author: Florian Weimer -Date: Tue Oct 18 16:28:33 2022 +0200 - - Log implicit ints/implicit function declarations to /usr/lib/gcc/errors - - Only do so for C99 and later language modes, both features were part - of C89. - - The directory and the file name prefix for files within can be - controlled using the GCC_ERROR_LOG_DIRECTORY and GCC_ERROR_LOG_PREFIX - environment variables. - -diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc -index d76ffb3380d..2b5d9ae2c80 100644 ---- a/gcc/c/c-decl.cc -+++ b/gcc/c/c-decl.cc -@@ -3458,6 +3458,14 @@ pushdecl (tree x) - static void - implicit_decl_warning (location_t loc, tree id, tree olddecl) - { -+ if (flag_isoc99) -+ { -+ log_error_to_directory (loc, "implicit function declaration", -+ IDENTIFIER_POINTER (id)); -+ error_at (loc, "implicit declaration of function %qE", id); -+ return; -+ } -+ - if (!warn_implicit_function_declaration) - return; - -@@ -6695,7 +6703,15 @@ grokdeclarator (const struct c_declarator *declarator, - - /* Diagnose defaulting to "int". */ - -- if (declspecs->default_int_p && !in_system_header_at (input_location)) -+ if (declspecs->default_int_p && flag_isoc99) -+ { -+ log_error_to_directory (loc, "defaulting to int"); -+ if (name) -+ error_at (loc, "type defaults to % in declaration of %qE", name); -+ else -+ error_at (loc, "type defaults to % in type name"); -+ } -+ else if (declspecs->default_int_p && !in_system_header_at (input_location)) - { - /* Issue a warning if this is an ISO C 99 program or if - -Wreturn-type and this is a function, or if -Wimplicit; -@@ -10452,9 +10468,12 @@ store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info) - warn_if_shadowing (decl); - - if (flag_isoc99) -- pedwarn (DECL_SOURCE_LOCATION (decl), -- OPT_Wimplicit_int, "type of %qD defaults to %", -- decl); -+ { -+ log_error_to_directory (DECL_SOURCE_LOCATION (decl), -+ "type defaults to int"); -+ error_at (DECL_SOURCE_LOCATION (decl), -+ "type of %qD defaults to %", decl); -+ } - else - warning_at (DECL_SOURCE_LOCATION (decl), - OPT_Wmissing_parameter_type, -diff --git a/gcc/diagnostic.cc b/gcc/diagnostic.cc -index c90c14e993e..5d0f32a0e33 100644 ---- a/gcc/diagnostic.cc -+++ b/gcc/diagnostic.cc -@@ -2724,3 +2724,44 @@ c_diagnostic_cc_tests () - #if __GNUC__ >= 10 - # pragma GCC diagnostic pop - #endif -+ -+/* Magic code to emit diagnostics to a log directory. */ -+void -+log_error_to_directory (location_t loc, const char *message, -+ const char *identifier) -+{ -+ const char *magic_path = getenv ("GCC_ERROR_LOG_DIRECTORY"); -+ if (magic_path == nullptr) -+ magic_path = "/usr/lib/gcc/errors"; -+ -+ // Do not log anything if the directory does not exist. -+ if (access (magic_path, R_OK | W_OK | X_OK) < 0) -+ return; -+ -+ const char *log_prefix = getenv ("GCC_ERROR_LOG_PREFIX"); -+ if (log_prefix == nullptr) -+ log_prefix = "gcc"; -+ -+ char *templ = xasprintf ("%s/%sXXXXXX", magic_path, log_prefix); -+ int fd = mkstemp (templ); -+ if (fd < 0) -+ abort(); -+ -+ auto exploc = expand_location (loc); -+ const char *file = exploc.file; -+ if (file == nullptr) -+ file = ""; -+ char *formatted; -+ if (identifier != nullptr) -+ formatted = xasprintf ("%s:%d: %s: %s\n", -+ file, exploc.line, message, identifier); -+ else -+ formatted = xasprintf ("%s:%d: %s\n", file, exploc.line, message); -+ ssize_t len = strlen (formatted); -+ if (write (fd, formatted, len) != len -+ || close (fd) < 0) -+ abort (); -+ -+ free (formatted); -+ free (templ); -+} -diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h -index e20f6edfc81..05a82d2292a 100644 ---- a/gcc/diagnostic.h -+++ b/gcc/diagnostic.h -@@ -616,4 +616,7 @@ extern bool warning_enabled_at (location_t, int); - - extern char *get_cwe_url (int cwe); - -+void log_error_to_directory (location_t loc, const char *message, -+ const char *identifier = nullptr); -+ - #endif /* ! GCC_DIAGNOSTIC_H */ From f89f895a8eb74f425c2326830a7047e6edeac010 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Thu, 16 Nov 2023 05:21:23 +0100 Subject: [PATCH 14/21] Additional error suppression for missing function arguments --- gcc-error-logging.patch | 21 ++++++++++++++++++++- gcc.spec | 2 +- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/gcc-error-logging.patch b/gcc-error-logging.patch index 06421f3..acc2279 100644 --- a/gcc-error-logging.patch +++ b/gcc-error-logging.patch @@ -771,7 +771,7 @@ index 20b49a9d371..64b62572144 100644 } else -commit a266e38389e37233e1bcd05edeb72f5771f516c1 +commit e9630535fa88e36e95cf098436b87dce205638c6 Author: Florian Weimer Date: Wed Nov 15 09:53:33 2023 +0100 @@ -875,3 +875,22 @@ index 93724e38dea..1943c232e70 100644 tree guessed_id = lookup_field_fuzzy (constructor_type, fieldname); if (guessed_id) { + +commit 6b7d1a727cdd04b041df9ff0f2121e6103126093 +Author: Florian Weimer +Date: Thu Nov 16 05:20:15 2023 +0100 + + Additional logging suppression for missing function arguments + +diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc +index 1943c232e70..6d86d19f2d6 100644 +--- a/gcc/c/c-typeck.cc ++++ b/gcc/c/c-typeck.cc +@@ -3836,6 +3836,7 @@ convert_arguments (location_t loc, vec arg_loc, tree typelist, + + if (typetail != NULL_TREE && TREE_VALUE (typetail) != void_type_node) + { ++ suppress_error_logging (); + error_at (loc, "too few arguments to function %qE", function); + inform_declaration (fundecl); + return -1; diff --git a/gcc.spec b/gcc.spec index 9ed96dd..8d72cc2 100644 --- a/gcc.spec +++ b/gcc.spec @@ -136,7 +136,7 @@ Summary: Various compilers (C, C++, Objective-C, ...) Name: gcc Version: %{gcc_version} -Release: %{gcc_release}.implicits.7%{?dist} +Release: %{gcc_release}.implicits.8%{?dist} # libgcc, libgfortran, libgomp, libstdc++ and crtstuff have # GCC Runtime Exception. License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD From d0bcb56742c5bd78a083a8a71c5bf5e3f8c74f01 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Thu, 23 Nov 2023 18:59:48 +0100 Subject: [PATCH 15/21] Additional special case for strerror_r autoconf probes --- gcc-error-logging.patch | 24 ++++++++++++++++++++++++ gcc.spec | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/gcc-error-logging.patch b/gcc-error-logging.patch index acc2279..56c596a 100644 --- a/gcc-error-logging.patch +++ b/gcc-error-logging.patch @@ -894,3 +894,27 @@ index 1943c232e70..6d86d19f2d6 100644 error_at (loc, "too few arguments to function %qE", function); inform_declaration (fundecl); return -1; + +commit 4bba0655b19ec541644150ac18553089a19c5b18 +Author: Florian Weimer +Date: Thu Nov 23 18:43:16 2023 +0100 + + Special case for strerror_r autoconf checks + +diff --git a/gcc/c-family/c-warn.cc b/gcc/c-family/c-warn.cc +index 9ac43a1af6e..a0989e3d4d7 100644 +--- a/gcc/c-family/c-warn.cc ++++ b/gcc/c-family/c-warn.cc +@@ -1952,6 +1952,12 @@ invalid_indirection_error (location_t loc, tree type, ref_operator errstring) + type); + break; + case RO_UNARY_STAR: ++ /* It does not matter that the operand is not a pointer because ++ of an implicit function declaration. The non-instrumented ++ compiler fails in that case, too. This means that there is ++ no need to log past and future errors. This is relevant to ++ strerror_r return type autoconf checks. */ ++ suppress_error_logging (); + error_at (loc, + "invalid type argument of unary %<*%> (have %qT)", + type); diff --git a/gcc.spec b/gcc.spec index 8d72cc2..4702bd8 100644 --- a/gcc.spec +++ b/gcc.spec @@ -136,7 +136,7 @@ Summary: Various compilers (C, C++, Objective-C, ...) Name: gcc Version: %{gcc_version} -Release: %{gcc_release}.implicits.8%{?dist} +Release: %{gcc_release}.implicits.8%{?dist}.1 # libgcc, libgfortran, libgomp, libstdc++ and crtstuff have # GCC Runtime Exception. License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD From 1e6e45ec00c6f13a2dd33235d10b36e4ddfdfdb0 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Tue, 28 Nov 2023 20:30:49 +0100 Subject: [PATCH 16/21] Additional error logging suppression --- gcc.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc.spec b/gcc.spec index 4702bd8..ab3d83c 100644 --- a/gcc.spec +++ b/gcc.spec @@ -136,7 +136,7 @@ Summary: Various compilers (C, C++, Objective-C, ...) Name: gcc Version: %{gcc_version} -Release: %{gcc_release}.implicits.8%{?dist}.1 +Release: %{gcc_release}.implicits.8%{?dist}.2 # libgcc, libgfortran, libgomp, libstdc++ and crtstuff have # GCC Runtime Exception. License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD From a18fa763f95fbe1625aa9eb5f1991b1b470290fb Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Tue, 28 Nov 2023 21:26:12 +0100 Subject: [PATCH 17/21] Actually commit patch change --- gcc-error-logging.patch | 49 +++++++++++++++++++++++++++++++++++++++++ gcc.spec | 2 +- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/gcc-error-logging.patch b/gcc-error-logging.patch index 56c596a..ff5d12e 100644 --- a/gcc-error-logging.patch +++ b/gcc-error-logging.patch @@ -918,3 +918,52 @@ index 9ac43a1af6e..a0989e3d4d7 100644 error_at (loc, "invalid type argument of unary %<*%> (have %qT)", type); + +commit 1f77edaa6bbec12a28a14a24ba9728e72f70d534 +Author: Florian Weimer +Date: Tue Nov 28 20:23:23 2023 +0100 + + Suppress error logging in case of unknown type errors + + These always happen with the non-instrumented compiler as well. + + Helps with this autoconf probe: + + configure:23354: gcc -o conftest -g -O2 -Wl,--as-needed conftest.c >&5 + conftest.c:63:40: error: unknown type name 'off64_t'; did you mean 'off_t'? + 63 | int fseeko64(FILE *stream, off64_t offset, int whence); + | ^~~~~~~ + | off_t + conftest.c: In function 'main': + conftest.c:69:24: error: implicit declaration of function 'fseeko64' + 69 | return fseeko64(stream, 256lu, 0); + | ^~~~~~~~ + + Code fragment: + + | #include + | #include + | #include + | + | #if !HAVE_DECL_FSEEKO64 + | int fseeko64(FILE *stream, off64_t offset, int whence); + | #endif + | + | int main() + | { + | FILE* stream; + | return fseeko64(stream, 256lu, 0); + | } + +diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc +index 3627a3fbdc7..2904b7bbf69 100644 +--- a/gcc/c/c-parser.cc ++++ b/gcc/c/c-parser.cc +@@ -2123,6 +2123,7 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok, + with some kind of hint. + If the user forgot a "struct" etc, suggest inserting + it. Otherwise, attempt to look for misspellings. */ ++ suppress_error_logging (); + gcc_rich_location richloc (here); + if (tag_exists_p (RECORD_TYPE, name)) + { diff --git a/gcc.spec b/gcc.spec index ab3d83c..4fb6369 100644 --- a/gcc.spec +++ b/gcc.spec @@ -136,7 +136,7 @@ Summary: Various compilers (C, C++, Objective-C, ...) Name: gcc Version: %{gcc_version} -Release: %{gcc_release}.implicits.8%{?dist}.2 +Release: %{gcc_release}.implicits.8%{?dist}.3 # libgcc, libgfortran, libgomp, libstdc++ and crtstuff have # GCC Runtime Exception. License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD From fd5541b8dfcd1f30b332d20edec2bb8ed4fed2d1 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Wed, 29 Nov 2023 09:39:20 +0100 Subject: [PATCH 18/21] More error logging suppression on type errors --- gcc-error-logging.patch | 27 +++++++++++++++++++++++++++ gcc.spec | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/gcc-error-logging.patch b/gcc-error-logging.patch index ff5d12e..7458eac 100644 --- a/gcc-error-logging.patch +++ b/gcc-error-logging.patch @@ -967,3 +967,30 @@ index 3627a3fbdc7..2904b7bbf69 100644 gcc_rich_location richloc (here); if (tag_exists_p (RECORD_TYPE, name)) { + +commit 3be96dbe1dfd2c99cf5e3dbf993db89321839a8f +Author: Florian Weimer +Date: Wed Nov 29 09:34:43 2023 +0100 + + Add error suppression for more unknown type names + +diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc +index 2904b7bbf69..f74434ca04c 100644 +--- a/gcc/c/c-parser.cc ++++ b/gcc/c/c-parser.cc +@@ -3180,6 +3180,7 @@ c_parser_declspecs (c_parser *parser, struct c_declspecs *specs, + attrs_ok = true; + if (kind == C_ID_ID) + { ++ suppress_error_logging (); + error_at (loc, "unknown type name %qE", value); + t.kind = ctsk_typedef; + t.spec = error_mark_node; +@@ -4804,6 +4805,7 @@ c_parser_parameter_declaration (c_parser *parser, tree attrs, + c_parser_set_source_position_from_token (token); + if (c_parser_next_tokens_start_typename (parser, cla_prefer_type)) + { ++ suppress_error_logging (); + auto_diagnostic_group d; + name_hint hint = lookup_name_fuzzy (token->value, + FUZZY_LOOKUP_TYPENAME, diff --git a/gcc.spec b/gcc.spec index 4fb6369..41a3c6f 100644 --- a/gcc.spec +++ b/gcc.spec @@ -136,7 +136,7 @@ Summary: Various compilers (C, C++, Objective-C, ...) Name: gcc Version: %{gcc_version} -Release: %{gcc_release}.implicits.8%{?dist}.3 +Release: %{gcc_release}.implicits.8%{?dist}.4 # libgcc, libgfortran, libgomp, libstdc++ and crtstuff have # GCC Runtime Exception. License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD From 6d625ad409ed5f330df7d0d7d18a375e89a70695 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Wed, 29 Nov 2023 11:44:13 +0100 Subject: [PATCH 19/21] Suppress error logging if unknown struct types are encountered --- gcc-error-logging.patch | 35 +++++++++++++++++++++++++++++++++++ gcc.spec | 2 +- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/gcc-error-logging.patch b/gcc-error-logging.patch index 7458eac..74ba50a 100644 --- a/gcc-error-logging.patch +++ b/gcc-error-logging.patch @@ -994,3 +994,38 @@ index 2904b7bbf69..f74434ca04c 100644 auto_diagnostic_group d; name_hint hint = lookup_name_fuzzy (token->value, FUZZY_LOOKUP_TYPENAME, + +commit 16d065b3ce04278001d03d3fd38f01fd71ec8c2d +Author: Florian Weimer +Date: Wed Nov 29 11:43:19 2023 +0100 + + Suppress error logging if unknown struct types are encountered + +diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc +index dafa70435c1..6f1f33f34e8 100644 +--- a/gcc/c/c-decl.cc ++++ b/gcc/c/c-decl.cc +@@ -5732,6 +5732,7 @@ finish_decl (tree decl, location_t init_loc, tree init, + is an error. */ + : !DECL_EXTERNAL (decl))) + { ++ suppress_error_logging (); + error ("storage size of %q+D isn%'t known", decl); + TREE_TYPE (decl) = error_mark_node; + } +diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc +index f74434ca04c..2d57acf17f8 100644 +--- a/gcc/c/c-parser.cc ++++ b/gcc/c/c-parser.cc +@@ -1786,7 +1786,10 @@ c_parser_translation_unit (c_parser *parser) + tree decl; + FOR_EACH_VEC_ELT (incomplete_record_decls, i, decl) + if (DECL_SIZE (decl) == NULL_TREE && TREE_TYPE (decl) != error_mark_node) +- error ("storage size of %q+D isn%'t known", decl); ++ { ++ suppress_error_logging (); ++ error ("storage size of %q+D isn%'t known", decl); ++ } + + if (vec_safe_length (current_omp_declare_target_attribute)) + { diff --git a/gcc.spec b/gcc.spec index 41a3c6f..7618c1d 100644 --- a/gcc.spec +++ b/gcc.spec @@ -136,7 +136,7 @@ Summary: Various compilers (C, C++, Objective-C, ...) Name: gcc Version: %{gcc_version} -Release: %{gcc_release}.implicits.8%{?dist}.4 +Release: %{gcc_release}.implicits.8%{?dist}.5 # libgcc, libgfortran, libgomp, libstdc++ and crtstuff have # GCC Runtime Exception. License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD From adc89608c04e5ba3590f8b5c398c90370e25f517 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Thu, 7 Dec 2023 13:16:38 +0100 Subject: [PATCH 20/21] Add more logging suppression in case of too many function arguments --- gcc-error-logging.patch | 19 +++++++++++++++++++ gcc.spec | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/gcc-error-logging.patch b/gcc-error-logging.patch index 74ba50a..5101c7a 100644 --- a/gcc-error-logging.patch +++ b/gcc-error-logging.patch @@ -1029,3 +1029,22 @@ index f74434ca04c..2d57acf17f8 100644 if (vec_safe_length (current_omp_declare_target_attribute)) { + +commit a686be614951b191446781a436aecad849dab38c +Author: Florian Weimer +Date: Thu Nov 30 13:34:46 2023 +0100 + + Add more logging suppression in case of too many function arguments + +diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc +index 6d86d19f2d6..37dc18fb420 100644 +--- a/gcc/c/c-typeck.cc ++++ b/gcc/c/c-typeck.cc +@@ -3694,6 +3694,7 @@ convert_arguments (location_t loc, vec arg_loc, tree typelist, + + if (type == void_type_node) + { ++ suppress_error_logging (); + if (selector) + error_at (loc, "too many arguments to method %qE", selector); + else diff --git a/gcc.spec b/gcc.spec index cc380a3..fa9061c 100644 --- a/gcc.spec +++ b/gcc.spec @@ -136,7 +136,7 @@ Summary: Various compilers (C, C++, Objective-C, ...) Name: gcc Version: %{gcc_version} -Release: %{gcc_release}.implicits.8%{?dist}.5 +Release: %{gcc_release}.implicits.8%{?dist}.6 # libgcc, libgfortran, libgomp, libstdc++ and crtstuff have # GCC Runtime Exception. License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD From 07a94645051b06528dbdd57829f2e505f394ade7 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Thu, 7 Dec 2023 15:52:39 +0100 Subject: [PATCH 21/21] Backport aarch64 C compatiblity fixes --- gcc-error-logging.patch | 63 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/gcc-error-logging.patch b/gcc-error-logging.patch index 5101c7a..4560407 100644 --- a/gcc-error-logging.patch +++ b/gcc-error-logging.patch @@ -1048,3 +1048,66 @@ index 6d86d19f2d6..37dc18fb420 100644 if (selector) error_at (loc, "too many arguments to method %qE", selector); else + +commit 5dccd006bf4e60ba843a9edda3bed230a59ae51f +Author: Pekka Seppänen +Date: Wed Sep 20 19:41:01 2023 +0100 + + aarch64: Ensure const and sign correctness + + Be const and sign correct by using a matching CIE augmentation type. + Use a builtin instead of relying being included. + + libgcc/ChangeLog: + + * config/aarch64/aarch64-unwind.h (aarch64_cie_signed_with_b_key): + Use const unsigned type and a builtin. + + Signed-off-by: Pekka Seppänen + (cherry picked from commit 0a59ff65df6da8267efb5c97dead8cd0dcd5b445) + +diff --git a/libgcc/config/aarch64/aarch64-unwind.h b/libgcc/config/aarch64/aarch64-unwind.h +index 3ad2f8239ed..d669edd671b 100644 +--- a/libgcc/config/aarch64/aarch64-unwind.h ++++ b/libgcc/config/aarch64/aarch64-unwind.h +@@ -40,8 +40,9 @@ aarch64_cie_signed_with_b_key (struct _Unwind_Context *context) + const struct dwarf_cie *cie = get_cie (fde); + if (cie != NULL) + { +- char *aug_str = cie->augmentation; +- return strchr (aug_str, 'B') == NULL ? 0 : 1; ++ const unsigned char *aug_str = cie->augmentation; ++ return __builtin_strchr ((const char *) aug_str, ++ 'B') == NULL ? 0 : 1; + } + } + return 0; + +commit 91768f20003d28cf1adf8d9ed6318dd4396efaf3 +Author: Florian Weimer +Date: Fri Dec 1 08:10:12 2023 +0100 + + aarch64: Avoid -Wincompatible-pointer-types warning in Linux unwinder + + * config/aarch64/linux-unwind.h + (aarch64_fallback_frame_state): Add cast to the expected type + in sc assignment. + + (cherry picked from commit 335bd6c938c254e3ae4b019cfc8a94bb8009ca81) + +diff --git a/libgcc/config/aarch64/linux-unwind.h b/libgcc/config/aarch64/linux-unwind.h +index 00eba866049..18b3df71e7b 100644 +--- a/libgcc/config/aarch64/linux-unwind.h ++++ b/libgcc/config/aarch64/linux-unwind.h +@@ -77,7 +77,10 @@ aarch64_fallback_frame_state (struct _Unwind_Context *context, + } + + rt_ = context->cfa; +- sc = &rt_->uc.uc_mcontext; ++ /* Historically, the uc_mcontext member was of type struct sigcontext, but ++ glibc uses a different type now with member names in the implementation ++ namespace. */ ++ sc = (struct sigcontext *) &rt_->uc.uc_mcontext; + + /* This define duplicates the definition in aarch64.md */ + #define SP_REGNUM 31