public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Dave Korn <dave.korn.cygwin@gmail.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: "binutils@sourceware.org" <binutils@sourceware.org>
Subject: Re: [PATCH,trunk+2.20] Fix issues in ld.bfd plugin interface [0/6]
Date: Sat, 26 Feb 2011 03:37:00 -0000	[thread overview]
Message-ID: <4D687545.8010303@gmail.com> (raw)
In-Reply-To: <AANLkTikKVKEogY17trUu+S0ZtjXzJ0bf96p0dAeU4-0c@mail.gmail.com>

On 26/02/2011 02:14, H.J. Lu wrote:

> 
> The question is if LTO linker should link in non-LTO copy of the same function
> and ignore the LTO-IR copy:

  Well, I think the linker should link at least one of them in, preferably the
IR one if it can so that it can be optimised along with the rest of the
program, but if for some reason the linker can't see that it's needed until
after ltrans, then it has no choice but to link the non-LTO copy, and settle
for what should after all only be a missed optimisation rather than
correctness problem.

> [hjl@gnu-6 pr12496-2]$ make
> as --32  -o start.o start.s
> /usr/gcc-4.6/bin/gcc -m32 -B./ -flto   -c -o main.o main.c
> /usr/gcc-4.6/bin/gcc -m32 -B./ -flto   -c -o div.o div.c
> ar rv libdiv.a div.o
> ar: creating libdiv.a
> a - div.o
> /usr/gcc-4.6/bin/gcc -m32 -B./ -O2 -flto -nostdlib -o prog
> -Wl,--start-group start.o main.o libdiv.a -Wl,--end-group

  When I tried this with ld.hjl on i686-pc-cygwin, I got an undefined
reference to __udivdi3, is that supposed to happen?

> Here div.o is compiled with -O0 -flto and the final link is compiled
> with -O2 -flto. I would expect div.c is compiled with -O2 -flto, not -O0,
> if div.c is linked in. Am I expecting too much?

  Well, to make that work, wouldn't we have to treat all archives as if they
were opened in --whole-archive mode during stage1, and let the plugin claim
every archive member that contains any IR and then rely on LTRANS to optimise
away all but the used code, right?

  I must admit I don't understand why LTO doesn't emit undefs in the LTO
symtab for builtins.  I think life would be easier all round if the LTO symtab
for main.o contained a reference to __udivdi3 all along, so that we could just
let the usual mechanism pull in all (and only) the needed stuff straight off
in stage1 and not give LTRANS so much redundant work to do.

    cheers,
      DaveK


  reply	other threads:[~2011-02-26  3:37 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-26  0:44 Dave Korn
2011-02-26  0:45 ` [PATCH,trunk+2.21] " Dave Korn
2011-02-26  0:45   ` [1/6][PATCH] Fix PE-COFF bug in orphan section alignment handling Dave Korn
2011-02-26  9:14     ` Alan Modra
2011-02-26  0:46   ` [2/6][PATCH] Do not use dummy bfd suffix for recognition, make it human-readable instead Dave Korn
2011-02-26  0:46   ` [4/6][PATCH] Fix issue from GCC PR47527: no ELF flags, EABI attribs, etc. in dummy IR BFD Dave Korn
2011-02-26  0:48     ` Dave Korn
2011-02-26  9:16       ` Alan Modra
2011-02-26  0:46   ` [3/6][PATCH] Revise linker plugin API to better preserve link order Dave Korn
2011-02-26  9:15     ` Alan Modra
2011-02-26  0:46   ` [5/6][PATCH] Perform second link stage and ignore now-obsolete linker -pass-through= option Dave Korn
2011-02-26  0:48     ` Dave Korn
2011-02-26  4:03     ` Rafael Ávila de Espíndola
2011-02-27 18:54       ` Ian Lance Taylor
2011-02-27 19:11         ` Rafael Ávila de Espíndola
2011-02-27 19:22           ` Ian Lance Taylor
2011-02-27 19:37             ` Rafael Ávila de Espíndola
2011-02-26  9:05     ` Alan Modra
2011-02-26  0:47   ` [x/6][PATCH] Portability tweaks for LTO tests Dave Korn
2011-02-26  0:49     ` Dave Korn
2011-02-26  3:50     ` H.J. Lu
2011-02-26  5:33       ` H.J. Lu
2011-02-26  0:47   ` [6/6][PATCH] Respect symbol wrappers when computing symbol resolutions Dave Korn
2011-02-26  0:49     ` Dave Korn
2011-02-26  4:50     ` H.J. Lu
2011-02-26  9:28     ` Alan Modra
2011-02-26  2:14 ` [PATCH,trunk+2.20] Fix issues in ld.bfd plugin interface [0/6] H.J. Lu
2011-02-26  3:37   ` Dave Korn [this message]
2011-02-26  3:48     ` H.J. Lu
2011-03-10 10:43 ` Dave Korn

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=4D687545.8010303@gmail.com \
    --to=dave.korn.cygwin@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=hjl.tools@gmail.com \
    /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).