This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] ada: Avoid Systematic recompilation of up-to-date objects under Darwin


> The patchfile below solves the problem of systematic recompilation of
> Ada files when
> giving "-s" to gnatmake under darwin (ppc and x86). More details on
> this problem are
> described in bug report 34289.
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34289
>
> ---------------------------------------------------------------
> 2007-12-03  Bechir Zalila  <bechir.zalila@gmail.com>
>
>         * switch-c.adb (Scan_Front_End_Switches): New switch -gnatea.
> Should always be the first switch to the gcc driver. Enable switch storing
> so that switches automatically added by the gcc driver at the beginning of
> the switch list are not put in the ALI file.
>
> 	* make.adb: (Compile_Sources.Compile): Add switch -gnatea as the first
> 	option.
> 	(Display): Never display -gnatea
>
> 	* lib.adb: (Switch_Storing_Enabled): initialized to False
> 	(Enable_Switch_Storing): New procedure. Set Switch_Storing_Enabled
> 	to True.
>
> 	* lib.ads: (Enable_Switch_Storing): New procedure.
>
> 	* lang-specs.h: surround the non-(g*&m*) switches we want to register
> 	by -gnatea and -gnatez

This is mostly OK, but initializing Switch_Storing_Enabled to False is quite 
problematic since no switches are recorded if you don't use gnatmake.

Here's a revision version, tested on i586-suse-linux, applied on the mainline.


2008-11-07  Bechir Zalila  <bechir.zalila@gmail.com>
            Eric Botcazou  <ebotcazou@adacore.com>

	PR ada/34289
        * lib.ads: (Enable_Switch_Storing): Declare.
        * lib.adb: (Enable_Switch_Storing): New procedure.
? ? ? ? * switch-c.adb (Scan_Front_End_Switches): Add support for -gnatea.
????????* make.adb: (Compile_Sources.Compile): Add -gnatea as first option.
????????(Display): Never display -gnatea
????????* gcc-interface/lang-specs.h: If -gnatea is present, pass -gnatez.


-- 
Eric Botcazou
Index: lib.adb
===================================================================
--- lib.adb	(revision 141548)
+++ lib.adb	(working copy)
@@ -49,7 +49,7 @@ with Uname;   use Uname;
 package body Lib is
 
    Switch_Storing_Enabled : Boolean := True;
-   --  Set to False by Disable_Switch_Storing
+   --  Controlled by Enable_Switch_Storing/Disable_Switch_Storing
 
    -----------------------
    -- Local Subprograms --
@@ -433,6 +433,19 @@ package body Lib is
       return Compilation_Switches.Last;
    end Compilation_Switches_Last;
 
+   ---------------------------
+   -- Enable_Switch_Storing --
+   ---------------------------
+
+   procedure Enable_Switch_Storing is
+   begin
+      Switch_Storing_Enabled := True;
+   end Enable_Switch_Storing;
+
+   ----------------------------
+   -- Disable_Switch_Storing --
+   ----------------------------
+
    procedure Disable_Switch_Storing is
    begin
       Switch_Storing_Enabled := False;
Index: lib.ads
===================================================================
--- lib.ads	(revision 141548)
+++ lib.ads	(working copy)
@@ -562,9 +562,15 @@ package Lib is
    --  which may influence the generated output file(s). Switch is the text of
    --  the switch to store (except that -fRTS gets changed back to --RTS).
 
+   procedure Enable_Switch_Storing;
+   --  Enable registration of switches by Store_Compilation_Switch. Used to
+   --  avoid registering switches added automatically by the gcc driver at the
+   --  beginning of the command line.
+
    procedure Disable_Switch_Storing;
    --  Disable registration of switches by Store_Compilation_Switch. Used to
-   --  avoid registering switches added automatically by the gcc driver.
+   --  avoid registering switches added automatically by the gcc driver at the
+   --  end of the command line.
 
    procedure Store_Linker_Option_String (S : String_Id);
    --  This procedure is called to register the string from a pragma
Index: switch-c.adb
===================================================================
--- switch-c.adb	(revision 141548)
+++ switch-c.adb	(working copy)
@@ -301,6 +301,11 @@ package body Switch.C is
 
                case Switch_Chars (Ptr) is
 
+                  when 'a' =>
+                     Store_Switch := False;
+                     Enable_Switch_Storing;
+                     Ptr := Ptr + 1;
+
                   --  -gnatec (configuration pragmas)
 
                   when 'c' =>
Index: make.adb
===================================================================
--- make.adb	(revision 141548)
+++ make.adb	(working copy)
@@ -2947,7 +2947,7 @@ package body Make is
          Source_Index : Int;
          Args         : Argument_List) return Process_Id
       is
-         Comp_Args : Argument_List (Args'First .. Args'Last + 9);
+         Comp_Args : Argument_List (Args'First .. Args'Last + 10);
          Comp_Next : Integer := Args'First;
          Comp_Last : Integer;
          Arg_Index : Integer;
@@ -3004,6 +3004,9 @@ package body Make is
             end if;
          end loop;
 
+         Comp_Args (Comp_Next) := new String'("-gnatea");
+         Comp_Next := Comp_Next + 1;
+
          Comp_Args (Comp_Next) := Comp_Flag;
          Comp_Next := Comp_Next + 1;
 
@@ -4109,9 +4112,11 @@ package body Make is
 
          for J in Args'Range loop
 
-            --  Never display -gnatez
+            --  Never display -gnatea nor -gnatez
 
-            if Args (J).all /= "-gnatez" then
+            if Args (J).all /= "-gnatea" and then
+              Args (J).all /= "-gnatez"
+            then
 
                --  Do not display the mapping file argument automatically
                --  created when using a project file.
Index: gcc-interface/lang-specs.h
===================================================================
--- gcc-interface/lang-specs.h	(revision 141548)
+++ gcc-interface/lang-specs.h	(working copy)
@@ -35,7 +35,8 @@
  gnat1 %{I*} %{k8:-gnatk8} %{Wall:-gnatwa} %{w:-gnatws} %{!Q:-quiet}\
     %{nostdinc*} %{nostdlib*}\
     -dumpbase %{.adb:%b.adb}%{.ads:%b.ads}%{!.adb:%{!.ads:%b.ada}}\
-    %{O*} %{W*} %{w} %{p} %{pg:-p} %{a} %{f*} %{d*} %{g*&m*} "
+    %{O*} %{W*} %{w} %{p} %{pg:-p} %{a} %{f*} %{d*}\
+    %{gnatea:-gnatez} %{g*&m*} "
 #if defined(TARGET_VXWORKS_RTP)
    "%{fRTS=rtp:-mrtp} "
 #endif

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]