public inbox for java@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Guenther <richard.guenther@gmail.com>
To: Diego Novillo <dnovillo@google.com>
Cc: gcc@gcc.gnu.org, fortran@gcc.gnu.org, java@gcc.gnu.org
Subject: Re: LTO branch merged into trunk - trunk remains CLOSED
Date: Sat, 03 Oct 2009 21:33:00 -0000	[thread overview]
Message-ID: <84fc9c000910031432i4d3c190dk6775c38ca0b59265@mail.gmail.com> (raw)
In-Reply-To: <20091003211217.GA22755@google.com>

On Sat, Oct 3, 2009 at 11:12 PM, Diego Novillo <dnovillo@google.com> wrote:
> The LTO branch has been merged into trunk at revision 152434.
...
> To enable LTO, simply add the flag '-flto' to both compile and
> link commands.  It doesn't really matter whether you compile and
> link in separate invocations or a single one.  All that matters
> is that -flto should be in both places:
>
>        $ gcc -flto -O2 -o f f1.c f2.c
>
>                        or
>
>        $ gcc -flto -c f1.c
>        $ gcc -flto -c f2.c
>        $ gcc -o f -flto -O2 f1.o f2.o

Remember though that options specified at compile time are _not_ automatically
enabled at link time!  Thus the 2nd example above would perform no initial
optimization (effectively skipping all early optimizations until the IPA passes)
while enabling optimization (starting with IPA passes and then remaining
optimization passes) at link time.  Thus the better canonical example would
have been

  $ gcc -O2 -flto -c f1.c
  $ gcc -O2 -flto -c f2.c
  $ gcc -o f -flto -O2 f1.o f2.o

where in particular enabling -fwhole-program is what should enable extra
optimization (well, if you do actually link a final binary).

Note that one missing feature is picking up entries from static library
archives at link time.  To not end up with unused LTO sections from
static libraries in the final binary you need to have recent enough binutils
or strip them manually.

Richard.

  reply	other threads:[~2009-10-03 21:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-03 21:12 Diego Novillo
2009-10-03 21:33 ` Richard Guenther [this message]
2009-10-03 21:36   ` Diego Novillo
2009-10-03 22:31 ` Richard Guenther
2009-10-03 23:40   ` Diego Novillo
2009-10-04  1:05     ` Diego Novillo
2009-10-05 14:42 ` Frank Ch. Eigler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=84fc9c000910031432i4d3c190dk6775c38ca0b59265@mail.gmail.com \
    --to=richard.guenther@gmail.com \
    --cc=dnovillo@google.com \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc@gcc.gnu.org \
    --cc=java@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).