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