From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1851) id 6F11A3858434; Mon, 28 Feb 2022 14:48:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6F11A3858434 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: a02b6d527b2183240b170da2f29d1c389901df61 Message-Id: <20220228144831.6F11A3858434@sourceware.org> Date: Mon, 28 Feb 2022 14:48:31 +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 14:48:31 -0000 https://gcc.gnu.org/g:a02b6d527b2183240b170da2f29d1c389901df61 commit a02b6d527b2183240b170da2f29d1c389901df61 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. 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 #include #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; }