To avoid using an existing shared library file instead of an archive from a static library project, the link command for executable now use the full paths of archives instead of the switches -L<library dir> -l<library name>. To test this, on Linux, link an executable that uses an archive coming from a static library project, which has in its library directory the shared version of the library. Verify that the shared library is not used by the executable.
Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-02 Vincent Celier <cel...@adacore.com> * make.adb (Gnatmake): use <library dir>/lib<library name>.a to link with an archive instead of -L<library dir> -l<library name>.
Index: make.adb =================================================================== --- make.adb (revision 177035) +++ make.adb (working copy) @@ -6066,24 +6066,41 @@ end loop; for Index in 1 .. Library_Projs.Last loop + if + Library_Projs.Table (Index).Library_Kind = Static + then + Linker_Switches.Increment_Last; + Linker_Switches.Table (Linker_Switches.Last) := + new String' + (Get_Name_String + (Library_Projs.Table (Index). + Library_Dir.Display_Name) & + Directory_Separator & + "lib" & + Get_Name_String + (Library_Projs.Table (Index). + Library_Name) & + ".a"); - -- Add the -L switch + else + -- Add the -L switch - Linker_Switches.Increment_Last; - Linker_Switches.Table (Linker_Switches.Last) := - new String'("-L" & - Get_Name_String - (Library_Projs.Table (Index). - Library_Dir.Display_Name)); + Linker_Switches.Increment_Last; + Linker_Switches.Table (Linker_Switches.Last) := + new String'("-L" & + Get_Name_String + (Library_Projs.Table (Index). + Library_Dir.Display_Name)); - -- Add the -l switch + -- Add the -l switch - Linker_Switches.Increment_Last; - Linker_Switches.Table (Linker_Switches.Last) := - new String'("-l" & - Get_Name_String - (Library_Projs.Table (Index). - Library_Name)); + Linker_Switches.Increment_Last; + Linker_Switches.Table (Linker_Switches.Last) := + new String'("-l" & + Get_Name_String + (Library_Projs.Table (Index). + Library_Name)); + end if; end loop; end if;