From patchwork Fri Jun 18 08:29:24 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 56150 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 438211007D4 for ; Fri, 18 Jun 2010 18:29:36 +1000 (EST) Received: (qmail 10088 invoked by alias); 18 Jun 2010 08:29:29 -0000 Received: (qmail 10049 invoked by uid 22791); 18 Jun 2010 08:29:21 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, 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; Fri, 18 Jun 2010 08:29:07 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id A1C0BCB0253; Fri, 18 Jun 2010 10:29:14 +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 a6IyAjwI906V; Fri, 18 Jun 2010 10:29:14 +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 89FFECB01E2; Fri, 18 Jun 2010 10:29:14 +0200 (CEST) Received: by saumur.act-europe.fr (Postfix, from userid 525) id B1455D9B31; Fri, 18 Jun 2010 10:29:24 +0200 (CEST) Date: Fri, 18 Jun 2010 10:29:24 +0200 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Vincent Celier Subject: [Ada] gnatmake -f -u
always invokes the compiler Message-ID: <20100618082924.GA29604@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 As documented, gnatmake -f -u
should always invoke the compiler. This patch ensures that it is aways true, even when the ALI file is read-only, when the source is in a directory specified with -aL or is a direct source of an externally built project. Tested on x86_64-pc-linux-gnu, committed on trunk 2010-06-18 Vincent Celier * make.adb (Must_Compile): New Boolean global variable (Main_On_Command_Line): New Boolean global variable (Collect_Arguments_And_Compile): Do compile if Must_Compile is True, even when the project is externally built. (Start_Compile_If_Possible): Compile in -aL directories if Check_Readonly_Files is True. Do compile if Must_Compile is True, even when the project is externally built. (Gnatmake): Set Must_Compile and Check_Readonly_Files to True when invoked with -f -u and one or several mains on the command line. (Scan_Make_Arg): Set Main_On_Command_Line to True when at least one main is specified on the command line. Index: make.adb =================================================================== --- make.adb (revision 160959) +++ make.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2010, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -202,6 +202,14 @@ package body Make is Unique_Compile_All_Projects : Boolean := False; -- Set to True if -U is used + Must_Compile : Boolean := False; + -- True if gnatmake is invoked with -f -u and one or several mains on the + -- command line. + + Main_On_Command_Line : Boolean := False; + -- True if gnatmake is invoked with one or several mains on the command + -- line. + RTS_Specified : String_Access := null; -- Used to detect multiple --RTS= switches @@ -2243,12 +2251,14 @@ package body Make is if Arguments_Project = No_Project then Add_Arguments (The_Saved_Gcc_Switches.all); - elsif not Arguments_Project.Externally_Built then + elsif not Arguments_Project.Externally_Built + or else Must_Compile + then -- We get the project directory for the relative path -- switches and arguments. - Arguments_Project := Ultimate_Extending_Project_Of - (Arguments_Project); + Arguments_Project := + Ultimate_Extending_Project_Of (Arguments_Project); -- If building a dynamic or relocatable library, compile with -- PIC option, if it exists. @@ -2258,7 +2268,6 @@ package body Make is then declare PIC : constant String := MLib.Tgt.PIC_Option; - begin if PIC /= "" then Add_Arguments ((1 => new String'(PIC))); @@ -2726,7 +2735,9 @@ package body Make is -- check for an eventual library project, and use the full path. if Arguments_Project /= No_Project then - if not Arguments_Project.Externally_Built then + if not Arguments_Project.Externally_Built + or else Must_Compile + then Prj.Env.Set_Ada_Paths (Arguments_Project, Project_Tree, @@ -2742,7 +2753,7 @@ package body Make is begin if Prj.Library - and then not Prj.Externally_Built + and then (not Prj.Externally_Built or else Must_Compile) and then not Prj.Need_To_Build_Lib then -- Add to the Q all sources of the project that have @@ -3272,8 +3283,9 @@ package body Make is Executable_Obsolete := True; end if; - In_Lib_Dir := Full_Lib_File /= No_File - and then In_Ada_Lib_Dir (Full_Lib_File); + In_Lib_Dir := not Check_Readonly_Files + and then Full_Lib_File /= No_File + and then In_Ada_Lib_Dir (Full_Lib_File); -- Since the following requires a system call, we precompute it -- when needed. @@ -3350,6 +3362,7 @@ package body Make is if Arguments_Project = No_Project or else not Arguments_Project.Externally_Built + or else Must_Compile then -- Don't waste any time if we have to recompile anyway @@ -4739,13 +4752,6 @@ package body Make is Display_Version ("GNATMAKE", "1995"); end if; - if Main_Project /= No_Project - and then Main_Project.Externally_Built - then - Make_Failed - ("nothing to do for a main project that is externally built"); - end if; - if Osint.Number_Of_Files = 0 then if Main_Project /= No_Project and then Main_Project.Library @@ -5182,6 +5188,26 @@ package body Make is end; end if; + -- The combination of -f -u and one or several mains on the command line + -- implies -a. + + if Force_Compilations + and then Unique_Compile + and then not Unique_Compile_All_Projects + and then Main_On_Command_Line + then + Check_Readonly_Files := True; + Must_Compile := True; + end if; + + if Main_Project /= No_Project + and then not Must_Compile + and then Main_Project.Externally_Built + then + Make_Failed + ("nothing to do for a main project that is externally built"); + end if; + -- Get the target parameters, which are only needed for a couple of -- cases in gnatmake. Protect against an exception, such as the case of -- system.ads missing from the library, and fail gracefully. @@ -8219,6 +8245,10 @@ package body Make is -- If not a switch it must be a file name else + if And_Save then + Main_On_Command_Line := True; + end if; + Add_File (Argv); Mains.Add_Main (Argv); end if;