]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Extend the linker's error message for missing libraries if there is an almost match.
authorNick Clifton <nickc@redhat.com>
Wed, 1 Apr 2020 16:25:28 +0000 (17:25 +0100)
committerNick Clifton <nickc@redhat.com>
Wed, 1 Apr 2020 16:25:28 +0000 (17:25 +0100)
PR ld/25747
* ldfile.c (ldfile_open_file): If a search for a library fails,
but there is a file that would match if it had a "lib" prefix to
its name, then tell the user.

ld/ChangeLog
ld/ldfile.c

index 16ffc3034885e6313e2594e29a1af1bc1ff8f4b0..b1e9f530c16f92d6cd8e8aa55c956314fab9eb00 100644 (file)
@@ -1,3 +1,10 @@
+2020-04-01  Nick Clifton  <nickc@redhat.com>
+
+       PR ld/25747
+       * ldfile.c (ldfile_open_file): If a search for a library fails,
+       but there is a file that would match if it had a "lib" prefix to
+       its name, then tell the user.
+
 2020-04-01  Tamar Christina  <tamar.christina@arm.com>
 
        PR ld/16017
index aa84906992bbc75cdf338776e2ec092719269ea6..3248a0460780a14252fddcbefcbba2bf74235c24 100644 (file)
@@ -445,6 +445,22 @@ ldfile_open_file (lang_input_statement_type *entry)
                   entry->local_sym_name, ld_sysroot);
          else
            einfo (_("%P: cannot find %s\n"), entry->local_sym_name);
+
+         /* PR 25747: Be kind to users who forgot to add the
+            "lib" prefix to their library when it was created.  */
+         for (arch = search_arch_head; arch != NULL; arch = arch->next)
+           {
+             if (ldfile_open_file_search (arch->name, entry, "", ".a"))
+               {
+                 const char * base = lbasename (entry->filename);
+
+                 einfo (_("%P: note to link with %s use use -l:%s or rename it to lib%s\n"),
+                        entry->filename, base, base);
+                 bfd_close (entry->the_bfd);
+                 entry->the_bfd = NULL;
+                 break;
+               }
+           }
          entry->flags.missing_file = TRUE;
          input_flags.missing_file = TRUE;
        }