gcc4ti
gcc4ti copied to clipboard
Build failures with gcc 9 / Fedora 32: cgraph_node not defined as a type
It looks like there's a problem building the old version of gcc with gcc 9.1+, currently the version in Fedora Rawhide:
../../../download/gcc.ti/gcc/pretty-print.h: At top level:
../../../download/gcc.ti/gcc/pretty-print.h:310:6: error: 'cgraph_node' is not defined as a type
310 | ATTRIBUTE_GCC_PPDIAG(2,3);
| ^~~~~~~~~~~~~~~~~~~~
../../../download/gcc.ti/gcc/pretty-print.h:313:6: error: 'cgraph_node' is not defined as a type
313 | ATTRIBUTE_GCC_PPDIAG(2,3);
| ^~~~~~~~~~~~~~~~~~~~
This was reported upstream here.
It looks like this is also a problem in gcc/toplev.h
since the macro is redefined there, too.
And gcc/c-tree.h
.
After some trial and error I got things to build with the following patch, applied after (or part of, I guess) Install_step_1.
--- a/gcc/pretty-print.h
+++ b/gcc/pretty-print.h
@@ -305,7 +305,7 @@ extern void pp_base_append_text (pretty_printer *, const char *, const char *);
/* This header may be included before diagnostics-core.h, hence the duplicate
definitions to allow for GCC-specific formats. */
-#if GCC_VERSION >= 3005
+#if (GCC_VERSION >= 3005) && (GCC_VERSION < 9001) /* 9.1.0 and 9.2.0 are buggy: https://gcc.gnu.org/PR90677 */
#define ATTRIBUTE_GCC_PPDIAG(m, n) __attribute__ ((__format__ (__gcc_diag__, m ,n))) ATTRIBUTE_NONNULL(m)
#else
#define ATTRIBUTE_GCC_PPDIAG(m, n) ATTRIBUTE_NONNULL(m)
--- a/gcc/toplev.h
+++ b/gcc/toplev.h
@@ -49,7 +49,7 @@ extern void _fatal_insn (const char *, r
/* None of these functions are suitable for ATTRIBUTE_PRINTF, because
each language front end can extend them with its own set of format
specifiers. We must use custom format checks. */
-#if GCC_VERSION >= 4001
+#if GCC_VERSION >= 4001 && (GCC_VERSION < 9001)
#define ATTRIBUTE_GCC_DIAG(m, n) __attribute__ ((__format__ (GCC_DIAG_STYLE, m, n))) ATTRIBUTE_NONNULL(m)
#else
#define ATTRIBUTE_GCC_DIAG(m, n) ATTRIBUTE_NONNULL(m)
--- a/gcc/c-tree.h
+++ b/gcc/c-tree.h
@@ -613,7 +613,7 @@ extern void c_write_global_declarations
/* In order for the format checking to accept the C frontend
diagnostic framework extensions, you must include this file before
toplev.h, not after. */
-#if GCC_VERSION >= 4001
+#if GCC_VERSION >= 4001 && (GCC_VERSION < 9001)
#define ATTRIBUTE_GCC_CDIAG(m, n) __attribute__ ((__format__ (GCC_DIAG_STYLE, m ,n))) ATTRIBUTE_NONNULL(m)
#else
#define ATTRIBUTE_GCC_CDIAG(m, n) ATTRIBUTE_NONNULL(m)
Given that GCC 9.3 and 10 contain fixes for the GCC bugs, (GCC_VERSION < 9001)
should read something long the lines of ((GCC_VERSION < 9001) || (GCC_VERSION >= 9003))
. However, given that fixed 9.x versions are available, people shouldn't be using the buggy versions anyway... so let's just do nothing ? :)