]> git.puffer.fish Git - mirror/frr.git/commitdiff
tools/gcc-plugins: fix for GCC 13 14346/head
authorDavid Lamparter <equinox@opensourcerouting.org>
Sun, 3 Sep 2023 20:56:57 +0000 (22:56 +0200)
committerDavid Lamparter <equinox@opensourcerouting.org>
Mon, 4 Sep 2023 10:16:48 +0000 (12:16 +0200)
As usual, new GCC version, new small random changes in the API.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
tools/gcc-plugins/Makefile
tools/gcc-plugins/frr-format.c
tools/gcc-plugins/gcc-common.h

index d6edd745cecd5dba5bb85d3adaa3706184364497..2af28fe2b19117c4d47d22b1d15a37fbf48e997c 100644 (file)
@@ -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)
index 2240a171b40e2c4be0d27c10a28b3c293a835aad..a5418e5357d3d173f75e6a1e19635aba7ba65c85 100644 (file)
@@ -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:
index 9f59447d63347840aa5f61b1ec0e420954f0fe4c..6eaea9bf74db177234416d00a3d97c6b30b71c35 100644 (file)
 #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"