Commit: Add linker diagnostic message about missing static libraries

Message ID 87ldwpm233.fsf@redhat.com
State New
Headers
Series Commit: Add linker diagnostic message about missing static libraries |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 fail Patch failed to apply

Commit Message

Nick Clifton Dec. 9, 2024, 1:13 p.m. UTC
  Hi Guys,

  I am applying the patch below in response to a user request for a more
  helpful error message from the linker if it fails to find a static
  library.  (The request is RHEL-69758 for those with access to the RHEL
  jira system).

Cheers
  Nick
  

Patch

diff --git a/ld/ldfile.c b/ld/ldfile.c
index f1107a1b7d7..050f505c31e 100644
--- a/ld/ldfile.c
+++ b/ld/ldfile.c
@@ -711,6 +711,12 @@  ldfile_open_file (lang_input_statement_type *entry)
 	  else
 	    einfo (_("%P: cannot find %s: %E\n"), entry->local_sym_name);
 
+	  /* Be kind to users who are creating static executables, but
+	     have forgotten to install the necessary static libraries.  */
+	  if (entry->flags.dynamic == false && startswith (entry->local_sym_name, "-l"))
+	    einfo (_("%P: have you installed the static version of the %s library ?\n"),
+		     entry->local_sym_name + 2);
+
 	  /* 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)