From patchwork Mon May 2 07:51:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 1624975 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=jfMPdxbF; dkim=fail reason="signature verification failed" header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Hxm7XB8A; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KsFfw0q8Zz9s0r for ; Mon, 2 May 2022 17:52:08 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EBEC2385741D for ; Mon, 2 May 2022 07:52:05 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 279FA3858D33 for ; Mon, 2 May 2022 07:51:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 279FA3858D33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 50BD0210EE; Mon, 2 May 2022 07:51:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1651477913; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=RKxmk3Wlss7NXnzy+Mac68tfyQATeqML9zCe3muoksQ=; b=jfMPdxbF8HWvOhqQkScYbp0Jxqv0RIqIC6f9W1UAJDOrViFEwNkafCY8aKcEqIujkjBHeY MoMFHXaP+5u9lKtJIFZfnrbQu8YGx3HTxMRtKYPs0foJ00TgEw3b3XJhh3HKIGrnNaqLfU 2C2rgfg/g/G0griUvEaUpAOUhWrBIyE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1651477913; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=RKxmk3Wlss7NXnzy+Mac68tfyQATeqML9zCe3muoksQ=; b=Hxm7XB8AXSch2EqTrUGPjohZSCx+2Ng7f7n2voSX6fNJHyykjgNt+EQV+1HpytsUdMwshB UQLGf4nFwZSBW6BA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 35385133E5; Mon, 2 May 2022 07:51:53 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id IPX5C5mNb2LMfgAAMHmgww (envelope-from ); Mon, 02 May 2022 07:51:53 +0000 Message-ID: <698bff4b-75ca-7a42-db8f-a5e90df5e567@suse.cz> Date: Mon, 2 May 2022 09:51:52 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 From: =?utf-8?q?Martin_Li=C5=A1ka?= Subject: [PATCH] LTO plugin: add ld_plugin_version callback. To: gcc-patches@gcc.gnu.org Content-Language: en-US X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jan Hubicka Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi. This in a new plug-in function that helps identifying compiler by a linker. Will be used in mold linker. Patch can bootstrap on x86_64-linux-gnu and survives regression tests. Ready to be installed? Thanks, Martin include/ChangeLog: * plugin-api.h (enum ld_plugin_compiler): New enum. (enum ld_plugin_version): New typedef. (struct ld_plugin_tv): Add new field. lto-plugin/ChangeLog: * lto-plugin.c (onload): Call ld_plugin_version. --- include/plugin-api.h | 18 +++++++++++++++++- lto-plugin/lto-plugin.c | 4 ++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/include/plugin-api.h b/include/plugin-api.h index 4e12c0320d6..4d0989028cc 100644 --- a/include/plugin-api.h +++ b/include/plugin-api.h @@ -211,6 +211,13 @@ enum ld_plugin_symbol_section_kind LDSSK_BSS }; +enum ld_plugin_compiler +{ + LDPC_UNKNOWN, + LDPC_GCC, + LDPC_LLVM +}; + /* How a symbol is resolved. */ enum ld_plugin_symbol_resolution @@ -475,6 +482,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 compiler + and its number version (MAJOR * 1000 + MINOR). */ + +typedef +void (*ld_plugin_version) (enum ld_plugin_compiler compiler, int version); + enum ld_plugin_level { LDPL_INFO, @@ -520,7 +534,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 +571,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 7a1c77812f6..698a0617ca7 100644 --- a/lto-plugin/lto-plugin.c +++ b/lto-plugin/lto-plugin.c @@ -69,6 +69,7 @@ along with this program; see the file COPYING3. If not see #include "../gcc/lto/common.h" #include "simple-object.h" #include "plugin-api.h" +#include "ansidecl.h" /* We need to use I64 instead of ll width-specifier on native Windows. The reason for this is that older MS-runtimes don't support the ll. */ @@ -1466,6 +1467,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 (LDPC_GCC, GCC_VERSION); + break; default: break; }