public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/marxin/heads/lto-plugin-add-LDPT_PLUGIN_VERSION)] lto-plugin: add LDPT_PLUGIN_VERSION
@ 2022-02-28 14:48 Martin Liska
  0 siblings, 0 replies; 2+ messages in thread
From: Martin Liska @ 2022-02-28 14:48 UTC (permalink / raw)
  To: gcc-cvs

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

commit a02b6d527b2183240b170da2f29d1c389901df61
Author: Martin Liska <mliska@suse.cz>
Date:   Mon Feb 28 15:47:08 2022 +0100

    lto-plugin: add LDPT_PLUGIN_VERSION
    
    include/ChangeLog:
    
            * plugin-api.h (enum ld_plugin_tag): Add LDPT_PLUGIN_VERSION.
            (struct ld_plugin_tv): Add tv_plugin_version.
    
    lto-plugin/ChangeLog:
    
            * lto-plugin.c (onload): Call tv_plugin_version in onload.

Diff:
---
 include/plugin-api.h    | 11 ++++++++++-
 lto-plugin/lto-plugin.c |  4 ++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/include/plugin-api.h b/include/plugin-api.h
index 4e12c0320d6..4302b5fb3fc 100644
--- a/include/plugin-api.h
+++ b/include/plugin-api.h
@@ -475,6 +475,13 @@ enum ld_plugin_status
 (*ld_plugin_get_wrap_symbols) (uint64_t *num_symbols,
                                const char ***wrap_symbol_list);
 
+/* The linker's interface for registering the "plugin_version" handler.
+   This handler is called directly after onload and provides identifier
+   and version of a compiler plug-in (e.g. GCC 12.0.1 20220228).  */
+
+typedef
+void (*ld_plugin_version) (const char *version);
+
 enum ld_plugin_level
 {
   LDPL_INFO,
@@ -520,7 +527,8 @@ enum ld_plugin_tag
   LDPT_GET_INPUT_SECTION_SIZE = 30,
   LDPT_REGISTER_NEW_INPUT_HOOK = 31,
   LDPT_GET_WRAP_SYMBOLS = 32,
-  LDPT_ADD_SYMBOLS_V2 = 33
+  LDPT_ADD_SYMBOLS_V2 = 33,
+  LDPT_PLUGIN_VERSION = 34,
 };
 
 /* The plugin transfer vector.  */
@@ -556,6 +564,7 @@ struct ld_plugin_tv
     ld_plugin_get_input_section_size tv_get_input_section_size;
     ld_plugin_register_new_input tv_register_new_input;
     ld_plugin_get_wrap_symbols tv_get_wrap_symbols;
+    ld_plugin_version tv_plugin_version;
   } tv_u;
 };
 
diff --git a/lto-plugin/lto-plugin.c b/lto-plugin/lto-plugin.c
index c9c048d3631..5ffe73b3441 100644
--- a/lto-plugin/lto-plugin.c
+++ b/lto-plugin/lto-plugin.c
@@ -67,6 +67,7 @@ along with this program; see the file COPYING3.  If not see
 #include <libiberty.h>
 #include <hashtab.h>
 #include "../gcc/lto/common.h"
+#include "../gcc/version.h"
 #include "simple-object.h"
 #include "plugin-api.h"
 
@@ -1431,6 +1432,9 @@ onload (struct ld_plugin_tv *tv)
 	  /* We only use this to make user-friendly temp file names.  */
 	  link_output_name = p->tv_u.tv_string;
 	  break;
+	case LDPT_PLUGIN_VERSION:
+	  p->tv_u.tv_plugin_version ("GCC " version_string);
+	  break;
 	default:
 	  break;
 	}


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [gcc(refs/users/marxin/heads/lto-plugin-add-LDPT_PLUGIN_VERSION)] lto-plugin: add LDPT_PLUGIN_VERSION
@ 2022-02-28 15:08 Martin Liska
  0 siblings, 0 replies; 2+ messages in thread
From: Martin Liska @ 2022-02-28 15:08 UTC (permalink / raw)
  To: gcc-cvs

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

commit ef2371c232156e680fea028565dee0e0cf69db49
Author: Martin Liska <mliska@suse.cz>
Date:   Mon Feb 28 15:47:08 2022 +0100

    lto-plugin: add LDPT_PLUGIN_VERSION
    
    include/ChangeLog:
    
            * plugin-api.h (enum ld_plugin_tag): Add LDPT_PLUGIN_VERSION.
            (struct ld_plugin_tv): Add tv_plugin_version.
    
    lto-plugin/ChangeLog:
    
            * lto-plugin.c (onload): Call tv_plugin_version in onload.
            * Makefile.am: Pass -DGCC_COMPILER_VERSION macro.
            * Makefile.in: Re-generate.

Diff:
---
 include/plugin-api.h    | 11 ++++++++++-
 lto-plugin/Makefile.am  |  1 +
 lto-plugin/Makefile.in  | 11 +++++++----
 lto-plugin/lto-plugin.c |  7 ++++++-
 4 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/include/plugin-api.h b/include/plugin-api.h
index 4e12c0320d6..4302b5fb3fc 100644
--- a/include/plugin-api.h
+++ b/include/plugin-api.h
@@ -475,6 +475,13 @@ enum ld_plugin_status
 (*ld_plugin_get_wrap_symbols) (uint64_t *num_symbols,
                                const char ***wrap_symbol_list);
 
