From patchwork Mon Oct 4 13:28:37 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 66651 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 DC4FAB6F07 for ; Tue, 5 Oct 2010 00:28:51 +1100 (EST) Received: (qmail 2628 invoked by alias); 4 Oct 2010 13:28:49 -0000 Received: (qmail 2616 invoked by uid 22791); 4 Oct 2010 13:28:47 -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; Mon, 04 Oct 2010 13:28:40 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 186E6CB01DD; Mon, 4 Oct 2010 15:28:38 +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 WhwRDoZApe+O; Mon, 4 Oct 2010 15:28:38 +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 A9FDACB01BA; Mon, 4 Oct 2010 15:28:37 +0200 (CEST) Received: by saumur.act-europe.fr (Postfix, from userid 525) id 8C06BD9BB4; Mon, 4 Oct 2010 15:28:37 +0200 (CEST) Date: Mon, 4 Oct 2010 15:28:37 +0200 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Vincent Celier Subject: [Ada] Simultaneous compilations and -gnateG Message-ID: <20101004132837.GA29935@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 When -gnateG is used, the preprocessed files will be written only for the sources of the main unit (spec, body and subunits) that is compiled. This will avoid simultaneous attempt to write the same preprocessed file when there are simultaneous compilations. The test for this is to invoke gnatmake with -f -j20 -gnateD... -gnateG a main that withs many package spec that in turn with the same spec that needs to be preprocessed. There should not be any warning that a preprocessed file cannot be written. Tested on x86_64-pc-linux-gnu, committed on trunk 2010-10-04 Vincent Celier * frontend.adb: Set Lib.Parsing_Main_Extended_Source to True before loading the main source, so that if it is preprocessed and -gnateG is used, the preprocessed file is written. * lib.ads (Analysing_Subunit_Of_Main): New global variable to indicate if a subunit is from the main unit when it is loaded. * sem_ch10.adb (Analyze_Proper_Body): Set Lib.Analysing_Subunit_Of_Main to True before loading a subunit. * sem_ch12.adb (Copy_Generic_Node): Set Lib.Analysing_Subunit_Of_Main to True when the main is a generic unit before loading one of its subunits. * sinput-l.adb (Load_File): If -gnateG is used, write the preprocessed file only for the main unit (spec, body and subunits). Index: lib.ads =================================================================== --- lib.ads (revision 164906) +++ lib.ads (working copy) @@ -49,6 +49,11 @@ package Lib is -- extended source (the main unit, its spec, or one of its subunits). This -- flag to implement In_Extended_Main_Source_Unit. + Analysing_Subunit_Of_Main : Boolean := False; + -- Set to True when analyzing a subunit of the main source. When True, if + -- the subunit is preprocessed and -gnateG is specified, then the + -- preprocessed file (.prep) is written. + -------------------------------------------- -- General Approach to Library Management -- -------------------------------------------- Index: frontend.adb =================================================================== --- frontend.adb (revision 164906) +++ frontend.adb (working copy) @@ -116,6 +116,11 @@ begin Prepcomp.Check_Symbols; end if; + -- We set Parsing_Main_Extended_Source true here to cover processing of all + -- the configuration pragma files, as well as the main source unit itself. + + Parsing_Main_Extended_Source := True; + -- Now that the preprocessing situation is established, we are able to -- load the main source (this is no longer done by Lib.Load.Initialize). @@ -127,11 +132,6 @@ begin return; end if; - -- We set Parsing_Main_Extended_Source true here to cover processing of all - -- the configuration pragma files, as well as the main source unit itself. - - Parsing_Main_Extended_Source := True; - -- Read and process configuration pragma files if present declare Index: sem_ch10.adb =================================================================== --- sem_ch10.adb (revision 164906) +++ sem_ch10.adb (working copy) @@ -1739,12 +1739,17 @@ package body Sem_Ch10 is -- Otherwise we must load the subunit and link to it else + -- Make sure that, if the subunit is preprocessed and -gnateG is + -- specified, the preprocessed file will be written. + + Lib.Analysing_Subunit_Of_Main := True; Unum := Load_Unit (Load_Name => Subunit_Name, Required => False, Subunit => True, Error_Node => N); + Lib.Analysing_Subunit_Of_Main := False; -- Give message if we did not get the unit Emit warning even if -- missing subunit is not within main unit, to simplify debugging. @@ -1822,11 +1827,11 @@ package body Sem_Ch10 is end if; end if; - -- The remaining case is when the subunit is not already loaded and - -- we are not generating code. In this case we are just performing - -- semantic analysis on the parent, and we are not interested in - -- the subunit. For subprograms, analyze the stub as a body. For - -- other entities the stub has already been marked as completed. + -- The remaining case is when the subunit is not already loaded and we + -- are not generating code. In this case we are just performing semantic + -- analysis on the parent, and we are not interested in the subunit. For + -- subprograms, analyze the stub as a body. For other entities the stub + -- has already been marked as completed. else Optional_Subunit; Index: sem_ch12.adb =================================================================== --- sem_ch12.adb (revision 164906) +++ sem_ch12.adb (working copy) @@ -5906,12 +5906,19 @@ package body Sem_Ch12 is New_Body : Node_Id; begin + -- Make sure that, if it is a subunit of the main unit that is + -- preprocessed and if -gnateG is specified, the preprocessed + -- file will be written. + + Lib.Analysing_Subunit_Of_Main := + Lib.In_Extended_Main_Source_Unit (N); Unum := Load_Unit (Load_Name => Subunit_Name, Required => False, Subunit => True, Error_Node => N); + Lib.Analysing_Subunit_Of_Main := False; -- If the proper body is not found, a warning message will be -- emitted when analyzing the stub, or later at the point Index: sinput-l.adb =================================================================== --- sinput-l.adb (revision 164933) +++ sinput-l.adb (working copy) @@ -30,6 +30,7 @@ with Einfo; use Einfo; with Errout; use Errout; with Fname; use Fname; with Hostparm; +with Lib; use Lib; with Opt; use Opt; with Osint; use Osint; with Output; use Output; @@ -552,9 +553,17 @@ package body Sinput.L is else -- Output the result of the preprocessing, if requested and - -- the source has been modified by the preprocessing. + -- the source has been modified by the preprocessing. Only + -- do that for the main unit (spec, body and subunits). - if Generate_Processed_File and then Modified then + if Generate_Processed_File and then + Modified and then + ((Compiler_State = Parsing + and then Parsing_Main_Extended_Source) + or else + (Compiler_State = Analyzing + and then Analysing_Subunit_Of_Main)) + then declare FD : File_Descriptor; NB : Integer;