public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Cary Coutant <ccoutant@google.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Ilya Verbin <iverbin@gmail.com>,
	Richard Biener <rguenther@suse.de>, Jan Hubicka <hubicka@ucw.cz>,
		gcc-patches <gcc-patches@gcc.gnu.org>,
	Thomas Schwinge <thomas@codesourcery.com>,
		Kirill Yukhin <kirill.yukhin@gmail.com>,
	Andrey Turetskiy <andrey.turetskiy@gmail.com>
Subject: Re: [PATCH 4/n] OpenMP 4.0 offloading infrastructure: lto-wrapper
Date: Fri, 10 Oct 2014 16:52:00 -0000	[thread overview]
Message-ID: <CAHACq4qgCNNxe+PPh3t8YVbdbbS5aUzeK=tH+Kp1r8Zxa1qG9Q@mail.gmail.com> (raw)
In-Reply-To: <20141010065320.GA10376@tucnak.redhat.com>

The linker already has a --strip-lto-sections option, and it's on by
default. I'll approve a patch that modifies gold to recognize
.gnu.offload_lto.* sections as part of --strip-lto-sections.

Really, though, you should be setting the SHF_EXCLUDE bit on these
sections. Do that and no special-casing will be necessary.

Generating a linker script on the fly to discard these sections is, to
me, rather hacky. There are better ways to do it.

-cary


On Thu, Oct 9, 2014 at 11:53 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Fri, Oct 10, 2014 at 12:07:03AM +0400, Ilya Verbin wrote:
>> On 09 Oct 16:07, Ilya Verbin wrote:
>> > > > +      /* By default linker does not discard .gnu.offload_lto_* sections.  */
>> > > > +      const char *linker_script = make_temp_file ("_linker_script.x");
>> > > > +      FILE *stream = fopen (linker_script, "w");
>> > > > +      if (!stream)
>> > > > +       fatal_error ("fopen %s: %m", linker_script);
>> > > > +      fprintf (stream, "SECTIONS { /DISCARD/ : { *("
>> > > > +                      OFFLOAD_SECTION_NAME_PREFIX "*) } }\n");
>> > > > +      fclose (stream);
>> > > > +      printf ("%s\n", linker_script);
>> > > > +
>> > > > +      goto finish;
>> > > > +    }
>> > >
>> > > Does this work with gold?  Are there any other linkers that support plugins,
>> > > but don't support linker scripts this way?
>> >
>> > Oops, gold does not support scripts, outputted from plugins :(
>> > "error: SECTIONS seen after other input files; try -T/--script"
>> >
>> > Probably, we should update default linker scripts in binutils?
>> > But without latest ld/gold all binaries compiled without -flto and with
>> > offloading will contain intermediate bytecode...
>>
>> Actually, this issue is not due to outputting a script from a plugin,
>> gold just does not support partial linker scripts:
>> https://sourceware.org/bugzilla/show_bug.cgi?id=17451
>>
>> So it seems that discarding .gnu.offload_lto_* sections (like it is done for
>> .gnu.lto_*) in the default ld and gold scripts is the right way?
>
> I must say I'm not very much familiar with the linker plugin API, but it
> surprises me that discarding sections is not something it allows.
> Anyway, can you do the partial linker script for the bfd linker (is there
> a way to determine from the linker plugin API if it is gold or bfd ld?), and
> for gold for the time being perhaps strip the sections in lto-wrapper? and
> feed the ET_REL objects with the sections stripped back to the linker
> through the plugin API?
>
>         Jakub

  reply	other threads:[~2014-10-10 16:51 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-02 15:15 Ilya Verbin
2014-10-08 10:27 ` Jakub Jelinek
2014-10-09 12:09   ` Ilya Verbin
2014-10-09 12:13     ` Bernd Schmidt
2014-10-09 20:27     ` Ilya Verbin
2014-10-10  7:13       ` Jakub Jelinek
2014-10-10 16:52         ` Cary Coutant [this message]
2014-10-10 17:01           ` Jakub Jelinek
2014-10-10 17:10             ` Cary Coutant
2014-10-13 22:47             ` Ilya Verbin
2014-10-14  9:41               ` Jakub Jelinek
2014-10-15 14:27                 ` Ilya Verbin
2014-10-15 14:46                   ` Jakub Jelinek
2014-10-16 11:18                     ` Ilya Verbin
2014-10-16 11:27                       ` Jakub Jelinek
2014-10-29 10:28                         ` Kirill Yukhin
2014-11-06 13:00                         ` Ilya Verbin
2014-11-12  9:47                           ` Richard Biener
2014-10-15 17:03                 ` Cary Coutant
2015-05-12 16:32 ` Thomas Schwinge
2015-05-12 17:19   ` Bernd Schmidt
2015-10-02 21:28     ` Help the offload gcc driver find the right assembler (was: [PATCH 4/n] OpenMP 4.0 offloading infrastructure: lto-wrapper) Thomas Schwinge
2016-02-19 19:42 ` [PATCH 4/n] OpenMP 4.0 offloading infrastructure: lto-wrapper Thomas Schwinge
2016-02-19 19:51   ` Ilya Verbin

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='CAHACq4qgCNNxe+PPh3t8YVbdbbS5aUzeK=tH+Kp1r8Zxa1qG9Q@mail.gmail.com' \
    --to=ccoutant@google.com \
    --cc=andrey.turetskiy@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    --cc=iverbin@gmail.com \
    --cc=jakub@redhat.com \
    --cc=kirill.yukhin@gmail.com \
    --cc=rguenther@suse.de \
    --cc=thomas@codesourcery.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).