From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1851) id C3CEB385842D; Mon, 28 Feb 2022 15:08:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C3CEB385842D Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Martin Liska To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/marxin/heads/lto-plugin-add-LDPT_PLUGIN_VERSION)] lto-plugin: add LDPT_PLUGIN_VERSION X-Act-Checkin: gcc X-Git-Author: Martin Liska X-Git-Refname: refs/users/marxin/heads/lto-plugin-add-LDPT_PLUGIN_VERSION X-Git-Oldrev: 1060d06b4df8836135ed15d020afbd3637dc625b X-Git-Newrev: ef2371c232156e680fea028565dee0e0cf69db49 Message-Id: <20220228150832.C3CEB385842D@sourceware.org> Date: Mon, 28 Feb 2022 15:08:32 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Feb 2022 15:08:32 -0000 https://gcc.gnu.org/g:ef2371c232156e680fea028565dee0e0cf69db49 commit ef2371c232156e680fea028565dee0e0cf69db49 Author: Martin Liska 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; }