From patchwork Mon Jun 14 09:22:55 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 55499 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 16FB51007D1 for ; Mon, 14 Jun 2010 19:22:56 +1000 (EST) Received: (qmail 8008 invoked by alias); 14 Jun 2010 09:22:54 -0000 Received: (qmail 7955 invoked by uid 22791); 14 Jun 2010 09:22:51 -0000 X-SWARE-Spam-Status: No, hits=-0.9 required=5.0 tests=AWL, BAYES_20, 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, 14 Jun 2010 09:22:46 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 1A199CB021C; Mon, 14 Jun 2010 11:22:49 +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 6l8cpkf2ti0F; Mon, 14 Jun 2010 11:22:49 +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 047B0CB021B; Mon, 14 Jun 2010 11:22:49 +0200 (CEST) Received: by saumur.act-europe.fr (Postfix, from userid 525) id 0F557D9B31; Mon, 14 Jun 2010 11:22:55 +0200 (CEST) Date: Mon, 14 Jun 2010 11:22:55 +0200 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Vincent Celier Subject: [Ada] 'Version and 'Body_Version in Stand-Alone Libraries Message-ID: <20100614092255.GA1042@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 Symbols for 'Version and 'Body_Version of units in Stand-Alone Libraries are now properly generated. The test for this is to have a SAL where 'Version for a non interface unit is used. Tested on x86_64-pc-linux-gnu, committed on trunk 2010-06-14 Vincent Celier * ali.adb (Scan_ALI): Set component Directly_Scanned of the unit(s) to the same value as the parameter of the same name. * ali.ads (Scan_ALI): New Boolean parameter Directly_Scanned, defaulted to False. * bindgen.adb (Gen_Versions_Ada): Never emit version symbols for Stand-Alone Library interfaces. When binding Stand-Alone Libraries, emit version symbols only for the units of the library. (Gen_Versions_C): Ditto. Index: bindgen.adb =================================================================== --- bindgen.adb (revision 160705) +++ bindgen.adb (working copy) @@ -2969,12 +2969,9 @@ -- Gen_Versions_Ada -- ---------------------- - -- This routine generates two sets of lines. The first set has the form: + -- This routine generates lines such as: -- unnnnn : constant Integer := 16#hhhhhhhh#; - - -- The second set has the form - -- pragma Export (C, unnnnn, unam); -- for each unit, where unam is the unit name suffixed by either B or @@ -2999,57 +2996,44 @@ -- Start of processing for Gen_Versions_Ada begin - if Bind_For_Library then - - -- When building libraries, the version number of each unit can - -- not be computed, since the binder does not know the full list - -- of units. Therefore, the 'Version and 'Body_Version - -- attributes cannot supported in this case. - - return; - end if; - WBI (""); WBI (" type Version_32 is mod 2 ** 32;"); for U in Units.First .. Units.Last loop - Increment_Ubuf; - WBI (" " & Ubuf & " : constant Version_32 := 16#" & - Units.Table (U).Version & "#;"); - end loop; + if not Units.Table (U).SAL_Interface and then + ((not Bind_For_Library) or else Units.Table (U).Directly_Scanned) + then + Increment_Ubuf; + WBI (" " & Ubuf & " : constant Version_32 := 16#" & + Units.Table (U).Version & "#;"); + Set_String (" pragma Export (C, "); + Set_String (Ubuf); + Set_String (", """); - WBI (""); - Ubuf := "u00000"; + Get_Name_String (Units.Table (U).Uname); - for U in Units.First .. Units.Last loop - Increment_Ubuf; - Set_String (" pragma Export (C, "); - Set_String (Ubuf); - Set_String (", """); + for K in 1 .. Name_Len loop + if Name_Buffer (K) = '.' then + Set_Char ('_'); + Set_Char ('_'); - Get_Name_String (Units.Table (U).Uname); + elsif Name_Buffer (K) = '%' then + exit; - for K in 1 .. Name_Len loop - if Name_Buffer (K) = '.' then - Set_Char ('_'); - Set_Char ('_'); + else + Set_Char (Name_Buffer (K)); + end if; + end loop; - elsif Name_Buffer (K) = '%' then - exit; - + if Name_Buffer (Name_Len) = 's' then + Set_Char ('S'); else - Set_Char (Name_Buffer (K)); + Set_Char ('B'); end if; - end loop; - if Name_Buffer (Name_Len) = 's' then - Set_Char ('S'); - else - Set_Char ('B'); + Set_String (""");"); + Write_Statement_Buffer; end if; - - Set_String (""");"); - Write_Statement_Buffer; end loop; end Gen_Versions_Ada; @@ -3067,43 +3051,37 @@ procedure Gen_Versions_C is begin - if Bind_For_Library then - - -- When building libraries, the version number of each unit can - -- not be computed, since the binder does not know the full list - -- of units. Therefore, the 'Version and 'Body_Version - -- attributes cannot supported. - - return; - end if; - for U in Units.First .. Units.Last loop - Set_String ("unsigned "); + if not Units.Table (U).SAL_Interface and then + ((not Bind_For_Library) or else Units.Table (U).Directly_Scanned) + then + Set_String ("unsigned "); - Get_Name_String (Units.Table (U).Uname); + Get_Name_String (Units.Table (U).Uname); - for K in 1 .. Name_Len loop - if Name_Buffer (K) = '.' then - Set_String ("__"); + for K in 1 .. Name_Len loop + if Name_Buffer (K) = '.' then + Set_String ("__"); - elsif Name_Buffer (K) = '%' then - exit; + elsif Name_Buffer (K) = '%' then + exit; + else + Set_Char (Name_Buffer (K)); + end if; + end loop; + + if Name_Buffer (Name_Len) = 's' then + Set_Char ('S'); else - Set_Char (Name_Buffer (K)); + Set_Char ('B'); end if; - end loop; - if Name_Buffer (Name_Len) = 's' then - Set_Char ('S'); - else - Set_Char ('B'); + Set_String (" = 0x"); + Set_String (Units.Table (U).Version); + Set_Char (';'); + Write_Statement_Buffer; end if; - - Set_String (" = 0x"); - Set_String (Units.Table (U).Version); - Set_Char (';'); - Write_Statement_Buffer; end loop; end Gen_Versions_C; Index: ali.adb =================================================================== --- ali.adb (revision 160705) +++ ali.adb (working copy) @@ -119,14 +119,15 @@ -------------- function Scan_ALI - (F : File_Name_Type; - T : Text_Buffer_Ptr; - Ignore_ED : Boolean; - Err : Boolean; - Read_Xref : Boolean := False; - Read_Lines : String := ""; - Ignore_Lines : String := "X"; - Ignore_Errors : Boolean := False) return ALI_Id + (F : File_Name_Type; + T : Text_Buffer_Ptr; + Ignore_ED : Boolean; + Err : Boolean; + Read_Xref : Boolean := False; + Read_Lines : String := ""; + Ignore_Lines : String := "X"; + Ignore_Errors : Boolean := False; + Directly_Scanned : Boolean := False) return ALI_Id is P : Text_Ptr := T'First; Line : Logical_Line_Number := 1; @@ -1415,6 +1416,7 @@ UL.First_Arg := First_Arg; UL.Elab_Position := 0; UL.SAL_Interface := ALIs.Table (Id).SAL_Interface; + UL.Directly_Scanned := Directly_Scanned; UL.Body_Needed_For_SAL := False; UL.Elaborate_Body_Desirable := False; UL.Optimize_Alignment := 'O'; Index: ali.ads =================================================================== --- ali.ads (revision 160705) +++ ali.ads (working copy) @@ -342,6 +342,9 @@ SAL_Interface : Boolean; -- Set True when this is an interface to a standalone library + Directly_Scanned : Boolean; + -- True iff it is a unit from an ALI file specified to gnatbind + Body_Needed_For_SAL : Boolean; -- Indicates that the source for the body of the unit (subprogram, -- package, or generic unit) must be included in a standalone library. @@ -933,14 +936,15 @@ -- Initialize the ALI tables. Also resets all switch values to defaults function Scan_ALI - (F : File_Name_Type; - T : Text_Buffer_Ptr; - Ignore_ED : Boolean; - Err : Boolean; - Read_Xref : Boolean := False; - Read_Lines : String := ""; - Ignore_Lines : String := "X"; - Ignore_Errors : Boolean := False) return ALI_Id; + (F : File_Name_Type; + T : Text_Buffer_Ptr; + Ignore_ED : Boolean; + Err : Boolean; + Read_Xref : Boolean := False; + Read_Lines : String := ""; + Ignore_Lines : String := "X"; + Ignore_Errors : Boolean := False; + Directly_Scanned : Boolean := False) return ALI_Id; -- Given the text, T, of an ALI file, F, scan and store the information -- from the file, and return the Id of the resulting entry in the ALI -- table. Switch settings may be modified as described above in the @@ -986,5 +990,11 @@ -- Scan_ALI was completely unable to process the file (e.g. it did not -- look like an ALI file at all). Ignore_Errors is intended to improve -- the downward compatibility of new compilers with old tools. + -- + -- Directly_Scanned is normally False. If it is set to True, then the + -- units (spec and/or body) corresponding to the ALI file are marked as + -- such. It is used to decide for what units gnatbind should generate + -- the symbols corresponding to 'Version or 'Body_Version in + -- Stand-Alone Libraries. end ALI;