public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Cary Coutant <ccoutant@google.com>
To: Ian Lance Taylor <iant@google.com>
Cc: "H.J. Lu" <hjl.tools@gmail.com>,
	Dave Korn <dave.korn.cygwin@gmail.com>,
	       GCC Development <gcc@gcc.gnu.org>,
	Binutils <binutils@sourceware.org>,
	       Tristan Gingold <gingold@adacore.com>
Subject: Re: PATCH: 2 stage BFD linker for LTO plugin
Date: Mon, 13 Dec 2010 22:16:00 -0000	[thread overview]
Message-ID: <AANLkTik=ii5wXvfrEYYKU0oYt-FqNMK7i-iNcfSQMCMU@mail.gmail.com> (raw)
In-Reply-To: <mcr39q14c0i.fsf@google.com>

> Here is an alternative proposal, with a patch for gold.
>
> We add a new plugin vector: LDPT_REGISTER_RESCAN_ARCHIVE_HOOK.  Like
> LDPT_REGISTER_CLAIM_FILE_HOOK, this gives the plugin the address of a
> function which can register a plugin function: rescan_archive.
>
> typedef
> enum ld_plugin_status
> (*ld_plugin_rescan_archive_handler) (
>  const struct ld_plugin_input_file *file, int *rescan);
>
> If the plugin registers this hook, the linker will call the hook for
> each archive that it sees.  If the hook sets the *rescan variable to a
> non-zero value, then the linker will rescan the archive after calling
> the all_symbols_read hook.  The archive will be rescanned using the same
> position dependent options as when it was originally scanned.  In
> particular, if the archive occurred within --start-group/--end-group,
> the entire group will be rescanned.
>
> The point of this patch is that the known problems with the LTO plugin
> are when the plugin introduces a previously unknown symbol which must be
> satisfied from some archive.  The new symbol is introduced when the
> all_symbols_hook read hook calls add_input_file to add a new object file
> to the link, and the new object file refers to the new symbol.  Since
> the symbol was not previously seen, if the definition should come from
> an archive, the archive will not have been searched.  Hence the test
> case in GCC PR 42690 comment #32.
>
> Fortunately, we know that gcc is not going to introduce arbitrary new
> symbol references.  The current system hacks around the problem by using
> a special -pass-through option which directs the plugin to add specific
> archives to the link, namely -lc and -lgcc.  That works for most cases,
> but not when gcc introduces a symbol which comes from -lm.  Still,
> despite the -lm issue, we do not have to concern ourselves with
> arbitrary archives, because gcc is not going to act arbitrarily.
>
> Also we know that the problem can only occur with archives, not with
> shared objects.
>
> The rescan_archive proposal fixes the problems and obviates the need to
> use -pass-through.  It avoids the unnecessary cost of a complete relink.
>
> I've appended a patch for gold which implements this proposal.  I've
> also appended a patch for lto-plugin.  This patched lto-plugin does not
> use -pass-through when rescan_archive is available.  It rescans libc.a,
> libgcc.a, and libm.a.  It handles the PR 42690 comment #32 test case
> correctly.
>
> Any thoughts on this approach?

Looks good to me. I'd still prefer something based on a list of symbol
names that the backend might introduce calls to, but I'll concede that
this is far more practical.

I think Dave mentioned in the other thread that libgcov, libssp, and
libmudflap might also need to be rescanned:

>>> My suspicion is that the LTO plugin can only introduce a small bounded
>>> set of new symbol references, namely those which we assume can be
>>> satisified from -lc or -lgcc.  Is that true?
>>
>> Exactly.
>
> Potentially also gcov, ssp, mudflap?

Should we mark the pass-through option in lto-plugin as obsolescent?

-cary

  reply	other threads:[~2010-12-13 22:16 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-04  6:07 H.J. Lu
2010-12-04 17:34 ` H.J. Lu
2010-12-05  0:44   ` H.J. Lu
2010-12-05 18:23     ` H.J. Lu
2010-12-06  0:11       ` H.J. Lu
2010-12-06  2:21         ` H.J. Lu
2010-12-06 16:59           ` Dave Korn
2010-12-06 17:20             ` H.J. Lu
2010-12-07 20:12               ` H.J. Lu
2010-12-08  5:55                 ` H.J. Lu
2010-12-06 17:44             ` H.J. Lu
2010-12-06 17:55               ` Dave Korn
2010-12-06 17:57                 ` H.J. Lu
2010-12-06 23:29                   ` Alan Modra
2010-12-06 23:32                     ` H.J. Lu
2010-12-06 23:56                       ` Ian Lance Taylor
2010-12-07  0:01                         ` H.J. Lu
2010-12-06 23:54                     ` Ian Lance Taylor
2010-12-07  0:00                       ` H.J. Lu
2010-12-07  0:09                         ` Ian Lance Taylor
2010-12-07  1:02                           ` H.J. Lu
2010-12-07  1:10                             ` H.J. Lu
2010-12-07  1:19                               ` Cary Coutant
2010-12-07  1:32                                 ` H.J. Lu
2010-12-13 21:08                     ` Ian Lance Taylor
2010-12-13 22:16                       ` Cary Coutant [this message]
2011-01-19  0:28                       ` Ian Lance Taylor
2011-01-19  1:38                         ` H.J. Lu
2011-01-19 10:25                         ` Richard Guenther
2011-01-19 14:57                           ` Ian Lance Taylor
2011-01-20  0:20                             ` Cary Coutant
2011-01-20  0:11                           ` Jan Hubicka
2011-01-24 21:55                         ` Ian Lance Taylor
2010-12-07  8:33             ` Tristan Gingold
2010-12-07 10:35               ` 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='AANLkTik=ii5wXvfrEYYKU0oYt-FqNMK7i-iNcfSQMCMU@mail.gmail.com' \
    --to=ccoutant@google.com \
    --cc=binutils@sourceware.org \
    --cc=dave.korn.cygwin@gmail.com \
    --cc=gcc@gcc.gnu.org \
    --cc=gingold@adacore.com \
    --cc=hjl.tools@gmail.com \
    --cc=iant@google.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).