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] Implement multilib support for gnatmake


Ping.

Laurent

On Mon, 2009-03-16 at 14:14 +0100, Laurent GUERBY wrote:
> Ping.
> 
> Laurent
> 
> On Wed, 2009-03-04 at 10:19 +0100, Laurent GUERBY wrote:
> > On Wed, 2009-03-04 at 09:39 +0100, Richard Guenther wrote:
> > > On Tue, Mar 3, 2009 at 11:44 PM, Joseph S. Myers
> > > <joseph@codesourcery.com> wrote:
> > > > On Tue, 3 Mar 2009, Laurent GUERBY wrote:
> > > >
> > > >> The patch does special processing if and only if two conditions are
> > > >> met:
> > > >> 1/ there is at least one -mxxx flag passed to gnatmake
> > > >> 2/ no --RTS is passed to gnatmake
> > > >
> > > > Some targets have multilibs selected by options not starting with -m
> > > > (-fPIC for VxWorks, other -f options such as -fleading-underscore in
> > > > various configs, -t* for arm-vxworks, -EL/-EB for some MIPS
> > > > configurations, -pthread for AIX, ...).  So at least -f -t -E -p options
> > > > need to be considered (and passed to the driver) as well if you want
> > > > multilib selection to work for all targets, and I have not checked if
> > > > there might be options starting with other letters selecting multilibs on
> > > > some targets (many MULTILIB_OPTIONS settings are multiple lines, so you
> > > > need to be careful in grepping).  Or you could arrange for the options
> > > > involved in MULTILIB_OPTIONS / MULTILIB_MATCHES to be known the gnatmake.
> > > 
> > > Duh.  Still the patch would be nice progress and I consider all the FAILs
> > > during multilib testing of gnat.dg an annoying regression that I would like
> > > to see fixed (either by really fixing it or by somehow disable multilib testing
> > > for gnat.dg).
> > 
> > For Ada and multilib AFAIK on the list of existing Ada multilib
> > supported targets only -m is used as multilib selector (Ada doesn't have
> > lots of exotics target hopefully). gnatmake by default will pass unknown
> > flags to the compiler but not to the linker so those flags are likely
> > not to work "by default" anyway in the before-my-patch gnatmake. That
> > said it's pretty easy to update the patch to include more flags if it's
> > needed.
> > 
> > For gnat.dg even with gnatmake multilib aware it still doesn't work
> > as is (on the non main multilib) and I'm trying to find out why.
> > 
> > Note: I updated my patch since with further testing I found out the
> > previous one wasn't playing nice with -bargs and -largs when at
> > the end of gnatmake command line.
> > 
> > Laurent
> > 
> > Index: make.adb
> > ===================================================================
> > --- make.adb	(revision 144573)
> > +++ make.adb	(working copy)
> > @@ -195,6 +195,9 @@
> >     RTS_Specified : String_Access := null;
> >     --  Used to detect multiple --RTS= switches
> >  
> > +   N_M_Switch : Natural := 0;
> > +   --  Used to count -mxxx switches that can affect multilib
> > +
> >     type Q_Record is record
> >        File  : File_Name_Type;
> >        Unit  : Unit_Name_Type;
> > @@ -666,6 +669,9 @@
> >     --  directory of the ultimate extending project. If it is not, we
> > ignore
> >     --  the fact that this ALI file is read-only.
> >  
> > +   procedure Process_Multilib;
> > +   --  Add appropriate --RTS argument to handle multilib.
> > +
> >     ----------------------------------------------------
> >     -- Compiler, Binder & Linker Data and Subprograms --
> >     ----------------------------------------------------
> > @@ -6854,6 +6860,7 @@
> >        Dependencies.Init;
> >  
> >        RTS_Specified := null;
> > +      N_M_Switch := 0;
> >  
> >        Mains.Delete;
> >  
> > @@ -6913,6 +6920,10 @@
> >           Scan_Make_Arg (Argument (Next_Arg), And_Save => True);
> >        end loop Scan_Args;
> >  
> > +      if N_M_Switch > 0 and RTS_Specified = null then
> > +         Process_Multilib;
> > +      end if;
> > +
> >        if Commands_To_Stdout then
> >           Set_Standard_Output;
> >        end if;
> > @@ -7587,6 +7598,93 @@
> >        Set_Name_Table_Byte (N, B or Mark);
> >     end Mark_Directory;
> >  
> > +   ----------------------
> > +   -- Process_Multilib --
> > +   ----------------------
> > +
> > +   procedure Process_Multilib is
> > +
> > +      Output_FD         : File_Descriptor;
> > +      Output_Name       : String_Access;
> > +      Arg_Index         : Natural := 0;
> > +      Success           : Boolean := False;
> > +      Return_Code       : Integer := 0;
> > +      Multilib_Gcc_Path : String_Access;
> > +      Multilib_Gcc      : String_Access;
> > +      N_Read            : Integer := 0;
> > +      Line              : String (1 .. 1000);
> > +      Args              : Argument_List (1 .. N_M_Switch + 1);
> > +
> > +   begin
> > +      pragma Assert (N_M_Switch > 0 and RTS_Specified = null);
> > +
> > +      for Next_Arg in 1 .. Argument_Count loop
> > +         declare
> > +            Argv : constant String := Argument (Next_Arg);
> > +         begin
> > +            if Argv'Length > 2
> > +              and then Argv (1) = '-'
> > +              and then Argv (2) = 'm'
> > +              and then Argv /= "-margs"
> > +            then
> > +               Arg_Index := Arg_Index + 1;
> > +               Args (Arg_Index) := new String'(Argv);
> > +            end if;
> > +         end;
> > +      end loop;
> > +
> > +      pragma Assert (Arg_Index = N_M_Switch);
> > +
> > +      Args (Args'Last) := new String'("-print-multi-directory");
> > +
> > +      if Saved_Gcc /= null then
> > +         Multilib_Gcc := Saved_Gcc;
> > +      else
> > +         Multilib_Gcc := Gcc;
> > +      end if;
> > +
> > +      Multilib_Gcc_Path :=
> > +        GNAT.OS_Lib.Locate_Exec_On_Path (Multilib_Gcc.all);
> > +
> > +      Create_Temp_File (Output_FD, Output_Name);
> > +      if Output_FD = Invalid_FD then
> > +         return;
> > +      end if;
> > +
> > +      GNAT.OS_Lib.Spawn (Multilib_Gcc_Path.all, Args, Output_FD,
> > +                         Return_Code, False);
> > +      Close (Output_FD);
> > +      if Return_Code /= 0 then
> > +         return;
> > +      end if;
> > +
> > +      Output_FD := Open_Read (Output_Name.all, Binary);
> > +      if Output_FD = Invalid_FD then
> > +         return;
> > +      end if;
> > +
> > +      N_Read := Read (Output_FD, Line (1)'Address, Line'Length);
> > +      Close (Output_FD);
> > +      Delete_File (Output_Name.all, Success);
> > +
> > +      for I in reverse 1 .. N_Read loop
> > +         if Line (I) = ASCII.CR or Line (I) = ASCII.LF then
> > +            N_Read := N_Read - 1;
> > +         else
> > +            exit;
> > +         end if;
> > +      end loop;
> > +
> > +      if N_Read = 0 or else Line (1 .. N_Read) = "." then
> > +         return;
> > +      end if;
> > +
> > +      Scan_Make_Arg ("-margs", And_Save => True);
> > +      Scan_Make_Arg ("--RTS=" & Line (1 .. N_Read),
> > +                     And_Save => True);
> > +
> > +   end Process_Multilib;
> > +
> >     -----------------------------
> >     -- Recursive_Compute_Depth --
> >     -----------------------------
> > @@ -8043,6 +8141,10 @@
> >              Add_Switch (Argv, Compiler, And_Save => And_Save);
> >              Add_Switch (Argv, Linker, And_Save => And_Save);
> >  
> > +            if Argv (2) = 'm' then
> > +               N_M_Switch := N_M_Switch + 1;
> > +            end if;
> > +
> >           --  -C=<mapping file>
> >  
> >           elsif Argv'Last > 2 and then Argv (2) = 'C' then
> > 



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