+/* The linker's interface for registering the "plugin_version" handler.
+   This handler is called directly after onload and provides identifier
+   and version of a compiler plug-in (e.g. GCC 12.0.1 20220228).  */
+
+typedef
+void (*ld_plugin_version) (const char *version);
+
 enum ld_plugin_level
 {
   LDPL_INFO,
@@ -520,7 +527,8 @@ enum ld_plugin_tag
   LDPT_GET_INPUT_SECTION_SIZE = 30,
   LDPT_REGISTER_NEW_INPUT_HOOK = 31,
   LDPT_GET_WRAP_SYMBOLS = 32,
-  LDPT_ADD_SYMBOLS_V2 = 33
+  LDPT_ADD_SYMBOLS_V2 = 33,
+  LDPT_PLUGIN_VERSION = 34,
 };
 
 /* The plugin transfer vector.  */
@@ -556,6 +564,7 @@ struct ld_plugin_tv
     ld_plugin_get_input_section_size tv_get_input_section_size;
     ld_plugin_register_new_input tv_register_new_input;
     ld_plugin_get_wrap_symbols tv_get_wrap_symbols;
+    ld_plugin_version tv_plugin_version;
   } tv_u;
 };
 
diff --git a/lto-plugin/Makefile.am b/lto-plugin/Makefile.am
index 988d7a78294..e04c703bfca 100644
--- a/lto-plugin/Makefile.am
+++ b/lto-plugin/Makefile.am
@@ -19,6 +19,7 @@ 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_CFLAGS = -DGCC_COMPILER_VERSION=${gcc_version}
 # 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) \
diff --git a/lto-plugin/Makefile.in b/lto-plugin/Makefile.in
index f8df31bb1e8..0c94a94abb4 100644
--- a/lto-plugin/Makefile.in
+++ b/lto-plugin/Makefile.in
@@ -141,7 +141,7 @@ am__uninstall_files_from_dir = { \
   }
 am__installdirs = "$(DESTDIR)$(libexecsubdir)"
 LTLIBRARIES = $(libexecsub_LTLIBRARIES)
-am_liblto_plugin_la_OBJECTS = lto-plugin.lo
+am_liblto_plugin_la_OBJECTS = liblto_plugin_la-lto-plugin.lo
 liblto_plugin_la_OBJECTS = $(am_liblto_plugin_la_OBJECTS)
 AM_V_P = $(am__v_P_@AM_V@)
 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
@@ -158,12 +158,12 @@ am__v_at_1 =
 DEFAULT_INCLUDES = -I.@am__isrc@
 depcomp =
 am__depfiles_maybe =
-COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
-	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 AM_V_lt = $(am__v_lt_@AM_V@)
 am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
 am__v_lt_0 = --silent
 am__v_lt_1 = 
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
 	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
@@ -323,7 +323,6 @@ prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
 real_target_noncanonical = @real_target_noncanonical@
-runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
@@ -350,6 +349,7 @@ AM_LIBTOOLFLAGS = --tag=disable-static
 libexecsub_LTLIBRARIES = liblto_plugin.la
 in_gcc_libs = $(foreach lib, $(libexecsub_LTLIBRARIES), $(gcc_build_dir)/$(lib))
 liblto_plugin_la_SOURCES = lto-plugin.c
+liblto_plugin_la_CFLAGS = -DGCC_COMPILER_VERSION=${gcc_version}
 # 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) -export-symbols-regex \
@@ -480,6 +480,9 @@ distclean-compile:
 .c.lo:
 	$(AM_V_CC)$(LTCOMPILE) -c -o $@ $<
 
+liblto_plugin_la-lto-plugin.lo: lto-plugin.c
+	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(liblto_plugin_la_CFLAGS) $(CFLAGS) -c -o liblto_plugin_la-lto-plugin.lo `test -f 'lto-plugin.c' || echo '$(srcdir)/'`lto-plugin.c
+
 mostlyclean-libtool:
 	-rm -f *.lo
 
diff --git a/lto-plugin/lto-plugin.c b/lto-plugin/lto-plugin.c
index c9c048d3631..eb5af7680d4 100644
--- a/lto-plugin/lto-plugin.c
+++ b/lto-plugin/lto-plugin.c
@@ -1374,8 +1374,10 @@ process_option (const char *option)
   verbose = verbose || debug;
 }
 
-/* Called by gold after loading the plugin. TV is the transfer vector. */
+#define xstr(s) str(s)
+#define str(s) #s
 
+/* Called by gold after loading the plugin. TV is the transfer vector. */
 enum ld_plugin_status
 onload (struct ld_plugin_tv *tv)
 {
@@ -1431,6 +1433,9 @@ onload (struct ld_plugin_tv *tv)
 	  /* We only use this to make user-friendly temp file names.  */
 	  link_output_name = p->tv_u.tv_string;
 	  break;
+	case LDPT_PLUGIN_VERSION:
+	  p->tv_u.tv_plugin_version ("GCC " xstr (GCC_COMPILER_VERSION));
+	  break;
 	default:
 	  break;
 	}


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-02-28 15:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-28 14:48 [gcc(refs/users/marxin/heads/lto-plugin-add-LDPT_PLUGIN_VERSION)] lto-plugin: add LDPT_PLUGIN_VERSION Martin Liska
2022-02-28 15:08 Martin Liska

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).