From patchwork Fri Jul 12 16:12:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Glisse X-Patchwork-Id: 258773 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 4647F2C034A for ; Sat, 13 Jul 2013 02:12:56 +1000 (EST) 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:cc:subject:in-reply-to:message-id:references :mime-version:content-type; q=dns; s=default; b=sEGS8DwRSWF1yDaf ty1yGujsx0pIZNwCmoSuowKviUNLVUDnAxFh9gdvLXxoJLuL2pa2fH3gtUVi1xP7 VBzCzsa0gVwoQeTdxDwSnM2xPXhvaYJV0Updt9g/R0fkmj4T4GF+C8NgFHjsPf0h XQ1N6xvRVRagkM31LQciqq2F8CU= 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:cc:subject:in-reply-to:message-id:references :mime-version:content-type; s=default; bh=xRaM5fLUaSWlA77GDYCn7d eqO7A=; b=v1GuQ7VpnpUkagUZZC+cI2eJa38FImV0ROy7B97Enmkhh1U65AFB0a H76fC3e/Sp1JR+dN12iv8CtSUDhKNWjmrE0jefb6DpBsUteDlcsHG2+16otbPq9r 1T/pE32odQahFBAb/iQA8TH7kGZqzCw0LNG53k4HBpJlQorjlc70Q= Received: (qmail 10109 invoked by alias); 12 Jul 2013 16:12:36 -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 10049 invoked by uid 89); 12 Jul 2013 16:12:36 -0000 X-Spam-SWARE-Status: No, score=0.2 required=5.0 tests=KHOP_RCVD_UNTRUST, KHOP_THREADED, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RDNS_NONE autolearn=no version=3.3.1 Received: from Unknown (HELO mail2-relais-roc.national.inria.fr) (192.134.164.83) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Fri, 12 Jul 2013 16:12:35 +0000 Received: from stedding.saclay.inria.fr ([193.55.250.194]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 12 Jul 2013 18:12:26 +0200 Received: from glisse (helo=localhost) by stedding.saclay.inria.fr with local-esmtp (Exim 4.80) (envelope-from ) id 1UxfxK-0005lD-O9; Fri, 12 Jul 2013 18:12:26 +0200 Date: Fri, 12 Jul 2013 18:12:26 +0200 (CEST) From: Marc Glisse To: Jakub Jelinek cc: gcc-patches@gcc.gnu.org Subject: Re: Call GNU ld with -O* In-Reply-To: <20130712152723.GW2475@laptop.redhat.com> Message-ID: References: <20130712152723.GW2475@laptop.redhat.com> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 X-Virus-Found: No On Fri, 12 Jul 2013, Jakub Jelinek wrote: > On Fri, Jul 12, 2013 at 04:54:21PM +0200, Marc Glisse wrote: >> +/* GNU ld has -O1 and gold -O2, but we only pass it with -O3, -Os or -Ofast. */ >> +#ifndef LINK_OPT_SPEC >> +#if HAVE_GNU_LD >> +#define LINK_OPT_SPEC "%{O*:%{!O0:%{!O1:%{!O2:%{!Og:%{!O:-O2}}}}}} " > > Wouldn't something like "%{O*:%{O|O0|O1|O2|Og:;:-O2}}" work? It does (I only did a non-bootstrap c,c++ build and some manual tests with -v). Thanks, I didn't know this syntax. Is the new version ok? Any tests I should do that would be more useful than running the testsuite? (I tried with several -O options in various orders and made sure that a -Wl,-On ended up later in the command line) Index: gcc.c =================================================================== --- gcc.c (revision 200921) +++ gcc.c (working copy) @@ -715,36 +715,45 @@ proper position among the other output f /* Linker command line options for -fsanitize= late on the command line. */ #ifndef SANITIZER_SPEC #define SANITIZER_SPEC "\ %{!nostdlib:%{!nodefaultlibs:%{fsanitize=address:" LIBASAN_SPEC "\ %{static:%ecannot specify -static with -fsanitize=address}\ %{fsanitize=thread:%e-fsanitize=address is incompatible with -fsanitize=thread}}\ %{fsanitize=thread:" LIBTSAN_SPEC "\ %{!pie:%{!shared:%e-fsanitize=thread linking must be done with -pie or -shared}}}}}" #endif +/* GNU ld has -O1 and gold -O2, but we only pass it with -O3, -Os or -Ofast. */ +#ifndef LINK_OPT_SPEC +#if HAVE_GNU_LD +#define LINK_OPT_SPEC "%{O*:%{O|O0|O1|O2|Og:;:-O2}} " +#else +#define LINK_OPT_SPEC "" +#endif +#endif + /* -u* was put back because both BSD and SysV seem to support it. */ /* %{static:} simply prevents an error message if the target machine doesn't handle -static. */ /* We want %{T*} after %{L*} and %D so that it can be used to specify linker scripts which exist in user specified directories, or in standard directories. */ /* We pass any -flto flags on to the linker, which is expected to understand them. In practice, this means it had better be collect2. */ /* %{e*} includes -export-dynamic; see comment in common.opt. */ #ifndef LINK_COMMAND_SPEC #define LINK_COMMAND_SPEC "\ %{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\ %(linker) " \ LINK_PLUGIN_SPEC \ "%{flto|flto=*:%