Commit df956773 by Vincent Celier Committed by Arnaud Charlet

mlib-prj.adb (Auto_Initialize): New constant String

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
parent f4657cf5
...@@ -96,6 +96,8 @@ package body MLib.Prj is ...@@ -96,6 +96,8 @@ package body MLib.Prj is
Compile_Switch_String : aliased String := "-c"; Compile_Switch_String : aliased String := "-c";
Compile_Switch : constant String_Access := Compile_Switch_String'Access; Compile_Switch : constant String_Access := Compile_Switch_String'Access;
Auto_Initialize : constant String := "-a";
-- List of objects to put inside the library -- List of objects to put inside the library
Object_Files : Argument_List_Access; Object_Files : Argument_List_Access;
...@@ -241,6 +243,10 @@ package body MLib.Prj is ...@@ -241,6 +243,10 @@ package body MLib.Prj is
-- Make sure that all the above tables are empty -- Make sure that all the above tables are empty
-- (Objects, Foreign_Objects, Ali_Files, Options). -- (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 -- -- Add_Argument --
------------------ ------------------
...@@ -811,6 +817,10 @@ package body MLib.Prj is ...@@ -811,6 +817,10 @@ package body MLib.Prj is
(B_Start & Get_Name_String (Data.Library_Name) & ".adb"); (B_Start & Get_Name_String (Data.Library_Name) & ".adb");
Add_Argument ("-L" & Get_Name_String (Data.Library_Name)); 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, -- Check if Binder'Default_Switches ("Ada") is defined. If it is,
-- add these switches to call gnatbind. -- add these switches to call gnatbind.
...@@ -2021,4 +2031,16 @@ package body MLib.Prj is ...@@ -2021,4 +2031,16 @@ package body MLib.Prj is
Library_Projs.Init; Library_Projs.Init;
end Reset_Tables; 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; end MLib.Prj;
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
-- This package provides a set of target dependent routines to build -- This package provides a set of target dependent routines to build
-- static, dynamic and shared libraries. -- 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 -- In the default version, libraries are not supported, so function
-- Support_For_Libraries return None. -- Support_For_Libraries return None.
...@@ -61,11 +61,12 @@ package MLib.Tgt is ...@@ -61,11 +61,12 @@ package MLib.Tgt is
-- A list of options to invoke the Archive_Builder, usually "cr" for "ar" -- A list of options to invoke the Archive_Builder, usually "cr" for "ar"
function Archive_Indexer return String; function Archive_Indexer return String;
-- Returns the name of the program, if any, that generates an index -- Returns the name of the program, if any, that generates an index to the
-- to the contents of an archive, usually "ranlib". -- 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; 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; function Dynamic_Option return String;
-- gcc option to create a dynamic library. -- gcc option to create a dynamic library.
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- 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 -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -29,9 +29,6 @@ ...@@ -29,9 +29,6 @@
package MLib.Utl is package MLib.Utl is
No_Argument_List : constant Argument_List := (1 .. 0 => null);
-- Comment needed ???
procedure Delete_File (Filename : in String); procedure Delete_File (Filename : in String);
-- Delete the file Filename -- Delete the file Filename
-- Why is this different from the standard OS_Lib routine??? -- Why is this different from the standard OS_Lib routine???
...@@ -43,18 +40,18 @@ package MLib.Utl is ...@@ -43,18 +40,18 @@ package MLib.Utl is
Options_2 : Argument_List; Options_2 : Argument_List;
Driver_Name : Name_Id := No_Name); Driver_Name : Name_Id := No_Name);
-- Driver_Name indicates the "driver" to invoke; by default, the "driver" -- Driver_Name indicates the "driver" to invoke; by default, the "driver"
-- is gcc. -- is gcc. This procedure invokes the driver to create a shared library.
-- This procedure invokes the driver to create a shared library.
-- Options are passed to gcc before the objects, Options_2 after. -- Options are passed to gcc before the objects, Options_2 after.
-- Output_File is the name of the library file to create. -- Output_File is the name of the library file to create. Objects are the
-- Objects are the names of the object files to put in the library. -- names of the object files to put in the library.
procedure Ar procedure Ar
(Output_File : String; (Output_File : String;
Objects : Argument_List); Objects : Argument_List);
-- Run ar to move all the binaries inside the archive. -- Run ar to move all the binaries inside the archive. If ranlib is on the
-- If ranlib is on the path, run it also. -- path, run it also. Output_File is the path name of the archive to
-- Arguments need documenting ??? -- create. Objects is the list of the path names of the object files to be
-- put in the archive.
function Lib_Directory return String; function Lib_Directory return String;
-- Return the directory containing libgnat -- Return the directory containing libgnat
......
...@@ -1012,6 +1012,10 @@ package Opt is ...@@ -1012,6 +1012,10 @@ package Opt is
-- Set to True if -h (-gnath for the compiler) switch encountered -- Set to True if -h (-gnath for the compiler) switch encountered
-- requesting usage information -- requesting usage information
Use_Pragma_Linker_Constructor : Boolean := False;
-- GNATBIND
-- True if pragma Linker_Constructor applies to adainit
Use_VADS_Size : Boolean := False; Use_VADS_Size : Boolean := False;
-- GNAT -- GNAT
-- Set to True if a valid pragma Use_VADS_Size is processed -- Set to True if a valid pragma Use_VADS_Size is processed
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment