From a18d46a4b6cd2b3c6f6506d09a3bd547b20293bf Mon Sep 17 00:00:00 2001 From: Ghjuvan Lacambre Date: Thu, 12 Nov 2020 09:38:58 +0100 Subject: [PATCH] [Ada] Implement -gnateb switch gcc/ada/ * doc/gnat_ugn/building_executable_programs_with_gnat.rst: Describe -gnateb switch. * doc/gnat_ugn/the_gnat_compilation_model.rst: Mention -gnateb switch in configuration pragma files section. * gnat_ugn.texi: Regenerate. * lib-writ.adb (Write_ALI): Strip directories from configuration files path if needed. * opt.ads: Declare Config_Files_Store_Basename option. * par.adb (Par): Save configuration file checksum. * switch-c.adb (Scan_Front_End_Switches): Set Config_Files_Store_Basename true if -gnateb is present. --- .../building_executable_programs_with_gnat.rst | 7 +++++++ .../doc/gnat_ugn/the_gnat_compilation_model.rst | 4 ++++ gcc/ada/gnat_ugn.texi | 17 +++++++++++++++++ gcc/ada/lib-writ.adb | 5 +---- gcc/ada/opt.ads | 5 +++++ gcc/ada/par.adb | 4 ++++ gcc/ada/switch-c.adb | 6 ++++++ 7 files changed, 44 insertions(+), 4 deletions(-) diff --git a/gcc/ada/doc/gnat_ugn/building_executable_programs_with_gnat.rst b/gcc/ada/doc/gnat_ugn/building_executable_programs_with_gnat.rst index 6993f0d402b..9c62d6e4a91 100644 --- a/gcc/ada/doc/gnat_ugn/building_executable_programs_with_gnat.rst +++ b/gcc/ada/doc/gnat_ugn/building_executable_programs_with_gnat.rst @@ -1517,6 +1517,13 @@ Alphabetical List of All Switches an exception because ``Self(Obj)`` produces an anonymous object which does not share the memory location of ``Obj``. +.. index:: -gnateb (gcc) + +:switch:`-gnateb` + Store configuration files by their basename in ALI files. This switch is + used for instance by gprbuild for distributed builds in order to prevent + issues where machine-specific absolute paths could end up being stored in + ALI files. .. index:: -gnatec (gcc) diff --git a/gcc/ada/doc/gnat_ugn/the_gnat_compilation_model.rst b/gcc/ada/doc/gnat_ugn/the_gnat_compilation_model.rst index 2f0e10c2d0a..46d589a8597 100644 --- a/gcc/ada/doc/gnat_ugn/the_gnat_compilation_model.rst +++ b/gcc/ada/doc/gnat_ugn/the_gnat_compilation_model.rst @@ -1560,6 +1560,10 @@ temporary files that are immediately deleted; it doesn't make sense to depend on a file that no longer exists. Such tools include ``gprbuild``, ``gnatmake``, and ``gnatcheck``. +By default, configuration pragma files are stored by their absolute paths in +ALI files. You can use the :switch:`-gnateb` switch in order to store them by +their basename instead. + If you are using project file, a separate mechanism is provided using project attributes. diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi index 2981d785aa2..14e92715ae2 100644 --- a/gcc/ada/gnat_ugn.texi +++ b/gcc/ada/gnat_ugn.texi @@ -2970,6 +2970,10 @@ temporary files that are immediately deleted; it doesn't make sense to depend on a file that no longer exists. Such tools include @code{gprbuild}, @code{gnatmake}, and @code{gnatcheck}. +By default, configuration pragma files are stored by their absolute paths in +ALI files. You can use the @code{-gnateb} switch in order to store them by +their basename instead. + If you are using project file, a separate mechanism is provided using project attributes. @@ -8968,6 +8972,19 @@ an exception because @code{Self(Obj)} produces an anonymous object which does not share the memory location of @code{Obj}. @end table +@geindex -gnateb (gcc) + + +@table @asis + +@item @code{-gnateb} + +Store configuration files by their basename in ALI files. This switch is +used for instance by gprbuild for distributed builds in order to prevent +issues where machine-specific absolute paths could end up being stored in +ALI files. +@end table + @geindex -gnatec (gcc) diff --git a/gcc/ada/lib-writ.adb b/gcc/ada/lib-writ.adb index 34a8d631c6e..f5b9e3032c8 100644 --- a/gcc/ada/lib-writ.adb +++ b/gcc/ada/lib-writ.adb @@ -1476,11 +1476,8 @@ package body Lib.Writ is -- Normal case of a unit entry with a source index if Sind > No_Source_File then - -- We never want directory information in ALI files - -- ???But back out this change temporarily until - -- gprbuild is fixed. - if False then + if Config_Files_Store_Basename then Fname := Strip_Directory (File_Name (Sind)); else Fname := File_Name (Sind); diff --git a/gcc/ada/opt.ads b/gcc/ada/opt.ads index 5017792a981..f55e9c665e2 100644 --- a/gcc/ada/opt.ads +++ b/gcc/ada/opt.ads @@ -364,6 +364,11 @@ package Opt is -- GNAT -- Names of configuration pragmas files (given by switches -gnatec) + Config_Files_Store_Basename : Boolean := False; + -- GNAT + -- Set True for -gnateb. Tells GNAT that config files should be referred to + -- by their basename and their checksums computed in ALI files. + Configurable_Run_Time_Mode : Boolean := False; -- GNAT, GNATBIND -- Set True if the compiler is operating in configurable run-time mode. diff --git a/gcc/ada/par.adb b/gcc/ada/par.adb index 4c3a1549988..95695d25696 100644 --- a/gcc/ada/par.adb +++ b/gcc/ada/par.adb @@ -1546,6 +1546,10 @@ begin end loop; end; + if Config_Files_Store_Basename then + Complete_Source_File_Entry; + end if; + -- Normal case of compilation unit else diff --git a/gcc/ada/switch-c.adb b/gcc/ada/switch-c.adb index e086a5d9d2b..c6eb063771e 100644 --- a/gcc/ada/switch-c.adb +++ b/gcc/ada/switch-c.adb @@ -486,6 +486,12 @@ package body Switch.C is Ptr := Ptr + 1; Check_Aliasing_Of_Parameters := True; + -- -gnateb (config file basenames and checksums in ALI) + + when 'b' => + Ptr := Ptr + 1; + Config_Files_Store_Basename := True; + -- -gnatec (configuration pragmas) when 'c' => -- 2.30.2