[gcc(refs/users/marxin/heads/lto-plugin-cleanup)] Port to CPP.

Martin Liska marxin@gcc.gnu.org
Thu Jan 6 11:22:43 GMT 2022


https://gcc.gnu.org/g:c9dbe065a6c11f5d101e62c7f55eaad43c1aa0f7

commit c9dbe065a6c11f5d101e62c7f55eaad43c1aa0f7
Author: Martin Liska <mliska@suse.cz>
Date:   Wed Jan 5 14:06:08 2022 +0100

    Port to CPP.

Diff:
---
 lto-plugin/Makefile.am                     |  8 ++++----
 lto-plugin/configure.ac                    |  1 +
 lto-plugin/{lto-plugin.c => lto-plugin.cc} | 12 ++++++++++++
 3 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/lto-plugin/Makefile.am b/lto-plugin/Makefile.am
index 988d7a78294..d0c980a2024 100644
--- a/lto-plugin/Makefile.am
+++ b/lto-plugin/Makefile.am
@@ -11,14 +11,14 @@ AM_CPPFLAGS = -I$(top_srcdir)/../include $(DEFS)
 AM_CFLAGS = @ac_lto_plugin_warn_cflags@ $(CET_HOST_FLAGS)
 AM_LDFLAGS = @ac_lto_plugin_ldflags@
 AM_LIBTOOLFLAGS = --tag=disable-static
-override CFLAGS := $(filter-out -fsanitize=address -fsanitize=hwaddress,$(CFLAGS))
-override LDFLAGS := $(filter-out -fsanitize=address -fsanitize=hwaddress,$(LDFLAGS))
+override CXXFLAGS := $(filter-out -fsanitize=address -fsanitize=hwaddress,$(CXXFLAGS))
+override LDFLAGS := $(filter-out -fsanitize=address -fsanitize=hwaddress,$(LDFLAGS)) -lstdc++
 
 libexecsub_LTLIBRARIES = liblto_plugin.la
 gcc_build_dir = @gcc_build_dir@
 in_gcc_libs = $(foreach lib, $(libexecsub_LTLIBRARIES), $(gcc_build_dir)/$(lib))
 
-liblto_plugin_la_SOURCES = lto-plugin.c
+liblto_plugin_la_SOURCES = lto-plugin.cc
 # Note that we intentionally override the bindir supplied by ACX_LT_HOST_FLAGS.
 liblto_plugin_la_LDFLAGS = $(AM_LDFLAGS) \
 	$(lt_host_flags) -module -avoid-version -bindir $(libexecsubdir) \
@@ -39,7 +39,7 @@ liblto_plugin_la_DEPENDENCIES = \
 	$(if $(wildcard $(libiberty_pic)),$(libiberty_pic),))
 LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
 liblto_plugin_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(liblto_plugin_la_LDFLAGS) $(LTLDFLAGS) -o $@
 
 all-local: $(in_gcc_libs)
diff --git a/lto-plugin/configure.ac b/lto-plugin/configure.ac
index 7e6f729e9dc..9aa6cfd5794 100644
--- a/lto-plugin/configure.ac
+++ b/lto-plugin/configure.ac
@@ -10,6 +10,7 @@ AC_ARG_WITH(libiberty,
 AC_SUBST(with_libiberty)
 AC_USE_SYSTEM_EXTENSIONS
 AC_PROG_CC
+AC_PROG_CXX
 AC_SYS_LARGEFILE
 ACX_PROG_CC_WARNING_OPTS([-Wall], [ac_lto_plugin_warn_cflags])
 
diff --git a/lto-plugin/lto-plugin.c b/lto-plugin/lto-plugin.cc
similarity index 99%
rename from lto-plugin/lto-plugin.c
rename to lto-plugin/lto-plugin.cc
index 51e0b4ded43..f80d69d0725 100644
--- a/lto-plugin/lto-plugin.c
+++ b/lto-plugin/lto-plugin.cc
@@ -64,7 +64,11 @@ along with this program; see the file COPYING3.  If not see
 #ifndef WEXITSTATUS
 #define WEXITSTATUS(S) (((S) & 0xff00) >> 8)
 #endif
+
+/* Defined in string.h */
+#define HAVE_DECL_BASENAME 1
 #include <libiberty.h>
+
 #include <hashtab.h>
 #include "../gcc/lto/common.h"
 #include "simple-object.h"
@@ -1368,6 +1372,10 @@ process_option (const char *option)
   verbose = verbose || debug;
 }
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Called by gold after loading the plugin. TV is the transfer vector. */
 
 enum ld_plugin_status
@@ -1540,3 +1548,7 @@ onload (struct ld_plugin_tv *tv)
 
   return LDPS_OK;
 }
+
+#ifdef __cplusplus
+}
+#endif


More information about the Gcc-cvs mailing list