From patchwork Wed Apr 11 10:31:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 897131 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-476198-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="frctpP50"; 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 40LgRc5m6pz9s35 for ; Wed, 11 Apr 2018 20:35:37 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:reply-to:mime-version:content-type; q=dns; s=default; b=B94p3oE7M1+U/NSSnTt6oVQ9x0qtyveXBFPt6e6sxq6 QWW6z53rf4mJj9GhRQlQUoqMd0/lKeSc6oZhUaosoIwh2SoCs4RVIK3hZPLApIoU eVRoMueTEAp7c401Ezpb37WHnLZgQbfDDLNQdWhX/Isi0KXAUkh/u43VmR+kDgk0 = 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:date :from:to:subject:message-id:reply-to:mime-version:content-type; s=default; bh=cUocRWIOQCw3Hw8NVNzc9lwJjl8=; b=frctpP50NSWli23R8 MHicrMZ82FCXtYxG+QJlSsOYK2v7VESr/Sxj8X2o+MPeG/EOd7Z4C2Z0mYnWzzOt /n8qXa8z+1fXlGEEXVwJzfC63b9IDTOKofVeqj0DPfDB5fPDpBtyxYcBjbEZsYqF RJlftEXoGR3KxEe1pxhEdfLmy4= Received: (qmail 37622 invoked by alias); 11 Apr 2018 10:35:31 -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 37605 invoked by uid 89); 11 Apr 2018 10:35:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, TIME_LIMIT_EXCEEDED autolearn=unavailable version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 11 Apr 2018 10:35:20 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7C094401CC41 for ; Wed, 11 Apr 2018 10:35:19 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.36.118.110]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3B4A42166BAE for ; Wed, 11 Apr 2018 10:35:19 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id w3BAV8Z4031269 for ; Wed, 11 Apr 2018 12:31:09 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id w3BAV8rw031268 for gcc-patches@gcc.gnu.org; Wed, 11 Apr 2018 12:31:08 +0200 Date: Wed, 11 Apr 2018 12:31:08 +0200 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [PATCH] Use --push-state --as-needed and --pop-state instead of --as-needed and --no-as-needed for libgcc Message-ID: <20180411103108.GP8577@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.2 (2017-12-15) X-IsSubscribed: yes Hi! As discussed, using --as-needed and --no-as-needed is dangerous, because it results in --no-as-needed even for libraries after -lgcc_s, even when the default is --as-needed or --as-needed has been specified earlier on the command line. If the linker supports --push-state/--pop-state, we should IMHO use it. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for stage1? Or is this something we want in GCC8 too? 2018-04-11 Jakub Jelinek * configure.ac (LD_AS_NEEDED_OPTION, LD_NO_AS_NEEDED_OPTION): Use --push-state --as-needed and --pop-state instead of --as-needed and --no-as-needed if ld supports it. * configure: Regenerated. Jakub --- gcc/configure.ac.jj 2018-03-21 21:18:32.470351282 +0100 +++ gcc/configure.ac 2018-04-10 13:31:25.448060053 +0200 @@ -5517,11 +5517,21 @@ if test $in_tree_ld = yes ; then if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 16 -o "$gcc_cv_gld_major_version" -gt 2 \ && test $in_tree_ld_is_elf = yes; then gcc_cv_ld_as_needed=yes + if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 28; then + gcc_cv_ld_as_needed_option='--push-state --as-needed' + gcc_cv_ld_no_as_needed_option='--pop-state' + fi fi elif test x$gcc_cv_ld != x; then # Check if linker supports --as-needed and --no-as-needed options if $gcc_cv_ld --help 2>&1 | grep as-needed > /dev/null; then gcc_cv_ld_as_needed=yes + if $gcc_cv_ld --help 2>&1 | grep push-state > /dev/null; then + if $gcc_cv_ld --help 2>&1 | grep pop-state > /dev/null; then + gcc_cv_ld_as_needed_option='--push-state --as-needed' + gcc_cv_ld_no_as_needed_option='--pop-state' + fi + fi fi case "$target:$gnu_ld" in *-*-solaris2*:no) --- gcc/configure.jj 2018-03-21 21:18:30.187351579 +0100 +++ gcc/configure 2018-04-10 13:47:57.652298798 +0200 @@ -28733,11 +28733,21 @@ if test $in_tree_ld = yes ; then if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 16 -o "$gcc_cv_gld_major_version" -gt 2 \ && test $in_tree_ld_is_elf = yes; then gcc_cv_ld_as_needed=yes + if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 28; then + gcc_cv_ld_as_needed_option='--push-state --as-needed' + gcc_cv_ld_no_as_needed_option='--pop-state' + fi fi elif test x$gcc_cv_ld != x; then # Check if linker supports --as-needed and --no-as-needed options if $gcc_cv_ld --help 2>&1 | grep as-needed > /dev/null; then gcc_cv_ld_as_needed=yes + if $gcc_cv_ld --help 2>&1 | grep push-state > /dev/null; then + if $gcc_cv_ld --help 2>&1 | grep pop-state > /dev/null; then + gcc_cv_ld_as_needed_option='--push-state --as-needed' + gcc_cv_ld_no_as_needed_option='--pop-state' + fi + fi fi case "$target:$gnu_ld" in *-*-solaris2*:no)