This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

Re: RFA: Warn when running LTO compiler without any optimization level set


On Fri, Apr 9, 2010 at 5:19 PM, Nick Clifton <nickc@redhat.com> wrote:
> Hi Guys,
>
> ?Running the LTO compiler without enabling any optimizations is not
> ?very useful, but it can happen if the user forgets to include a -O<n>
> ?setting on the linker command line. ?(Or as happened to me, a
> ?testsuite harness has separate settings for the compiler and linker
> ?command lines and although -flto has been added to both, -03 was only
> ?added to the compiler command line).
>
> ?The attached patch adds a warning message for this particular
> ?circumstance:
>
> ? ?lto1: warning: -flto used without an optimization level set - was this intentional ?
>
> ?At the moment this warning can only be disabled by adding -O<n> (where
> ?<n> is not zero), -Os or -w to the command line. ?I could add a
> ?specific warning enable/disable option to control it, but this seemed
> ?like overkill.
>
> ?Tested without regressions on an i686-pc-linux-gnu toolchain.
>
> ?OK to apply ?

This will break all testing as we test with -O0 and -O2.  I don't
think this is a good idea anyway.

Richard.

> Cheers
> ?Nick
>
> gcc/lto/ChangeLog
> 2010-04-09 ?Nick Clifton ?<nickc@redhat.com>
>
> ? ? ? ?* lto-lang.c (lto_init): Warn if the LTO compiler is run without
> ? ? ? ?any optimizations enabled.
>
> Index: gcc/lto/lto-lang.c
> ===================================================================
> --- gcc/lto/lto-lang.c ?(revision 158149)
> +++ gcc/lto/lto-lang.c ?(working copy)
> @@ -1031,6 +1031,22 @@
> ?static bool
> ?lto_init (void)
> ?{
> + ?/* It is pointless to invoke LTO without any kind of optimization enabled.
> + ? ? So if the optimization level is zero we issue a warning message to the
> + ? ? user.
> +
> + ? ? If the user is only interested in enabling specific optimizations and
> + ? ? they are bugged by this warning they can add -w to the command line.
> + ? ? FIXME: Do we need a -Wlto option to allow this warning to be enabled/
> + ? ? disabled explicitly ?
> +
> + ? ? Note, we have to perform this test here, rather than in
> + ? ? opts.c:decode_options, because there is no way to tell that we are
> + ? ? running as the LTO compiler in that function. ?*/
> + ?if (optimize == 0)
> + ? ?warning_at (UNKNOWN_LOCATION, 0, "-flto used on object files without an "
> + ? ? ? ? ? ? ? "optimization level set - was this intentional ?");
> +
> ? /* We need to generate LTO if running in WPA mode. ?*/
> ? flag_generate_lto = flag_wpa;
>
>


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