When the compiler is invoked with several --RTS= switches, with different
values designated the same runtime directory, the compiler reports an
error that RTS cannot be specified several times. This patch fixes
this problem.
The test for this is to invoke the compiler with two switches --RTS=, one
with the full path of the runtime directory, the other with the runtime
name.
Example:
gcc -c --RTS=/full/path/rts-sjlj/ --RTS=toto main.adb

Tested on x86_64-pc-linux-gnu, committed on trunk

2015-02-20  Vincent Celier  <cel...@adacore.com>

        * switch-c.adb (Scan_Front_End_Switches): Do not fail when --RTS=
        is specified several times with different values that indicates
        the same runtime directory.

Index: switch-c.adb
===================================================================
--- switch-c.adb        (revision 220835)
+++ switch-c.adb        (working copy)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 2001-2014, Free Software Foundation, Inc.         --
+--          Copyright (C) 2001-2015, 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- --
@@ -229,17 +229,6 @@
                        new String'(Switch_Chars (Ptr + 4 .. Max));
                   end if;
 
-                  --  Check that this is the first time --RTS is specified
-                  --  or if it is not the first time, the same path has been
-                  --  specified.
-
-                  if RTS_Specified = null then
-                     RTS_Specified := Runtime_Dir;
-
-                  elsif  RTS_Specified.all /= Runtime_Dir.all then
-                     Osint.Fail ("--RTS cannot be specified multiple times");
-                  end if;
-
                   --  Valid --RTS switch
 
                   Opt.No_Stdinc := True;
@@ -251,13 +240,23 @@
                   RTS_Lib_Path_Name :=
                     Get_RTS_Search_Dir (Runtime_Dir.all, Objects);
 
-                  if RTS_Src_Path_Name /= null
+                  if RTS_Specified /= null then
+                     if RTS_Src_Path_Name = null
+                       or else RTS_Lib_Path_Name = null
+                       or else RTS_Specified.all /= RTS_Lib_Path_Name.all
+                     then
+                        Osint.Fail
+                          ("--RTS cannot be specified multiple times");
+                     end if;
+
+                  elsif RTS_Src_Path_Name /= null
                     and then RTS_Lib_Path_Name /= null
                   then
                      --  Store the -fRTS switch (Note: Store_Compilation_Switch
                      --  changes -fRTS back into --RTS for the actual output).
 
                      Store_Compilation_Switch (Switch_Chars);
+                     RTS_Specified := new String'(RTS_Lib_Path_Name.all);
 
                   elsif RTS_Src_Path_Name = null
                     and then RTS_Lib_Path_Name = null

Reply via email to