]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/build] Work around GCC ipa-modref bug
authorTom de Vries <tdevries@suse.de>
Sun, 13 Jul 2025 05:25:43 +0000 (07:25 +0200)
committerTom de Vries <tdevries@suse.de>
Sun, 13 Jul 2025 05:25:43 +0000 (07:25 +0200)
PR mi/32571 reports the following problem:
...
$ gdb -q -batch -ex "b bla.c:100"
<random output>
Make breakpoint pending on future shared library load? (y or [n]) \
  [answered N; input not from terminal]
...
while this is expected:
...
$ gdb -q -batch -ex "b bla.c:100"
No symbol table is loaded.  Use the "file" command.
Make breakpoint pending on future shared library load? (y or [n]) \
  [answered N; input not from terminal]
...

A few factors in reproducing this are building gdb using gcc 14,
"-O2 -flto=auto" and --disable-nls.  For more details, see the PR.

This turns out to be caused by a GCC PR [1], more specifically a problem in
ipa-modref.

Work around this by disabling ipa-modref for GCC versions 12-15 and 16.0,
assuming the GCC 16.1 release will contain a fix.

Tested on aarch64-linux and x86_64-linux.

Approved-By: Andrew Burgess <aburgess@redhat.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32571

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120987

gdbsupport/common-defs.h

index 07caf3bd7e4a8cbd56b79b8d555161094cc45b03..cfdefe19ce0f61644853b291e4de88e92b87f6ee 100644 (file)
 #pragma GCC optimize("-fno-hoist-adjacent-loads")
 #endif
 
+#if defined (__GNUC__) && !defined (__clang__) \
+  && ((__GNUC__ >= 12 && __GNUC__ <= 15)       \
+      || (__GNUC__ == 16 && __GNUC_MINOR__ < 1))
+/* Work around PR gcc/120987 starting gcc 12, and assume it will be fixed in
+   the gcc 16.1 release.  */
+#pragma GCC optimize("-fno-ipa-modref")
+#endif
+
 #include <gdbsupport/config.h>
 
 #undef PACKAGE_NAME