summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2023-09-03 22:56:57 +0200
committerDavid Lamparter <equinox@opensourcerouting.org>2023-09-04 12:16:48 +0200
commit2821d3b91b5145a848eee00d7134c12b45be10f6 (patch)
tree7febffbc1f5de6554140d05ad8a50130e6592e2c /tools
parent640b59a8b0d87337fef336950e7ebf94a3344a7f (diff)
tools/gcc-plugins: fix for GCC 13
As usual, new GCC version, new small random changes in the API. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/gcc-plugins/Makefile8
-rw-r--r--tools/gcc-plugins/frr-format.c19
-rw-r--r--tools/gcc-plugins/gcc-common.h4
3 files changed, 23 insertions, 8 deletions
diff --git a/tools/gcc-plugins/Makefile b/tools/gcc-plugins/Makefile
index d6edd745ce..2af28fe2b1 100644
--- a/tools/gcc-plugins/Makefile
+++ b/tools/gcc-plugins/Makefile
@@ -5,11 +5,15 @@ CXX=g++-9
PLUGBASE=`$(CXX) -print-file-name=plugin`
CPPFLAGS=-I$(PLUGBASE)/include -I$(PLUGBASE)/include/c-family
+# NB: compiler flags must match those used to build gcc, otherwise inlining
+# behavior is different and linker errors will result due to missing symbols
+# (which should in fact be inlined)
+
frr-format.so: frr-format.o
- $(CXX) -g -shared -o $@ $^
+ $(CXX) -fno-rtti -fno-exceptions -fasynchronous-unwind-tables -ggdb -shared -o $@ $^
frr-format.o: frr-format.c gcc-common.h
- $(CXX) -g $(CPPFLAGS) -fPIC -Wall -Wextra -Wno-unused-parameter -c -o $@ $<
+ $(CXX) -fno-rtti -fno-exceptions -fasynchronous-unwind-tables -ggdb $(CPPFLAGS) -fPIC -Wall -Wextra -Wno-unused-parameter -c -o $@ $<
install:
install -d $(DESTDIR)$(PLUGBASE)
diff --git a/tools/gcc-plugins/frr-format.c b/tools/gcc-plugins/frr-format.c
index 2240a171b4..a5418e5357 100644
--- a/tools/gcc-plugins/frr-format.c
+++ b/tools/gcc-plugins/frr-format.c
@@ -3464,7 +3464,7 @@ class frr_range_label_for_type_mismatch : public range_label
{
}
- label_text get_text (unsigned range_idx) const OVERRIDE;
+ label_text get_text (unsigned range_idx) const override;
protected:
tree m_labelled_type;
@@ -3564,19 +3564,26 @@ class range_label_for_format_type_mismatch
{
}
- label_text get_text (unsigned range_idx) const FINAL OVERRIDE
+#if BUILDING_GCC_VERSION >= 13000
+#define text_get(text) text.get()
+#define text_return(text, result) return label_text::take(result)
+#else
+#define text_get(text) text.m_buffer
+#define text_return(text, result) text.maybe_free(); return label_take(result)
+#endif
+
+ label_text get_text (unsigned range_idx) const final override
{
label_text text = range_label_for_type_mismatch::get_text (range_idx);
- if (text.m_buffer == NULL)
+ if (text_get(text) == NULL)
return text;
indirection_suffix suffix (m_pointer_count);
char *p = (char *) alloca (suffix.get_buffer_size ());
suffix.fill_buffer (p);
- char *result = concat (text.m_buffer, p, NULL);
- text.maybe_free ();
- return label_take(result);
+ char *result = concat (text_get(text), p, NULL);
+ text_return(text, result);
}
private:
diff --git a/tools/gcc-plugins/gcc-common.h b/tools/gcc-plugins/gcc-common.h
index 9f59447d63..6eaea9bf74 100644
--- a/tools/gcc-plugins/gcc-common.h
+++ b/tools/gcc-plugins/gcc-common.h
@@ -111,6 +111,10 @@
#include "varasm.h"
#include "stor-layout.h"
#include "internal-fn.h"
+#if BUILDING_GCC_VERSION >= 13000
+#include "gimple.h"
+#include "gimple-iterator.h"
+#endif
#include "gimple-expr.h"
#include "gimple-fold.h"
#include "context.h"