From patchwork Tue Dec 17 06:39:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xi Ruoyao X-Patchwork-Id: 1211131 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-516084-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=mengyan1223.wang Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="MKe01vQG"; dkim=pass (2048-bit key; unprotected) header.d=mengyan1223.wang header.i=@mengyan1223.wang header.b="enlPRhod"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47cT662LrHz9sPW for ; Tue, 17 Dec 2019 17:40:12 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:subject:from:to:cc:date:content-type:mime-version :content-transfer-encoding; q=dns; s=default; b=er9kDem5tNqbM3eb O+CcfKx4ly1jhG483DTqGC7+z0aOcB71pv/RNgRlIRb47kUNA5unPLcAty/+yNRC PwNwp2tT9GEZNrea7y/KWOskMi6b7wjtX++6p9Mjg4KITi+oxEQHPMq0YOAGVzLE DYrjt1yeir25puNzzvWX5kvuiWg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:subject:from:to:cc:date:content-type:mime-version :content-transfer-encoding; s=default; bh=LraGLylvBjwWFZ6pvPzjqu 9gtxo=; b=MKe01vQGjBZjxclK6LnzLLD3vzMz1kKXfhQ/ikCt65lgFd8fqJ1Cin 2EDvA0dydfOXRGKvu5Z4r9NufnWpWUbPlDfcAAX/pzsGQAM+XB1VznI97Ed+W2I0 QQqB5/Uj2jBKIAS9SJOCYdNJ8GuV4T1UXf94LxO7bAaXgEWTlrGyk= Received: (qmail 74334 invoked by alias); 17 Dec 2019 06:40:04 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 74316 invoked by uid 89); 17 Dec 2019 06:40:03 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 spammy=symtab_node X-HELO: mengyan1223.wang Received: from mengyan1223.wang (HELO mengyan1223.wang) (89.208.246.23) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 17 Dec 2019 06:40:02 +0000 Received: from xry111-X57S1 (unknown [IPv6:2408:8270:a53:90d0:f9a6:91de:fbc0:b47]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: xry111@mengyan1223.wang) by mengyan1223.wang (Postfix) with ESMTPSA id 7B43D65ACB; Tue, 17 Dec 2019 01:39:58 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mengyan1223.wang; s=mail; t=1576564801; bh=0tXyxoVDG1gawAQXNQrRXcHxXJaI6ol71gLqSE6CAbA=; h=Subject:From:To:Cc:Date:From; b=enlPRhodeckvg1c5fjddWJ26D1JFV1m0ApUDl9vb8tg7opdHGQYD1ldpthUb+8HdP oIp+QKHFFd1B4s6L/vp6bcBiv3/ie0QaPT1brNcZggqkkIy/6AZAa3t0rMtz22/iyQ DUapXSBmF3yBCCboKSFrVG401zxuqM7URc/MC3ggPDOAedPpzODK8508ZVu8Frm835 EWr3okE+Frxbo0ONyycDv4bxlm1ClBLmDzCSdER89oIA30XBAHcqppXldbBhvt3FCa Hyt2Kj5f54J5IDLKeV1S81/iFKx0xNunoJjy4CRge9V+9NfnONMHRd50Wg5HmisQyn 1AuCBNXwBw1dw== Message-ID: <4e112e2d2afb5f579fac32caec3741f7e140e556.camel@mengyan1223.wang> Subject: [PATCH] Fix symver attribute with LTO From: Xi Ruoyao To: gcc-patches@gcc.gnu.org Cc: Jan Hubicka Date: Tue, 17 Dec 2019 14:39:52 +0800 User-Agent: Evolution 3.34.2 MIME-Version: 1.0 Hi, with Jan's patch commited in r278878 we can use symver attribute for functions and variables. The symver attribute is designed for replacing toplevel asm statements containing ".symver" which may be removed by LTO. Unfortunately, a quick test shown GCC still generates buggy so file with LTO and new symver attribute. Two issues: 1. The symver node in symtab is marked as PREVAILING_DEF_IRONLY (no EXP) and then removed by LTO. 2. The actual function body implementing the symver-ed function is also marked as PREVAILING_DEF_IRONLY and then removed or marked as local. So no ".globl" directive is outputed for it. Both issue cause symbols with symver missing in DSO (with LTO enabled). I modified fuse-3.9.0 code to use new symver attribute and tried to build it with GCC trunk and LTO. The result is a buggy DSO. With this patch applied, fuse-3.9.0 can be built with LTO enabled and no problem. I'll test symver patch and this patch with more packages. Bootstrapped/regtested x86_64-linux. I'm not a maintainer. gcc/ChangeLog: 2019-12-17 Xi Ruoyao * cgraph.h (symtab_node::used_from_object_file_p): Symver nodes are part of DSO ABI so always used by non-LTO object files. * ipa-visibility.c (cgraph_externally_visible_p): Functions with symver attributes should always be visible. Index: gcc/cgraph.h =================================================================== --- gcc/cgraph.h (revision 279452) +++ gcc/cgraph.h (working copy) @@ -2682,7 +2682,7 @@ symtab_node::used_from_object_file_p (vo { if (!TREE_PUBLIC (decl) || DECL_EXTERNAL (decl)) return false; - if (resolution_used_from_other_file_p (resolution)) + if (symver || resolution_used_from_other_file_p (resolution)) return true; return false; } Index: gcc/ipa-visibility.c =================================================================== --- gcc/ipa-visibility.c (revision 279452) +++ gcc/ipa-visibility.c (working copy) @@ -216,6 +216,8 @@ cgraph_externally_visible_p (struct cgra return true; if (lookup_attribute ("noipa", DECL_ATTRIBUTES (node->decl))) return true; + if (lookup_attribute ("symver", DECL_ATTRIBUTES (node->decl))) + return true; if (TARGET_DLLIMPORT_DECL_ATTRIBUTES && lookup_attribute ("dllexport", DECL_ATTRIBUTES (node->decl)))