This is the mail archive of the binutils@sources.redhat.com 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]

Re: Patch to add --warn-error flag to ld


Could I please get some feedback on this patch?  I'd be happy if I
knew that at least it was in someone's queue.
        
        --jtc

>>>>> "jtc" == J T Conklin <jtc@redback.com> writes:
jtc> Since it seems some of my users don't seem to notice linker warnings,
jtc> I'd like to add a flag to turn warnings to errors, similar to gcc's
jtc> -Werror.
jtc>
jtc> The enclosed patch is submitted for consideration.  In vfinfo(),
jtc> config.make_executable is set to false when config.warn_error is true.
jtc> It may be better to move this check from vfinfo() to einfo(), so that
jtc> calls to info_msg() (which may be benign messages, rather than warnings)
jtc> don't cause the link to fail.
jtc>
jtc>         --jtc
jtc>
jtc> 2001-03-06  J.T. Conklin  <jtc@redback.com>
jtc>
jtc> 	* ld.texinfo: Document --warn-error.
jtc>
jtc> 	* ldmisc.c (vfinfo): Set flag to inhibit making executable if
jtc>  	warnings have been turned into errors.
jtc> 	* lexsup.c (OPTION_WARN_ERROR): Define.
jtc> 	(ld_options): Entry for --warn-error.
jtc> 	(parse_args): Handle OPTION_WARN_ERROR.
jtc> 	* ld.h (ld_config_type): Add warn_error.
jtc>
jtc> Index: ld.h
jtc> ===================================================================
jtc> RCS file: /cvs/src/src/ld/ld.h,v
jtc> retrieving revision 1.9
jtc> diff -c -r1.9 ld.h
jtc> *** ld.h	2000/10/09 15:09:17	1.9
jtc> --- ld.h	2001/03/06 23:20:09
jtc> ***************
jtc> *** 192,197 ****
jtc> --- 192,200 ----
jtc>        changes due to the alignment of an input section.  */
jtc>     boolean warn_section_align;
  
jtc> +   /* If true, warning messages are fatal */
jtc> +   boolean warn_error;
jtc> + 
jtc>     boolean sort_common;
  
jtc>     boolean text_read_only;
jtc> Index: ld.texinfo
jtc> ===================================================================
jtc> RCS file: /cvs/src/src/ld/ld.texinfo,v
jtc> retrieving revision 1.33
jtc> diff -c -r1.33 ld.texinfo
jtc> *** ld.texinfo	2001/01/14 04:36:34	1.33
jtc> --- ld.texinfo	2001/03/06 23:20:13
jtc> ***************
jtc> *** 1245,1250 ****
jtc> --- 1245,1254 ----
jtc>   is only meaningful on ELF platforms which support shared libraries.
jtc>   @xref{VERSION}.
  
jtc> + @kindex --warn-error
jtc> + @item --warn-error
jtc> + Make all warnings into errors.
jtc> + 
jtc>   @kindex --warn-comon
jtc>   @cindex warnings, on combining symbols
jtc>   @cindex combining symbols, warnings on
jtc> Index: ldmisc.c
jtc> ===================================================================
jtc> RCS file: /cvs/src/src/ld/ldmisc.c,v
jtc> retrieving revision 1.4
jtc> diff -c -r1.4 ldmisc.c
jtc> *** ldmisc.c	2000/09/21 20:21:59	1.4
jtc> --- ldmisc.c	2001/03/06 23:20:14
jtc> ***************
jtc> *** 399,404 ****
jtc> --- 399,407 ----
jtc>   	}
jtc>       }
  
jtc> +   if (config.warn_error)
jtc> +     config.make_executable = false;
jtc> + 
jtc>     if (fatal == true)
jtc>       xexit (1);
jtc>   }
jtc> Index: lexsup.c
jtc> ===================================================================
jtc> RCS file: /cvs/src/src/ld/lexsup.c,v
jtc> retrieving revision 1.29
jtc> diff -c -r1.29 lexsup.c
jtc> *** lexsup.c	2001/01/14 04:36:34	1.29
jtc> --- lexsup.c	2001/03/06 23:20:16
jtc> ***************
jtc> *** 108,114 ****
jtc>   #define OPTION_VERSION_EXPORTS_SECTION	(OPTION_VERSION_SCRIPT + 1)
jtc>   #define OPTION_WARN_COMMON		(OPTION_VERSION_EXPORTS_SECTION + 1)
jtc>   #define OPTION_WARN_CONSTRUCTORS	(OPTION_WARN_COMMON + 1)
jtc> ! #define OPTION_WARN_MULTIPLE_GP		(OPTION_WARN_CONSTRUCTORS + 1)
jtc>   #define OPTION_WARN_ONCE		(OPTION_WARN_MULTIPLE_GP + 1)
jtc>   #define OPTION_WARN_SECTION_ALIGN	(OPTION_WARN_ONCE + 1)
jtc>   #define OPTION_SPLIT_BY_RELOC		(OPTION_WARN_SECTION_ALIGN + 1)
jtc> --- 108,115 ----
jtc>   #define OPTION_VERSION_EXPORTS_SECTION	(OPTION_VERSION_SCRIPT + 1)
jtc>   #define OPTION_WARN_COMMON		(OPTION_VERSION_EXPORTS_SECTION + 1)
jtc>   #define OPTION_WARN_CONSTRUCTORS	(OPTION_WARN_COMMON + 1)
jtc> ! #define OPTION_WARN_ERROR		(OPTION_WARN_CONSTRUCTORS + 1)
jtc> ! #define OPTION_WARN_MULTIPLE_GP		(OPTION_WARN_ERROR + 1)
jtc>   #define OPTION_WARN_ONCE		(OPTION_WARN_MULTIPLE_GP + 1)
jtc>   #define OPTION_WARN_SECTION_ALIGN	(OPTION_WARN_ONCE + 1)
jtc>   #define OPTION_SPLIT_BY_RELOC		(OPTION_WARN_SECTION_ALIGN + 1)
jtc> ***************
jtc> *** 377,382 ****
jtc> --- 378,386 ----
jtc>     { {"warn-constructors", no_argument, NULL, OPTION_WARN_CONSTRUCTORS},
jtc>         '\0', NULL, N_("Warn if global constructors/destructors are seen"),
jtc>         TWO_DASHES },
jtc> +   { {"warn-error", no_argument, NULL, OPTION_WARN_ERROR},
jtc> +      '\0', NULL, N_("Warning messages are fatal"),
jtc> +      TWO_DASHES },
jtc>     { {"warn-multiple-gp", no_argument, NULL, OPTION_WARN_MULTIPLE_GP},
jtc>         '\0', NULL, N_("Warn if the multiple GP values are used"), TWO_DASHES },
jtc>     { {"warn-once", no_argument, NULL, OPTION_WARN_ONCE},
jtc> ***************
jtc> *** 1027,1032 ****
jtc> --- 1031,1039 ----
jtc>   	  break;
jtc>   	case OPTION_WARN_CONSTRUCTORS:
jtc>   	  config.warn_constructors = true;
jtc> + 	  break;
jtc> + 	case OPTION_WARN_ERROR:
jtc> + 	  config.warn_error = true;
jtc>   	  break;
jtc>   	case OPTION_WARN_MULTIPLE_GP:
jtc>   	  config.warn_multiple_gp = true;



-- 
J.T. Conklin
RedBack Networks


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