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? Thanks, -- Ilya