[PATCH 1/2] Fix -fno-lto (PR lto/46905)
Richard Guenther
richard.guenther@gmail.com
Thu Dec 16 13:29:00 GMT 2010
On Thu, Dec 16, 2010 at 1:41 PM, Andi Kleen <andi@firstfloor.org> wrote:
> From: Andi Kleen <ak@linux.intel.com>
>
> This fixes PR lto/46905.
>
> It's sometimes convenient in large Makefiles to globally enable LTO
> in CFLAGS, but disable it again for specific files. The simplest
> way to do that is appending -fno-lto, but that didn't work.
> Add explicit code to handle this case.
>
> Passes bootstrap and full test on x86_64-linux. Ok?
Do you really need the common.opt and opts.c hunks?
> gcc/
>
> 2010-12-15 Andi Kleen <ak@linux.intel.com>
>
> PR lto/46905
> * collect2.c (main): Handle -fno-lto.
> * common.opt (fno-lto): Add.
> * opts.c (common_handle_option): Handle OPT_fno_lto.
> ---
> gcc/collect2.c | 2 ++
> gcc/common.opt | 4 ++++
> gcc/opts.c | 4 ++++
> 3 files changed, 10 insertions(+), 0 deletions(-)
>
> diff --git a/gcc/collect2.c b/gcc/collect2.c
> index 89b21d5..77f794f 100644
> --- a/gcc/collect2.c
> +++ b/gcc/collect2.c
> @@ -1211,6 +1211,8 @@ main (int argc, char **argv)
> else if ((! strncmp (argv[i], "-flto=", 6)
> || ! strcmp (argv[i], "-flto")) && ! use_plugin)
> lto_mode = LTO_MODE_WHOPR;
> + else if (!strncmp (argv[i], "-fno-lto", 8))
> + lto_mode = LTO_MODE_NONE;
> else if (! strcmp (argv[i], "-plugin"))
> {
> use_plugin = true;
> diff --git a/gcc/common.opt b/gcc/common.opt
> index 32df6fc..e6cb5e4 100644
> --- a/gcc/common.opt
> +++ b/gcc/common.opt
> @@ -1302,6 +1302,10 @@ floop-optimize
> Common Ignore
> Does nothing. Preserved for backward compatibility.
>
> +fno-lto
> +Common RejectNegative
> +Disable link-time optimization
> +
> flto
> Common
> Enable link-time optimization.
> diff --git a/gcc/opts.c b/gcc/opts.c
> index 2c8e767..fc6f272 100644
> --- a/gcc/opts.c
> +++ b/gcc/opts.c
> @@ -1673,6 +1673,10 @@ common_handle_option (struct gcc_options *opts,
> opts->x_flag_lto = "";
> break;
>
> + case OPT_fno_lto:
> + opts->x_flag_lto = NULL;
> + break;
> +
> case OPT_w:
> dc->dc_inhibit_warnings = true;
> break;
> --
> 1.7.1
>
>
More information about the Gcc-patches
mailing list