Commit 3b81743f by Nicolas Setton Committed by Arnaud Charlet

link.c: Add flag __gnat_separate_run_path_options.

2009-04-22  Nicolas Setton  <setton@adacore.com>

	* link.c: Add flag __gnat_separate_run_path_options.

	* mlib.adb (Separate_Run_Path_Options): New subprogram.

	* mlib.ads (Separate_Run_Path_Options): Declare.

	* gnatcmd.adb (Process_Link): Add support for emitting one "rpath"
	switch per directory, rather than one "rpath" switch listing all
	directories.

	* gnatlink.adb (Process_Binder_File): Likewise.

	* make.adb (Gnatmake): Likewise.

From-SVN: r146561
parent 3a69b5ff
2009-04-22 Nicolas Setton <setton@adacore.com>
* link.c: Add flag __gnat_separate_run_path_options.
* mlib.adb (Separate_Run_Path_Options): New subprogram.
* mlib.ads (Separate_Run_Path_Options): Declare.
* gnatcmd.adb (Process_Link): Add support for emitting one "rpath"
switch per directory, rather than one "rpath" switch listing all
directories.
* gnatlink.adb (Process_Binder_File): Likewise.
* make.adb (Gnatmake): Likewise.
2009-04-22 Hristian Kirtchev <kirtchev@adacore.com> 2009-04-22 Hristian Kirtchev <kirtchev@adacore.com>
* exp_ch6.adb (Make_Build_In_Place_Call_In_Assignment): Code cleanup. * exp_ch6.adb (Make_Build_In_Place_Call_In_Assignment): Code cleanup.
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1996-2008, Free Software Foundation, Inc. -- -- Copyright (C) 1996-2009, Free Software Foundation, 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- --
...@@ -976,54 +976,80 @@ procedure GNATCmd is ...@@ -976,54 +976,80 @@ procedure GNATCmd is
Current : Natural; Current : Natural;
begin begin
-- First, compute the exact length for the switch if MLib.Separate_Run_Path_Options then
for Index in -- We are going to create one switch of the form
Library_Paths.First .. Library_Paths.Last -- "-Wl,-rpath,dir_N" for each directory to consider.
loop
-- Add the length of the library dir plus one for the
-- directory separator.
Length := -- One switch for each library directory
Length +
Library_Paths.Table (Index)'Length + 1;
end loop;
-- Finally, add the length of the standard GNAT library dir for Index in
Library_Paths.First .. Library_Paths.Last
loop
Last_Switches.Increment_Last;
Last_Switches.Table
(Last_Switches.Last) := new String'
(Path_Option.all &
Last_Switches.Table (Index).all);
end loop;
Length := Length + MLib.Utl.Lib_Directory'Length; -- One switch for the standard GNAT library dir.
Option := new String (1 .. Length);
Option (1 .. Path_Option'Length) := Path_Option.all;
Current := Path_Option'Length;
-- Put each library dir followed by a dir separator Last_Switches.Increment_Last;
Last_Switches.Table
(Last_Switches.Last) := new String'
(Path_Option.all & MLib.Utl.Lib_Directory);
for Index in else
Library_Paths.First .. Library_Paths.Last -- First, compute the exact length for the switch
loop
Option for Index in
(Current + 1 .. Library_Paths.First .. Library_Paths.Last
loop
-- Add the length of the library dir plus one for the
-- directory separator.
Length :=
Length +
Library_Paths.Table (Index)'Length + 1;
end loop;
-- Finally, add the length of the standard GNAT library dir
Length := Length + MLib.Utl.Lib_Directory'Length;
Option := new String (1 .. Length);
Option (1 .. Path_Option'Length) := Path_Option.all;
Current := Path_Option'Length;
-- Put each library dir followed by a dir separator
for Index in
Library_Paths.First .. Library_Paths.Last
loop
Option
(Current + 1 ..
Current +
Library_Paths.Table (Index)'Length) :=
Library_Paths.Table (Index).all;
Current :=
Current + Current +
Library_Paths.Table (Index)'Length) := Library_Paths.Table (Index)'Length + 1;
Library_Paths.Table (Index).all; Option (Current) := Path_Separator;
Current := end loop;
Current +
Library_Paths.Table (Index)'Length + 1;
Option (Current) := Path_Separator;
end loop;
-- Finally put the standard GNAT library dir -- Finally put the standard GNAT library dir
Option Option
(Current + 1 .. (Current + 1 ..
Current + MLib.Utl.Lib_Directory'Length) := Current + MLib.Utl.Lib_Directory'Length) :=
MLib.Utl.Lib_Directory; MLib.Utl.Lib_Directory;
-- And add the switch to the last switches -- And add the switch to the last switches
Last_Switches.Increment_Last; Last_Switches.Increment_Last;
Last_Switches.Table (Last_Switches.Last) := Last_Switches.Table (Last_Switches.Last) :=
Option; Option;
end if;
end; end;
end if; end if;
end if; end if;
......
...@@ -65,6 +65,9 @@ ...@@ -65,6 +65,9 @@
/* using_gnu_linker is set to 1 when the GNU linker is used under this */ /* using_gnu_linker is set to 1 when the GNU linker is used under this */
/* target. */ /* target. */
/* separate_run_path_options is set to 1 when separate "rpath" arguments */
/* must be passed to the linker for each directory in the rpath. */
/* RESPONSE FILE & GNU LINKER */ /* RESPONSE FILE & GNU LINKER */
/* -------------------------- */ /* -------------------------- */
/* objlist_file_supported and using_gnu_link used together tell gnatlink */ /* objlist_file_supported and using_gnu_link used together tell gnatlink */
...@@ -88,6 +91,7 @@ unsigned char __gnat_objlist_file_supported = 1; ...@@ -88,6 +91,7 @@ unsigned char __gnat_objlist_file_supported = 1;
char __gnat_shared_libgnat_default = STATIC; char __gnat_shared_libgnat_default = STATIC;
unsigned char __gnat_using_gnu_linker = 0; unsigned char __gnat_using_gnu_linker = 0;
const char *__gnat_object_library_extension = ".a"; const char *__gnat_object_library_extension = ".a";
unsigned char __gnat_separate_run_path_options = 0;
#elif defined (sgi) #elif defined (sgi)
const char *__gnat_object_file_option = "-Wl,-objectlist,"; const char *__gnat_object_file_option = "-Wl,-objectlist,";
...@@ -97,6 +101,7 @@ unsigned char __gnat_objlist_file_supported = 1; ...@@ -97,6 +101,7 @@ unsigned char __gnat_objlist_file_supported = 1;
char __gnat_shared_libgnat_default = STATIC; char __gnat_shared_libgnat_default = STATIC;
unsigned char __gnat_using_gnu_linker = 0; unsigned char __gnat_using_gnu_linker = 0;
const char *__gnat_object_library_extension = ".a"; const char *__gnat_object_library_extension = ".a";
unsigned char __gnat_separate_run_path_options = 0;
#elif defined (__WIN32) #elif defined (__WIN32)
const char *__gnat_object_file_option = ""; const char *__gnat_object_file_option = "";
...@@ -106,6 +111,7 @@ unsigned char __gnat_objlist_file_supported = 1; ...@@ -106,6 +111,7 @@ unsigned char __gnat_objlist_file_supported = 1;
char __gnat_shared_libgnat_default = STATIC; char __gnat_shared_libgnat_default = STATIC;
unsigned char __gnat_using_gnu_linker = 1; unsigned char __gnat_using_gnu_linker = 1;
const char *__gnat_object_library_extension = ".a"; const char *__gnat_object_library_extension = ".a";
unsigned char __gnat_separate_run_path_options = 0;
#elif defined (__hpux__) #elif defined (__hpux__)
const char *__gnat_object_file_option = "-Wl,-c,"; const char *__gnat_object_file_option = "-Wl,-c,";
...@@ -115,6 +121,7 @@ unsigned char __gnat_objlist_file_supported = 1; ...@@ -115,6 +121,7 @@ unsigned char __gnat_objlist_file_supported = 1;
char __gnat_shared_libgnat_default = STATIC; char __gnat_shared_libgnat_default = STATIC;
unsigned char __gnat_using_gnu_linker = 0; unsigned char __gnat_using_gnu_linker = 0;
const char *__gnat_object_library_extension = ".a"; const char *__gnat_object_library_extension = ".a";
unsigned char __gnat_separate_run_path_options = 0;
#elif defined (_AIX) #elif defined (_AIX)
const char *__gnat_object_file_option = "-Wl,-f,"; const char *__gnat_object_file_option = "-Wl,-f,";
...@@ -124,6 +131,7 @@ const unsigned char __gnat_objlist_file_supported = 1; ...@@ -124,6 +131,7 @@ const unsigned char __gnat_objlist_file_supported = 1;
char __gnat_shared_libgnat_default = STATIC; char __gnat_shared_libgnat_default = STATIC;
unsigned char __gnat_using_gnu_linker = 0; unsigned char __gnat_using_gnu_linker = 0;
const char *__gnat_object_library_extension = ".a"; const char *__gnat_object_library_extension = ".a";
unsigned char __gnat_separate_run_path_options = 0;
#elif defined (VMS) #elif defined (VMS)
const char *__gnat_object_file_option = ""; const char *__gnat_object_file_option = "";
...@@ -133,6 +141,7 @@ int __gnat_link_max = 2147483647; ...@@ -133,6 +141,7 @@ int __gnat_link_max = 2147483647;
unsigned char __gnat_objlist_file_supported = 0; unsigned char __gnat_objlist_file_supported = 0;
unsigned char __gnat_using_gnu_linker = 0; unsigned char __gnat_using_gnu_linker = 0;
const char *__gnat_object_library_extension = ".olb"; const char *__gnat_object_library_extension = ".olb";
unsigned char __gnat_separate_run_path_options = 0;
#elif defined (sun) #elif defined (sun)
const char *__gnat_object_file_option = ""; const char *__gnat_object_file_option = "";
...@@ -142,6 +151,7 @@ int __gnat_link_max = 2147483647; ...@@ -142,6 +151,7 @@ int __gnat_link_max = 2147483647;
unsigned char __gnat_objlist_file_supported = 0; unsigned char __gnat_objlist_file_supported = 0;
unsigned char __gnat_using_gnu_linker = 0; unsigned char __gnat_using_gnu_linker = 0;
const char *__gnat_object_library_extension = ".a"; const char *__gnat_object_library_extension = ".a";
unsigned char __gnat_separate_run_path_options = 0;
#elif defined (__FreeBSD__) #elif defined (__FreeBSD__)
const char *__gnat_object_file_option = ""; const char *__gnat_object_file_option = "";
...@@ -151,6 +161,7 @@ int __gnat_link_max = 8192; ...@@ -151,6 +161,7 @@ int __gnat_link_max = 8192;
unsigned char __gnat_objlist_file_supported = 1; unsigned char __gnat_objlist_file_supported = 1;
unsigned char __gnat_using_gnu_linker = 1; unsigned char __gnat_using_gnu_linker = 1;
const char *__gnat_object_library_extension = ".a"; const char *__gnat_object_library_extension = ".a";
unsigned char __gnat_separate_run_path_options = 0;
#elif defined (__APPLE__) #elif defined (__APPLE__)
const char *__gnat_object_file_option = "-Wl,-filelist,"; const char *__gnat_object_file_option = "-Wl,-filelist,";
...@@ -160,6 +171,7 @@ int __gnat_link_max = 262144; ...@@ -160,6 +171,7 @@ int __gnat_link_max = 262144;
unsigned char __gnat_objlist_file_supported = 1; unsigned char __gnat_objlist_file_supported = 1;
unsigned char __gnat_using_gnu_linker = 0; unsigned char __gnat_using_gnu_linker = 0;
const char *__gnat_object_library_extension = ".a"; const char *__gnat_object_library_extension = ".a";
unsigned char __gnat_separate_run_path_options = 1;
#elif defined (linux) || defined(__GLIBC__) #elif defined (linux) || defined(__GLIBC__)
const char *__gnat_object_file_option = ""; const char *__gnat_object_file_option = "";
...@@ -169,6 +181,7 @@ int __gnat_link_max = 8192; ...@@ -169,6 +181,7 @@ int __gnat_link_max = 8192;
unsigned char __gnat_objlist_file_supported = 1; unsigned char __gnat_objlist_file_supported = 1;
unsigned char __gnat_using_gnu_linker = 1; unsigned char __gnat_using_gnu_linker = 1;
const char *__gnat_object_library_extension = ".a"; const char *__gnat_object_library_extension = ".a";
unsigned char __gnat_separate_run_path_options = 0;
#elif defined (__svr4__) && defined (i386) #elif defined (__svr4__) && defined (i386)
const char *__gnat_object_file_option = ""; const char *__gnat_object_file_option = "";
...@@ -178,6 +191,7 @@ int __gnat_link_max = 2147483647; ...@@ -178,6 +191,7 @@ int __gnat_link_max = 2147483647;
unsigned char __gnat_objlist_file_supported = 0; unsigned char __gnat_objlist_file_supported = 0;
unsigned char __gnat_using_gnu_linker = 0; unsigned char __gnat_using_gnu_linker = 0;
const char *__gnat_object_library_extension = ".a"; const char *__gnat_object_library_extension = ".a";
unsigned char __gnat_separate_run_path_options = 0;
#else #else
...@@ -190,4 +204,5 @@ int __gnat_link_max = 2147483647; ...@@ -190,4 +204,5 @@ int __gnat_link_max = 2147483647;
unsigned char __gnat_objlist_file_supported = 0; unsigned char __gnat_objlist_file_supported = 0;
unsigned char __gnat_using_gnu_linker = 0; unsigned char __gnat_using_gnu_linker = 0;
const char *__gnat_object_library_extension = ".a"; const char *__gnat_object_library_extension = ".a";
unsigned char __gnat_separate_run_path_options = 0;
#endif #endif
...@@ -36,6 +36,7 @@ with Gnatvsn; use Gnatvsn; ...@@ -36,6 +36,7 @@ with Gnatvsn; use Gnatvsn;
with Hostparm; use Hostparm; with Hostparm; use Hostparm;
with Makeusg; with Makeusg;
with Makeutl; use Makeutl; with Makeutl; use Makeutl;
with MLib;
with MLib.Prj; with MLib.Prj;
with MLib.Tgt; use MLib.Tgt; with MLib.Tgt; use MLib.Tgt;
with MLib.Utl; with MLib.Utl;
...@@ -6361,53 +6362,85 @@ package body Make is ...@@ -6361,53 +6362,85 @@ package body Make is
Current : Natural; Current : Natural;
begin begin
for Index in if MLib.Separate_Run_Path_Options then
Library_Paths.First .. Library_Paths.Last
loop -- We are going to create one switch of the form
-- Add the length of the library dir plus one -- "-Wl,-rpath,dir_N" for each directory to
-- for the directory separator. -- consider.
Length := -- One switch for each library directory
Length +
Library_Paths.Table (Index)'Length + 1; for Index in
end loop; Library_Paths.First .. Library_Paths.Last
loop
Linker_Switches.Increment_Last;
Linker_Switches.Table
(Linker_Switches.Last) := new String'
(Path_Option.all &
Library_Paths.Table (Index).all);
end loop;
-- Finally, add the length of the standard GNAT -- One switch for the standard GNAT library dir.
-- library dir.
Length := Length + MLib.Utl.Lib_Directory'Length; Linker_Switches.Increment_Last;
Option := new String (1 .. Length); Linker_Switches.Table
Option (1 .. Path_Option'Length) := Path_Option.all; (Linker_Switches.Last) := new String'
Current := Path_Option'Length; (Path_Option.all & MLib.Utl.Lib_Directory);
-- Put each library dir followed by a dir separator else
-- We are going to create one switch of the form
-- "-Wl,-rpath,dir_1:dir_2:dir_3"
for Index in
Library_Paths.First .. Library_Paths.Last
loop
-- Add the length of the library dir plus one
-- for the directory separator.
Length :=
Length +
Library_Paths.Table (Index)'Length + 1;
end loop;
for Index in -- Finally, add the length of the standard GNAT
Library_Paths.First .. Library_Paths.Last -- library dir.
loop
Option Length := Length + MLib.Utl.Lib_Directory'Length;
(Current + 1 .. Option := new String (1 .. Length);
Option (1 .. Path_Option'Length) :=
Path_Option.all;
Current := Path_Option'Length;
-- Put each library dir followed by a dir
-- separator.
for Index in
Library_Paths.First .. Library_Paths.Last
loop
Option
(Current + 1 ..
Current +
Library_Paths.Table (Index)'Length) :=
Library_Paths.Table (Index).all;
Current :=
Current + Current +
Library_Paths.Table (Index)'Length) := Library_Paths.Table (Index)'Length + 1;
Library_Paths.Table (Index).all; Option (Current) := Path_Separator;
Current := end loop;
Current +
Library_Paths.Table (Index)'Length + 1;
Option (Current) := Path_Separator;
end loop;
-- Finally put the standard GNAT library dir -- Finally put the standard GNAT library dir
Option Option
(Current + 1 .. (Current + 1 ..
Current + MLib.Utl.Lib_Directory'Length) := Current + MLib.Utl.Lib_Directory'Length) :=
MLib.Utl.Lib_Directory; MLib.Utl.Lib_Directory;
-- And add the switch to the linker switches -- And add the switch to the linker switches
Linker_Switches.Increment_Last; Linker_Switches.Increment_Last;
Linker_Switches.Table (Linker_Switches.Last) := Linker_Switches.Table (Linker_Switches.Last) :=
Option; Option;
end if;
end; end;
end if; end if;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1999-2008, AdaCore -- -- Copyright (C) 1999-2009, AdaCore --
-- -- -- --
-- 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- --
...@@ -442,6 +442,19 @@ package body MLib is ...@@ -442,6 +442,19 @@ package body MLib is
end if; end if;
end Major_Id_Name; end Major_Id_Name;
-------------------------------
-- Separate_Run_Path_Options --
-------------------------------
function Separate_Run_Path_Options return Boolean is
Separate_Paths : Boolean;
for Separate_Paths'Size use Character'Size;
pragma Import (C, Separate_Paths, "__gnat_separate_run_path_options");
begin
return Separate_Paths;
end Separate_Run_Path_Options;
-- Package elaboration -- Package elaboration
begin begin
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 1999-2008, AdaCore -- -- Copyright (C) 1999-2009, AdaCore --
-- -- -- --
-- 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- --
...@@ -84,6 +84,10 @@ package MLib is ...@@ -84,6 +84,10 @@ package MLib is
-- For example, if Lib_Filename is "libtoto.so" and Lib_Version is -- For example, if Lib_Filename is "libtoto.so" and Lib_Version is
-- "libtoto.so.1.2", then "libtoto.so.1" is returned. -- "libtoto.so.1.2", then "libtoto.so.1" is returned.
function Separate_Run_Path_Options return Boolean;
-- Return True if separate rpath arguments must be passed to the linker
-- for each directory in the rpath.
private private
Preserve : Attribute := Time_Stamps; Preserve : Attribute := Time_Stamps;
......
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