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
This commit is contained in:
Vincent Celier 2005-07-04 15:28:39 +02:00 committed by Arnaud Charlet
parent f4657cf513
commit df95677353
4 changed files with 39 additions and 15 deletions

View 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;

View 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.

View 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

View 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