This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

optionally silence a linker warning


This patch adds a new linker option to silence the "skipping
incompatible <library> when searching for <library name>" warning.

	* ld.texinfo (--no-warn-search-mismatch): Document.
	* ldfile.c (ldfile_try_open_bfd): Don't warn about skipping
	incompatible libraries if --no-warn-search-mismatch.
	* ld.h (args_type): Add warn_search_mismatch.
	* ldmain.c (main): Init it.
	* lexsup.c (enum option_values): Add OPTION_NO_WARN_SEARCH_MISMATCH.
	(ld_options): Add entry for --no-warn-search-mismatch.
	(parse_args): Handle OPTION_NO_WARN_SEARCH_MISMATCH.

Index: ld/ld.texinfo
===================================================================
RCS file: /cvs/src/src/ld/ld.texinfo,v
retrieving revision 1.193
diff -u -p -r1.193 ld.texinfo
--- ld/ld.texinfo	30 Apr 2007 14:06:40 -0000	1.193
+++ ld/ld.texinfo	3 May 2007 08:56:06 -0000
@@ -1390,6 +1390,11 @@ errors.  This option should only be used
 have taken some special action that ensures that the linker errors are
 inappropriate.
 
+@kindex --no-warn-search-mismatch
+@item --no-warn-search-mismatch
+Normally @command{ld} will give a warning if it finds an incompatible
+library during a library search.  This option silences the warning.
+
 @kindex --no-whole-archive
 @item --no-whole-archive
 Turn off the effect of the @option{--whole-archive} option for subsequent
Index: ld/ld.h
===================================================================
RCS file: /cvs/src/src/ld/ld.h,v
retrieving revision 1.37
diff -u -p -r1.37 ld.h
--- ld/ld.h	28 Mar 2007 14:42:27 -0000	1.37
+++ ld/ld.h	3 May 2007 08:56:01 -0000
@@ -177,6 +177,10 @@ typedef struct {
      files.  */
   bfd_boolean warn_mismatch;
 
+  /* Warn on attempting to open an incompatible library during a library
+     search.  */
+  bfd_boolean warn_search_mismatch;
+
   /* Name of shared object whose symbol table should be filtered with
      this shared object.  From the --filter option.  */
   char *filter_shlib;
Index: ld/ldfile.c
===================================================================
RCS file: /cvs/src/src/ld/ldfile.c,v
retrieving revision 1.41
diff -u -p -r1.41 ldfile.c
--- ld/ldfile.c	26 Apr 2007 14:46:59 -0000	1.41
+++ ld/ldfile.c	3 May 2007 08:56:06 -0000
@@ -252,8 +252,10 @@ ldfile_try_open_bfd (const char *attempt
 		  yyin = NULL;
 		  if (skip)
 		    {
-		      einfo (_("%P: skipping incompatible %s when searching for %s\n"),
-			     attempt, entry->local_sym_name);
+		      if (command_line.warn_search_mismatch)
+			einfo (_("%P: skipping incompatible %s "
+				 "when searching for %s\n"),
+			       attempt, entry->local_sym_name);
 		      bfd_close (entry->the_bfd);
 		      entry->the_bfd = NULL;
 		      return FALSE;
@@ -279,8 +281,10 @@ ldfile_try_open_bfd (const char *attempt
 		    && bfd_get_flavour (output_bfd) == bfd_target_xcoff_flavour
 		    && bfd_check_format (entry->the_bfd, bfd_archive)))
 	    {
-	      einfo (_("%P: skipping incompatible %s when searching for %s\n"),
-		     attempt, entry->local_sym_name);
+	      if (command_line.warn_search_mismatch)
+		einfo (_("%P: skipping incompatible %s "
+			 "when searching for %s\n"),
+		       attempt, entry->local_sym_name);
 	      bfd_close (entry->the_bfd);
 	      entry->the_bfd = NULL;
 	      return FALSE;
Index: ld/ldmain.c
===================================================================
RCS file: /cvs/src/src/ld/ldmain.c,v
retrieving revision 1.121
diff -u -p -r1.121 ldmain.c
--- ld/ldmain.c	30 Apr 2007 14:06:40 -0000	1.121
+++ ld/ldmain.c	3 May 2007 08:56:07 -0000
@@ -257,6 +257,7 @@ main (int argc, char **argv)
   command_line.interpreter = NULL;
   command_line.rpath = NULL;
   command_line.warn_mismatch = TRUE;
+  command_line.warn_search_mismatch = TRUE;
   command_line.check_section_addresses = TRUE;
   command_line.accept_unknown_input_arch = FALSE;
   command_line.symbolic = symbolic_unset;
Index: ld/lexsup.c
===================================================================
RCS file: /cvs/src/src/ld/lexsup.c,v
retrieving revision 1.99
diff -u -p -r1.99 lexsup.c
--- ld/lexsup.c	26 Apr 2007 14:46:59 -0000	1.99
+++ ld/lexsup.c	3 May 2007 08:56:08 -0000
@@ -83,6 +83,7 @@ enum option_values
   OPTION_NO_DEMANGLE,
   OPTION_NO_KEEP_MEMORY,
   OPTION_NO_WARN_MISMATCH,
+  OPTION_NO_WARN_SEARCH_MISMATCH,
   OPTION_NOINHIBIT_EXEC,
   OPTION_NON_SHARED,
   OPTION_NO_WHOLE_ARCHIVE,
@@ -428,6 +429,10 @@ static const struct ld_option ld_options
     TWO_DASHES },
   { {"no-warn-mismatch", no_argument, NULL, OPTION_NO_WARN_MISMATCH},
     '\0', NULL, N_("Don't warn about mismatched input files"), TWO_DASHES},
+  { {"no-warn-search-mismatch", no_argument, NULL,
+     OPTION_NO_WARN_SEARCH_MISMATCH},
+    '\0', NULL, N_("Don't warn on finding an incompatible library"),
+    TWO_DASHES},
   { {"no-whole-archive", no_argument, NULL, OPTION_NO_WHOLE_ARCHIVE},
     '\0', NULL, N_("Turn off --whole-archive"), TWO_DASHES },
   { {"noinhibit-exec", no_argument, NULL, OPTION_NOINHIBIT_EXEC},
@@ -963,6 +968,9 @@ parse_args (unsigned argc, char **argv)
 	case OPTION_NO_WARN_MISMATCH:
 	  command_line.warn_mismatch = FALSE;
 	  break;
+	case OPTION_NO_WARN_SEARCH_MISMATCH:
+	  command_line.warn_search_mismatch = FALSE;
+	  break;
 	case OPTION_NOINHIBIT_EXEC:
 	  force_make_executable = TRUE;
 	  break;

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]