From patchwork Sun Oct 27 07:08:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangyu Chen X-Patchwork-Id: 2002930 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=qq.com header.i=@qq.com header.a=rsa-sha256 header.s=s201512 header.b=zXi2EQw0; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Xbnh14kbpz1xtp for ; Sun, 27 Oct 2024 18:09:20 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D2D34385842D for ; Sun, 27 Oct 2024 07:09:16 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from out203-205-221-209.mail.qq.com (out203-205-221-209.mail.qq.com [203.205.221.209]) by sourceware.org (Postfix) with UTF8SMTPS id DF1033858D34 for ; Sun, 27 Oct 2024 07:08:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DF1033858D34 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=cyyself.name Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=cyyself.name ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DF1033858D34 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=203.205.221.209 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730012938; cv=none; b=ksuL2KD+RjudC39oEs8dao9fhOIMoFU7r4vGSpK+P1P9iZH6im3OdQbdJEW/6hqJTy3BoE0fXz9rCPrPTNdx/sa/YBJ6kLpHrUXGOsJ7Sk8uqGHPCn0WDRbBDd6Dx+zpzHijhDKHMATQGWG/8kX1iOb0HWuN1RiLKBqWaT5jPbI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730012938; c=relaxed/simple; bh=epQ25GTN7wgtIHIbF6f4SV/kEY2hlZ+d6d34Bm0Ruhc=; h=DKIM-Signature:Message-ID:From:To:Subject:Date:MIME-Version; b=UoRigLPFLXBzXymGFyPbjN/36MN2/zAQrWsyx94RMUYlJYPQqnzv1Ikm62X75YWcxtMaEbVOkLJOAmnfCW6k4jAjj0hf/F8FeQoPVru8nAAsA9KrxI7rsbWCx/gksGN4TEQ2BgFpRykN1SRLBlwIx2BmoCK6vojn6SvYWMhpEdU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1730012921; bh=hi4UBwcMDL2bEgrap3lZCnOBHjF8Fcqb9diZfGPdoD0=; h=From:To:Cc:Subject:Date; b=zXi2EQw0Nyy5M/7u7Jq1X/2WAnp/74XUcu9qWxYIQk/Ks2JO6TrEa4ScViX5mcmc5 F3IiUPdVApiqAYZfUPyPa5jT7QHjpAftZbjPFC1qsAmtfVFHom+iHcJZWDseMgiNCn dFhMBm3mBi2Oakc0y4tSb1ub8LzoYRf1+JHz33ZY= Received: from m1.edu.cn ([2001:da8:c800:d6b4:4bc3:26be:a073:a346]) by newxmesmtplogicsvrszc13-0.qq.com (NewEsmtp) with SMTP id 22580694; Sun, 27 Oct 2024 15:08:37 +0800 X-QQ-mid: xmsmtpt1730012917tcee0shmu Message-ID: X-QQ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X1z5L2GBWG1DxYu9E= X-QQ-XMRINFO: OWPUhxQsoeAVDbp3OJHYyFg= From: Yangyu Chen To: gcc-patches@gcc.gnu.org Cc: Andrew Carlotti , Yangyu Chen Subject: [PATCH v2] [aarch64] Fix function multiversioning dispatcher link error with LTO Date: Sun, 27 Oct 2024 07:08:23 +0000 X-OQ-MSGID: <20241027070823.434141-1-cyy@cyyself.name> X-Mailer: git-send-email 2.47.0 MIME-Version: 1.0 X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, HELO_DYNAMIC_IPADDR, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, RDNS_DYNAMIC, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org We forgot to apply DECL_EXTERNAL to __init_cpu_features_resolver decl. When building with LTO, the linker cannot find the __init_cpu_features_resolver.lto_priv* symbol, causing the link error. This patch get this fixed by adding DECL_EXTERNAL to the decl. To avoid used but never defined warning for this symbol, we also mark TREE_PUBLIC to the decl. Minimal steps to reproduce the bug: echo '__attribute__((target_clones("default", "aes"))) void func1() { }' > 1.c echo '__attribute__((target_clones("default", "aes"))) void func2() { }' > 2.c echo 'void func1();void func2();int main(){func1();func2();return 0;}' > main.c gcc -flto -c 1.c 2.c gcc -flto main.c 1.o 2.o Fixes: 0cfde688e213 ("[aarch64] Add function multiversioning support") gcc/ChangeLog: * config/aarch64/aarch64.cc (dispatch_function_versions): Adding DECL_EXTERNAL and TREE_PUBLIC to __init_cpu_features_resolver decl. --- gcc/config/aarch64/aarch64.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index 5770491b30c..37123befeaf 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -20437,6 +20437,8 @@ dispatch_function_versions (tree dispatch_decl, tree init_fn_id = get_identifier ("__init_cpu_features_resolver"); tree init_fn_decl = build_decl (UNKNOWN_LOCATION, FUNCTION_DECL, init_fn_id, init_fn_type); + DECL_EXTERNAL (init_fn_decl) = 1; + TREE_PUBLIC (init_fn_decl) = 1; tree arg1 = DECL_ARGUMENTS (dispatch_decl); tree arg2 = TREE_CHAIN (arg1); ifunc_cpu_init_stmt = gimple_build_call (init_fn_decl, 2, arg1, arg2);