This patch simplifies the contents of Ali files, but removing from it dependency lines that denote units that are not analyzed, because they only appear in the context of units named in limited_with clauses.
The following must execute quietly: gcc -c -gnatc a_things.ads grep c_things a_things.ali grep f_things a_things.ali --- limited with B_Things; package A_Things is type Instance is tagged null record; type Class_Access is access all Instance'Class; procedure Do_Something (Self : Instance); function Get_B_Instance (Self : Instance) return access B_Things.Instance'Class; function Get_B_Class_Acccess (Self : Instance) return B_Things.Class_Access; end A_Things; --- limited with A_Things; limited with C_Things; package B_Things is type Instance is tagged null record; type Class_Access is access all Instance'Class; Some_Junk : Integer := 1235; procedure Do_Something (Self : Instance); function Get_A_Instance (Self : Instance) return access A_Things.Instance'Class; function Get_A_Class_Acccess (Self : Instance) return A_Things.Class_Access; function Get_C_Instance (Self : Instance) return access C_Things.Instance'Class; function Get_C_Class_Acccess (Self : Instance) return C_Things.Class_Access; end B_Things; --- limited with B_Things; limited with D_Things; package C_Things is type Instance is tagged null record; type Class_Access is access all Instance'Class; procedure Do_Something (Self : Instance); function Get_B_Instance (Self : Instance) return access B_Things.Instance'Class; function Get_B_Class_Acccess (Self : Instance) return B_Things.Class_Access; function Get_D_Instance (Self : Instance) return access D_Things.Instance'Class; function Get_D_Class_Acccess (Self : Instance) return D_Things.Class_Access; end C_Things; --- limited with C_Things; limited with E_Things; package D_Things is type Instance is tagged null record; type Class_Access is access all Instance'Class; procedure Do_Something (Self : Instance); function Get_C_Instance (Self : Instance) return access C_Things.Instance'Class; function Get_C_Class_Acccess (Self : Instance) return C_Things.Class_Access; function Get_E_Instance (Self : Instance) return access E_Things.Instance'Class; function Get_E_Class_Acccess (Self : Instance) return E_Things.Class_Access; end D_Things; --- limited with E_Things; limited with F_Things; package E_Things is type Instance is tagged null record; type Class_Access is access all Instance'Class; procedure Do_Something (Self : Instance); function Get_D_Instance (Self : Instance) return access D_Things.Instance'Class; function Get_D_Class_Acccess (Self : Instance) return D_Things.Class_Access; function Get_F_Instance (Self : Instance) return access F_Things.Instance'Class; function Get_F_Class_Acccess (Self : Instance) return F_Things.Class_Access; end E_Things; --- limited with E_Things; package F_Things is type Instance is tagged private; type Class_Access is access all Instance'Class; procedure Do_Something (Self : Instance); function Get_E_Instance (Self : Instance) return access E_Things.Instance'Class is (null); function Get_E_Class_Acccess (Self : Instance) return E_Things.Class_Access is (null); private type Instance is tagged record X : Integer; Y : Integer; Z : Integer; end record; end F_Things; Tested on x86_64-pc-linux-gnu, committed on trunk 2016-04-21 Ed Schonberg <schonb...@adacore.com> * lib-writ.adb (Write_ALI): Do not record in ali file units that are present in the files table but not analyzed. These units are present because they appear in the context of units named in limited_with clauses, and the unit being compiled does not depend semantically on them.
Index: lib-writ.adb =================================================================== --- lib-writ.adb (revision 235192) +++ lib-writ.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2015, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2016, 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- -- @@ -155,8 +155,9 @@ OA_Setting => 'O', SPARK_Mode_Pragma => Empty); - -- Parse system.ads so that the checksum is set right - -- Style checks are not applied. + -- Parse system.ads so that the checksum is set right, + -- Style checks are not applied. The Ekind is set to ensure + -- that this reference is always present in the ali file. declare Save_Mindex : constant Nat := Multiple_Unit_Index; @@ -166,6 +167,7 @@ Style_Check := False; Initialize_Scanner (Units.Last, System_Source_File_Index); Discard_List (Par (Configuration_Pragmas => False)); + Set_Ekind (Cunit_Entity (Units.Last), E_Package); Style_Check := Save_Style; Multiple_Unit_Index := Save_Mindex; end; @@ -1429,6 +1431,17 @@ Units.Table (Unum).Dependency_Num := J; Sind := Units.Table (Unum).Source_Index; + -- The dependency table also contains units that appear in the + -- context of a unit loaded through a limited_with clause. These + -- units are never analyzed, and thus the main unit does not + -- really have a dependency on them. + + if Present (Cunit_Entity (Unum)) + and then Ekind (Cunit_Entity (Unum)) = E_Void + then + goto Next_Unit; + end if; + Write_Info_Initiate ('D'); Write_Info_Char (' '); @@ -1452,6 +1465,18 @@ Write_Info_Char (' '); Write_Info_Str (Get_Hex_String (Source_Checksum (Sind))); + -- If the dependency comes from a limited_with clause, + -- record limited_checksum. + -- Disable for now, until full checksum changes are checked. + + -- if Present (Cunit_Entity (Unum)) + -- and then From_Limited_With (Cunit_Entity (Unum)) + -- then + -- Write_Info_Char (' '); + -- Write_Info_Char ('Y'); + -- Write_Info_Str (Get_Hex_String (Limited_Chk_Sum (Sind))); + -- end if; + -- If subunit, add unit name, omitting the %b at the end if Present (Cunit (Unum)) then @@ -1492,6 +1517,9 @@ end if; Write_Info_EOL; + + <<Next_Unit>> + null; end loop; end;