mlib-prj.adb (Auto_Initialize): New constant String
authorVincent Celier <celier@adacore.com>
Mon, 4 Jul 2005 13:28:39 +0000 (15:28 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Mon, 4 Jul 2005 13:28:39 +0000 (15:28 +0200)
2005-07-04  Vincent Celier  <celier@adacore.com>

* mlib-prj.adb (Auto_Initialize): New constant String
(SALs_Use_Constructors): New Boolean function
(Build_Library): Call gnatbind with Auto_Initialize switch when
SALs_Use_Constructors returns True.

* mlib-tgt.ads: Minor reformatting

* mlib-utl.ads: Minor reformatting

* opt.ads: (Use_Pragma_Linker_Constructor): New Boolean flag

From-SVN: r101582

gcc/ada/mlib-prj.adb
gcc/ada/mlib-tgt.ads
gcc/ada/mlib-utl.ads
gcc/ada/opt.ads

index 36a504e566465bab7b7f35381d7210b4e6228c8a..464821ce9336b3a54876842e8d4b0501cd80b68c 100644 (file)
@@ -96,6 +96,8 @@ package body MLib.Prj is
    Compile_Switch_String : aliased String := "-c";
    Compile_Switch : constant String_Access := Compile_Switch_String'Access;
 
+   Auto_Initialize : constant String := "-a";
+
    --  List of objects to put inside the library
 
    Object_Files : Argument_List_Access;
@@ -241,6 +243,10 @@ package body MLib.Prj is
    --  Make sure that all the above tables are empty
    --  (Objects, Foreign_Objects, Ali_Files, Options).
 
+   function SALs_Use_Constructors return Boolean;
+   --  Indicate if Stand-Alone Libraries are automatically initialized using
+   --  the constructor mechanism.
+
    ------------------
    -- Add_Argument --
    ------------------
@@ -811,6 +817,10 @@ package body MLib.Prj is
               (B_Start & Get_Name_String (Data.Library_Name) & ".adb");
             Add_Argument ("-L" & Get_Name_String (Data.Library_Name));
 
+            if Data.Lib_Auto_Init and then SALs_Use_Constructors then
+               Add_Argument (Auto_Initialize);
+            end if;
+
             --  Check if Binder'Default_Switches ("Ada") is defined. If it is,
             --  add these switches to call gnatbind.
 
@@ -2021,4 +2031,16 @@ package body MLib.Prj is
       Library_Projs.Init;
    end Reset_Tables;
 
+   ---------------------------
+   -- SALs_Use_Constructors --
+   ---------------------------
+
+   function SALs_Use_Constructors return Boolean is
+      function C_SALs_Init_Using_Constructors return Integer;
+      pragma Import (C, C_SALs_Init_Using_Constructors,
+                     "__gnat_sals_init_using_constructors");
+   begin
+      return C_SALs_Init_Using_Constructors /= 0;
+   end SALs_Use_Constructors;
+
 end MLib.Prj;
index cc7c54950e84a5ba801be1e1e1714b46d4442f0a..4e8cd24599fb257faddc7955fc5c9660f2856869 100644 (file)
@@ -27,7 +27,7 @@
 --  This package provides a set of target dependent routines to build
 --  static, dynamic and shared libraries.
 
---  There are several versions for the body of this package.
+--  There are several versions for the body of this package
 
 --  In the default version, libraries are not supported, so function
 --  Support_For_Libraries return None.
@@ -61,11 +61,12 @@ package MLib.Tgt is
    --  A list of options to invoke the Archive_Builder, usually "cr" for "ar"
 
    function Archive_Indexer return String;
-   --  Returns the name of the program, if any, that generates an index
-   --  to the contents of an archive, usually "ranlib".
+   --  Returns the name of the program, if any, that generates an index to the
+   --  contents of an archive, usually "ranlib". If there is no archive indexer
+   --  to be used, returns an empty string.
 
    function Archive_Indexer_Options return String_List_Access;
-   --  A list of options to invoke the Archive_Indexer, usually empty.
+   --  A list of options to invoke the Archive_Indexer, usually empty
 
    function Dynamic_Option return String;
    --  gcc option to create a dynamic library.
index 1de69996486ee39e8f2813e34b83b71ba630d36e..bbc895d7e69662e7b0b4f17a337a602eb60fc4e4 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---            Copyright (C) 2001-2004, Ada Core Technologies, Inc           --
+--            Copyright (C) 2001-2005, Ada Core Technologies, 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- --
@@ -29,9 +29,6 @@
 
 package MLib.Utl is
 
-   No_Argument_List : constant Argument_List := (1 .. 0 => null);
-   --  Comment needed ???
-
    procedure Delete_File (Filename : in String);
    --  Delete the file Filename
    --  Why is this different from the standard OS_Lib routine???
@@ -43,18 +40,18 @@ package MLib.Utl is
       Options_2   : Argument_List;
       Driver_Name : Name_Id := No_Name);
    --  Driver_Name indicates the "driver" to invoke; by default, the "driver"
-   --  is gcc.
-   --  This procedure invokes the driver to create a shared library.
+   --  is gcc. This procedure invokes the driver to create a shared library.
    --  Options are passed to gcc before the objects, Options_2 after.
-   --  Output_File is the name of the library file to create.
-   --  Objects are the names of the object files to put in the library.
+   --  Output_File is the name of the library file to create. Objects are the
+   --  names of the object files to put in the library.
 
    procedure Ar
      (Output_File : String;
       Objects     : Argument_List);
-   --  Run ar to move all the binaries inside the archive.
-   --  If ranlib is on the path, run it also.
-   --  Arguments need documenting ???
+   --  Run ar to move all the binaries inside the archive. If ranlib is on the
+   --  path, run it also. Output_File is the path name of the archive to
+   --  create. Objects is the list of the path names of the object files to be
+   --  put in the archive.
 
    function Lib_Directory return String;
    --  Return the directory containing libgnat
index 64a86d22ce74ab420085777ff84fa4da938fd778..a4de938eb9b7c027ab4df661f64fb6f3f0a999ba 100644 (file)
@@ -1012,6 +1012,10 @@ package Opt is
    --  Set to True if -h (-gnath for the compiler) switch encountered
    --  requesting usage information
 
+   Use_Pragma_Linker_Constructor : Boolean := False;
+   --  GNATBIND
+   --  True if pragma Linker_Constructor applies to adainit
+
    Use_VADS_Size : Boolean := False;
    --  GNAT
    --  Set to True if a valid pragma Use_VADS_Size is processed