[gcc r12-6223] [Ada] Reduce runtime dependencies on stage1

Pierre-Marie de Rodat pmderodat@gcc.gnu.org
Wed Jan 5 11:33:16 GMT 2022


https://gcc.gnu.org/g:1fc93860a54772c3302ba755eed504d3b00c88ef

commit r12-6223-g1fc93860a54772c3302ba755eed504d3b00c88ef
Author: Arnaud Charlet <charlet@adacore.com>
Date:   Mon Nov 29 10:04:36 2021 +0000

    [Ada] Reduce runtime dependencies on stage1
    
    gcc/ada/
    
            * osint.adb (File_Names_Equal): Declare To_Lower locally.
            * osint.ads (Null_FD): New.
            * fmap.adb, sinput-l.adb, targparm.adb: Adapt to changes above.
            * switch-b.adb (Scan_Debug_Switches): Use Is_Regular_File to
            simplify the bootstrap dependencies.

Diff:
---
 gcc/ada/fmap.adb     |  2 +-
 gcc/ada/osint.adb    | 15 +++++++++++++++
 gcc/ada/osint.ads    |  4 ++++
 gcc/ada/sinput-l.adb |  2 +-
 gcc/ada/switch-b.adb |  2 +-
 gcc/ada/targparm.adb |  2 +-
 6 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/gcc/ada/fmap.adb b/gcc/ada/fmap.adb
index 7a8e082cbb1..7597eba9cd8 100644
--- a/gcc/ada/fmap.adb
+++ b/gcc/ada/fmap.adb
@@ -301,7 +301,7 @@ package body Fmap is
       Read_Source_File (Name_Enter (File_Name), 1, Hi, Src, FD, Config);
 
       if Null_Source_Buffer_Ptr (Src) then
-         if FD = Null_FD then
+         if FD = Osint.Null_FD then
             Write_Str ("warning: could not locate mapping file """);
          else
             Write_Str ("warning: no read access for mapping file """);
diff --git a/gcc/ada/osint.adb b/gcc/ada/osint.adb
index cf39128fb7b..a8a6801f9e4 100644
--- a/gcc/ada/osint.adb
+++ b/gcc/ada/osint.adb
@@ -1059,6 +1059,21 @@ package body Osint is
    ----------------------
 
    function File_Names_Equal (File1, File2 : String) return Boolean is
+
+      function To_Lower (A : String) return String;
+      --  For bootstrap reasons, we cannot use To_Lower from System.Case_Util
+
+      --------------
+      -- To_Lower --
+      --------------
+
+      function To_Lower (A : String) return String is
+         Result : String := A;
+      begin
+         To_Lower (Result);
+         return Result;
+      end To_Lower;
+
    begin
       if File_Names_Case_Sensitive then
          return File1 = File2;
diff --git a/gcc/ada/osint.ads b/gcc/ada/osint.ads
index f1a9f848c25..f733e65d330 100644
--- a/gcc/ada/osint.ads
+++ b/gcc/ada/osint.ads
@@ -52,6 +52,10 @@ package Osint is
    Project_Include_Path_File : constant String := "ADA_PRJ_INCLUDE_FILE";
    Project_Objects_Path_File : constant String := "ADA_PRJ_OBJECTS_FILE";
 
+   Null_FD : constant File_Descriptor := -2;
+   --  Uninitialized file descriptor. Copied from System.OS_Lib for bootstrap
+   --  reasons.
+
    Output_FD : File_Descriptor;
    --  File descriptor for current library info, list, tree, C, H, or binder
    --  output. Only one of these is open at a time, so we need only one FD.
diff --git a/gcc/ada/sinput-l.adb b/gcc/ada/sinput-l.adb
index 2d5efb00424..6a939bc6a88 100644
--- a/gcc/ada/sinput-l.adb
+++ b/gcc/ada/sinput-l.adb
@@ -420,7 +420,7 @@ package body Sinput.L is
       if Null_Source_Buffer_Ptr (Src) then
          Source_File.Decrement_Last;
 
-         if FD = Null_FD then
+         if FD = Osint.Null_FD then
             return No_Source_File;
          else
             return No_Access_To_Source_File;
diff --git a/gcc/ada/switch-b.adb b/gcc/ada/switch-b.adb
index a7359789e5a..bea6ab3dc6c 100644
--- a/gcc/ada/switch-b.adb
+++ b/gcc/ada/switch-b.adb
@@ -312,7 +312,7 @@ package body Switch.B is
 
             Ptr := Max + 1;
 
-            if not Is_Read_Accessible_File (Force_Elab_Order_File.all) then
+            if not Is_Regular_File (Force_Elab_Order_File.all) then
                Osint.Fail (Force_Elab_Order_File.all & ": file not found");
             end if;
 
diff --git a/gcc/ada/targparm.adb b/gcc/ada/targparm.adb
index 4390c0ea3e0..ade05c25795 100644
--- a/gcc/ada/targparm.adb
+++ b/gcc/ada/targparm.adb
@@ -165,7 +165,7 @@ package body Targparm is
       if Null_Source_Buffer_Ptr (Text) then
          Write_Line ("fatal error, run-time library not installed correctly");
 
-         if FD = Null_FD then
+         if FD = Osint.Null_FD then
             Write_Line ("cannot locate file system.ads");
          else
             Write_Line ("no read access for file system.ads");


More information about the Gcc-cvs mailing list