From: Piotr Trojanek <[email protected]>

We had a complicated, ancient workaround for gnatmake that simply hardcoded
library names to "libXXX.a".

Note: if we ever wanted to make this platform-specific, it should probably use
__gnat_object_library_extension, which is currently used by gnatlink, but is
equal to "libXXX.a" on every platform except for VMS, which is unsupported.

gcc/ada/ChangeLog:

        * adaint.c (__gnat_library_template): Move logic to gnatmake.
        * make.adb (Get_Library_File): Use simple single template.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/adaint.c | 30 ------------------------------
 gcc/ada/make.adb | 41 ++---------------------------------------
 2 files changed, 2 insertions(+), 69 deletions(-)

diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c
index a290a22a62b..9e349d6907c 100644
--- a/gcc/ada/adaint.c
+++ b/gcc/ada/adaint.c
@@ -315,36 +315,6 @@ char __gnat_dir_separator = DIR_SEPARATOR;
 
 char __gnat_path_separator = PATH_SEPARATOR;
 
-/* The GNAT_LIBRARY_TEMPLATE contains a list of expressions that define
-   the base filenames that libraries specified with -lsomelib options
-   may have. This is used by GNATMAKE to check whether an executable
-   is up-to-date or not. The syntax is
-
-     library_template ::= { pattern ; } pattern NUL
-     pattern          ::= [ prefix ] * [ postfix ]
-
-   These should only specify names of static libraries as it makes
-   no sense to determine at link time if dynamic-link libraries are
-   up to date or not. Any libraries that are not found are supposed
-   to be up-to-date:
-
-     * if they are needed but not present, the link
-       will fail,
-
-     * otherwise they are libraries in the system paths and so
-       they are considered part of the system and not checked
-       for that reason.
-
-   ??? This should be part of a GNAT host-specific compiler
-       file instead of being included in all user applications
-       as well. This is only a temporary work-around for 3.11b.  */
-
-#ifndef GNAT_LIBRARY_TEMPLATE
-#define GNAT_LIBRARY_TEMPLATE "lib*.a"
-#endif
-
-const char *__gnat_library_template = GNAT_LIBRARY_TEMPLATE;
-
 #if defined (__vxworks)
 #define GNAT_MAX_PATH_LEN PATH_MAX
 
diff --git a/gcc/ada/make.adb b/gcc/ada/make.adb
index 5d60aff8325..c17718f22e4 100644
--- a/gcc/ada/make.adb
+++ b/gcc/ada/make.adb
@@ -1433,12 +1433,6 @@ package body Make is
       --  on the name specified with the -l linker option, using the
       --  Ada object path. Return No_File if no such file can be found.
 
-      type Char_Array is array (Natural) of Character;
-      type Char_Array_Access is access constant Char_Array;
-
-      Template : Char_Array_Access;
-      pragma Import (C, Template, "__gnat_library_template");
-
       ----------------
       -- Check_File --
       ----------------
@@ -1512,41 +1506,10 @@ package body Make is
       -- Get_Library_Name --
       ----------------------
 
-      --  See comments in a-adaint.c about template syntax
-
       function Get_Library_File (Name : String) return File_Name_Type is
-         File : File_Name_Type := No_File;
-
+         Library_Name : constant String := "lib" & Name & ".a";
       begin
-         Name_Len := 0;
-
-         for Ptr in Template'Range loop
-            case Template (Ptr) is
-               when '*' =>
-                  Add_Str_To_Name_Buffer (Name);
-
-               when ';' =>
-                  File := Full_Lib_File_Name (Name_Find);
-                  exit when File /= No_File;
-                  Name_Len := 0;
-
-               when NUL =>
-                  exit;
-
-               when others =>
-                  Add_Char_To_Name_Buffer (Template (Ptr));
-            end case;
-         end loop;
-
-         --  The for loop exited because the end of the template
-         --  was reached. File contains the last possible file name
-         --  for the library.
-
-         if File = No_File and then Name_Len > 0 then
-            File := Full_Lib_File_Name (Name_Find);
-         end if;
-
-         return File;
+         return Full_Lib_File_Name (Name_Find (Library_Name));
       end Get_Library_File;
 
    --  Start of processing for Check_Linker_Options
-- 
2.53.0

Reply via email to