From patchwork Mon Oct 4 14:10:10 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 66680 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]) by ozlabs.org (Postfix) with SMTP id AB8FAB70CC for ; Tue, 5 Oct 2010 01:10:26 +1100 (EST) Received: (qmail 10439 invoked by alias); 4 Oct 2010 14:10:21 -0000 Received: (qmail 10069 invoked by uid 22791); 4 Oct 2010 14:10:19 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, TW_FX, TW_MX, TW_RG, TW_TX, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (212.99.106.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 04 Oct 2010 14:10:13 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 27DBCCB0245; Mon, 4 Oct 2010 16:10:11 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hGa5Gxu7+51q; Mon, 4 Oct 2010 16:10:11 +0200 (CEST) Received: from saumur.act-europe.fr (saumur.act-europe.fr [10.10.0.183]) by mel.act-europe.fr (Postfix) with ESMTP id 0B538CB0244; Mon, 4 Oct 2010 16:10:11 +0200 (CEST) Received: by saumur.act-europe.fr (Postfix, from userid 525) id E30B5D9BB4; Mon, 4 Oct 2010 16:10:10 +0200 (CEST) Date: Mon, 4 Oct 2010 16:10:10 +0200 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [Ada] Instruct gnatmake to pass -Oxxx switches to the linker Message-ID: <20101004141010.GA8266@adacore.com> Mime-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.9i X-IsSubscribed: yes 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 This makes it so that gnatmake passes -Oxxx switches to the linker in addition to the compiler. This is aimed at simplifying the use of LTO in Ada. Tested on x86_64-pc-linux-gnu, committed on trunk 2010-10-04 Eric Botcazou * make.adb (Scan_Make_Arg): Pass -Oxxx switches to the linker as well. * gnatlink.adb (Gnatlink): Filter out -Oxxx switches for CLI, RTX and AAMP. Index: make.adb =================================================================== --- make.adb (revision 164906) +++ make.adb (working copy) @@ -8060,12 +8060,12 @@ package body Make is elsif Argv (2) = 'L' then Add_Switch (Argv, Linker, And_Save => And_Save); - -- For -gxxxxx, -pg, -mxxx, -fxxx: give the switch to both the + -- For -gxxx, -pg, -mxxx, -fxxx, -Oxxx, pass the switch to both the -- compiler and the linker (except for -gnatxxx which is only for the -- compiler). Some of the -mxxx (for example -m64) and -fxxx (for -- example -ftest-coverage for gcov) need to be used when compiling -- the binder generated files, and using all these gcc switches for - -- the binder generated files should not be a problem. + -- them should not be a problem. Pass -Oxxx to the linker for LTO. elsif (Argv (2) = 'g' and then (Argv'Last < 5 @@ -8073,6 +8073,7 @@ package body Make is or else Argv (2 .. Argv'Last) = "pg" or else (Argv (2) = 'm' and then Argv'Last > 2) or else (Argv (2) = 'f' and then Argv'Last > 2) + or else (Argv (2) = 'O' and then Argv'Last > 2) then Add_Switch (Argv, Compiler, And_Save => And_Save); Add_Switch (Argv, Linker, And_Save => And_Save); Index: gnatlink.adb =================================================================== --- gnatlink.adb (revision 164906) +++ gnatlink.adb (working copy) @@ -1965,6 +1965,25 @@ begin or else Linker_Options.Table (J) (1 .. 2) = "-l" or else Linker_Options.Table (J) (1 .. 3) = "-Wl" or else Linker_Options.Table (J) (1 .. 3) = "-sh" + or else Linker_Options.Table (J) (1 .. 2) = "-O" + or else Linker_Options.Table (J) (1 .. 2) = "-g" + then + Linker_Options.Table (J .. Linker_Options.Last - 1) := + Linker_Options.Table (J + 1 .. Linker_Options.Last); + Linker_Options.Decrement_Last; + Num_Args := Num_Args - 1; + end if; + end loop; + + elsif AAMP_On_Target then + + -- Remove extraneous flags not relevant for AAMP + + for J in reverse Linker_Options.First .. Linker_Options.Last loop + if Linker_Options.Table (J)'Length = 0 + or else Linker_Options.Table (J) (1 .. 3) = "-Wl" + or else Linker_Options.Table (J) (1 .. 3) = "-sh" + or else Linker_Options.Table (J) (1 .. 2) = "-O" or else Linker_Options.Table (J) (1 .. 2) = "-g" then Linker_Options.Table (J .. Linker_Options.Last - 1) := @@ -1986,6 +2005,7 @@ begin or else Linker_Options.Table (J) (1 .. 2) = "-l" or else Linker_Options.Table (J) (1 .. 3) = "-Wl" or else Linker_Options.Table (J) (1 .. 3) = "-sh" + or else Linker_Options.Table (J) (1 .. 2) = "-O" or else Linker_Options.Table (J) (1 .. 8) = "-Xlinker" or else Linker_Options.Table (J) (1 .. 9) = "-mthreads" then