Subject: Re: bug#54020: Impossible to pass `-no-suppress` to `libtool` via automake files

From: Mike Frysinger <[email-masked]>
Date: Thu, 18 Jan 2024 20:55:18 -0500

On 17 Jan 2024 00:11, Mike Frysinger wrote:
> On 15 Feb 2022 23:03, Damian Szuberski wrote:
> > A standard `libtool` invocation line generated by automake looks like:
> > ```
> > LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
> >         $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
> >         $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
> >         $(AM_CFLAGS) $(CFLAGS)
> > ```
> > Sometimes files compiled using the method above make the compiler emit
> > errors. Those errors are suppressed by default which makes troubleshooting
> > impossible. `libtool` has a command line option, `-no-suppress` which can
> > be used to make the compiler verbose. Unfortunately, there is no way to
> > inject that option since `libtool` demands that it comes after
> > `--mode=compile`. `AM_LIBTOOLFLAGS` nor `LIBTOOLFLAGS` cannot be used for
> > that purpose since "it is too early", according to `libtool`'s command line
> > parser. It is somewhat possible to use `AM_CFLAGS` for that purpose but
> > then it breaks modes other than `--mode=compile`.
> 
> i was reading the libtool manual today and was reminded that libtool processes
> some standard options straight out of the wrapped command rather than forcing
> you to split things up.  for example, it detects the -o option and parses that.
> then i was reminded that when passing libtool linker options like -no-undefined,
> you simply add them to the standard LDFLAGS.
> 
> which is to say, options like -no-suppress do not need exact placement.  put it
> in existing CFLAGS variables as makes sense for your target.
> 	AM_CFLAGS = -no-suppress
> or
> 	libfoo_la_CFLAGS = $(AM_CFLAGS) -no-suppress
> and libtool should parse & discard it before invoking the underlying compiler.

the Automake manual has libtool examples for general & linking flags,
but nothing for compiling.  we could add some to make it more clear.
-mike