public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Martin Liska <marxin@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc(refs/users/marxin/heads/lto-plugin-add-LDPT_PLUGIN_VERSION)] lto-plugin: add LDPT_PLUGIN_VERSION
Date: Mon, 28 Feb 2022 14:48:31 +0000 (GMT)	[thread overview]
Message-ID: <20220228144831.6F11A3858434@sourceware.org> (raw)

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;
 	}


             reply	other threads:[~2022-02-28 14:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-28 14:48 Martin Liska [this message]
2022-02-28 15:08 Martin Liska

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220228144831.6F11A3858434@sourceware.org \
    --to=marxin@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).