RFC: Document unexpected behaviour of --fatal-warnings

Serge Guelton serge.guelton@telecom-bretagne.eu
Wed Jan 24 15:07:47 GMT 2024


On Tue, Jan 23, 2024 at 12:28:17PM +0000, Nick Clifton wrote:
> Hi Guys,
> 
>   It was recently pointed out to me that the bfd linker's
>   --fatal-warnings option can behave in an unexpected manner.  For
>   example:
> 
>     $ ld.bfd -z bad-option --fatal-warnings -e 0/dev/null
>     ld.bfd: warning: -z bad-option ignored
>     $ echo $?
>     0
> 
>   ie the warning about the ignored option is not being treated as an
>   error.  This happens because the --fatal-warnings option only takes
>   affect after it has been processed, and we process the options in a
>   linear order.  So the following works:
> 
>     $ ld.bfd --fatal-warnings -z bad-option -e 0 /dev/null
>     ld.bfd: warning: -z bad-option ignored
>     $ echo $?
>     1
> 
>   This behaviour differs from gold and lld, both of which honour
>   --fatal-warnings no matter where it occurs on the command line.
> 
>   So we could fix the linker, create a two pass argument scan and the
>   problem would be solved.  But a) I am lazy and b) we already have a

Hey Nick,

In case you're worried about doing two passes, you could also record the fact
that a warning has been raised in a boolean somewhere, and choke on it if
--fatal-warnings was specified.

Anyway, thanks for fighting the lazyness and making the effort of looking into
this ;-)




More information about the Binutils mailing list