Message ID | 20180508151708.GC16916@kam.mff.cuni.cz |
---|---|
State | New |
Headers | show |
Series | Incremental LTO linking part 3: lto-wrapper support | expand |
On Tue, 8 May 2018, Jan Hubicka wrote: > Hi, > this patch makes lto-wrapper to look for -flinker-output=rel and in this > case confiugre lto1 in non-WHOPR mode + disable section renaming. > > Bootstrapped/regtested x86_64-linux with rest of incremental link patchset. > OK? > > * lto-wrapper.c (debug_objcopy): Add rename parameter; pass > it down to simple_object_copy_lto_debug_sections. > (run_gcc): Determine incremental LTO link time and configure > lto1 into non-wpa mode, disable renaming of debug sections. > > Index: lto-wrapper.c > =================================================================== > --- lto-wrapper.c (revision 260042) > +++ lto-wrapper.c (working copy) > @@ -966,7 +966,7 @@ > is returned. Return NULL on error. */ > > const char * > -debug_objcopy (const char *infile) > +debug_objcopy (const char *infile, bool rename) > { > const char *outfile; > const char *errmsg; > @@ -1008,7 +1008,7 @@ > } > > outfile = make_temp_file ("debugobjtem"); > - errmsg = simple_object_copy_lto_debug_sections (inobj, outfile, &err); > + errmsg = simple_object_copy_lto_debug_sections (inobj, outfile, &err, rename); > if (errmsg) > { > unlink_if_ordinary (outfile); > @@ -1056,6 +1056,7 @@ > bool have_offload = false; > unsigned lto_argc = 0, ltoobj_argc = 0; > char **lto_argv, **ltoobj_argv; > + bool linker_output_rel = false; > bool skip_debug = false; > unsigned n_debugobj; > > @@ -1108,9 +1109,12 @@ > file_offset = (off_t) loffset; > } > fd = open (filename, O_RDONLY | O_BINARY); > + /* Linker plugin passes -fresolution and -flinker-output options. */ > if (fd == -1) > { > lto_argv[lto_argc++] = argv[i]; > + if (strcmp (argv[i], "-flinker-output=rel") == 0) > + linker_output_rel = true; > continue; > } Why do you need this? > > @@ -1175,6 +1179,11 @@ > lto_mode = LTO_MODE_WHOPR; > break; > > + case OPT_flinker_output_: > + linker_output_rel = !strcmp (option->arg, "rel"); > + break; > + > + And this? It looks to me either should suffice and if not then what about conflicting options here? Otherwise looks ok. Richard. > default: > break; > } > @@ -1191,6 +1200,9 @@ > fputc ('\n', stderr); > } > > + if (linker_output_rel) > + no_partition = true; > + > if (no_partition) > { > lto_mode = LTO_MODE_LTO; > @@ -1435,7 +1447,7 @@ > for (i = 0; i < ltoobj_argc; ++i) > { > const char *tem; > - if ((tem = debug_objcopy (ltoobj_argv[i]))) > + if ((tem = debug_objcopy (ltoobj_argv[i], !linker_output_rel))) > { > obstack_ptr_grow (&argv_obstack, tem); > n_debugobj++; > >
> > @@ -1108,9 +1109,12 @@ > > file_offset = (off_t) loffset; > > } > > fd = open (filename, O_RDONLY | O_BINARY); > > + /* Linker plugin passes -fresolution and -flinker-output options. */ > > if (fd == -1) > > { > > lto_argv[lto_argc++] = argv[i]; > > + if (strcmp (argv[i], "-flinker-output=rel") == 0) > > + linker_output_rel = true; > > continue; > > } > > Why do you need this? > > > > > @@ -1175,6 +1179,11 @@ > > lto_mode = LTO_MODE_WHOPR; > > break; > > > > + case OPT_flinker_output_: > > + linker_output_rel = !strcmp (option->arg, "rel"); > > + break; > > + > > + > > And this? It looks to me either should suffice and if not then > what about conflicting options here? > > Otherwise looks ok. This is because the -flinker-output may be specified by user and then it goes to decoded options or by linker plugin (because we default to non-lto objects of there is non-IL .o file linker in and only plugin knows). These options comes in in different ways, but we know that either the first hunk matches or the second hunk, they never match together. So I hope it is OK (extending linker plugin to update passed options is probably unnecesary work. We do same trick for -fresolution and other stuff). I have added explanatory comment. Honza > > Richard. > > > default: > > break; > > } > > @@ -1191,6 +1200,9 @@ > > fputc ('\n', stderr); > > } > > > > + if (linker_output_rel) > > + no_partition = true; > > + > > if (no_partition) > > { > > lto_mode = LTO_MODE_LTO; > > @@ -1435,7 +1447,7 @@ > > for (i = 0; i < ltoobj_argc; ++i) > > { > > const char *tem; > > - if ((tem = debug_objcopy (ltoobj_argv[i]))) > > + if ((tem = debug_objcopy (ltoobj_argv[i], !linker_output_rel))) > > { > > obstack_ptr_grow (&argv_obstack, tem); > > n_debugobj++; > > > > > > -- > Richard Biener <rguenther@suse.de> > SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)
Index: lto-wrapper.c =================================================================== --- lto-wrapper.c (revision 260042) +++ lto-wrapper.c (working copy) @@ -966,7 +966,7 @@ is returned. Return NULL on error. */ const char * -debug_objcopy (const char *infile) +debug_objcopy (const char *infile, bool rename) { const char *outfile; const char *errmsg; @@ -1008,7 +1008,7 @@ } outfile = make_temp_file ("debugobjtem"); - errmsg = simple_object_copy_lto_debug_sections (inobj, outfile, &err); + errmsg = simple_object_copy_lto_debug_sections (inobj, outfile, &err, rename); if (errmsg) { unlink_if_ordinary (outfile); @@ -1056,6 +1056,7 @@ bool have_offload = false; unsigned lto_argc = 0, ltoobj_argc = 0; char **lto_argv, **ltoobj_argv; + bool linker_output_rel = false; bool skip_debug = false; unsigned n_debugobj; @@ -1108,9 +1109,12 @@ file_offset = (off_t) loffset; } fd = open (filename, O_RDONLY | O_BINARY); + /* Linker plugin passes -fresolution and -flinker-output options. */ if (fd == -1) { lto_argv[lto_argc++] = argv[i]; + if (strcmp (argv[i], "-flinker-output=rel") == 0) + linker_output_rel = true; continue; } @@ -1175,6 +1179,11 @@ lto_mode = LTO_MODE_WHOPR; break; + case OPT_flinker_output_: + linker_output_rel = !strcmp (option->arg, "rel"); + break; + + default: break; } @@ -1191,6 +1200,9 @@ fputc ('\n', stderr); } + if (linker_output_rel) + no_partition = true; + if (no_partition) { lto_mode = LTO_MODE_LTO; @@ -1435,7 +1447,7 @@ for (i = 0; i < ltoobj_argc; ++i) { const char *tem; - if ((tem = debug_objcopy (ltoobj_argv[i]))) + if ((tem = debug_objcopy (ltoobj_argv[i], !linker_output_rel))) { obstack_ptr_grow (&argv_obstack, tem); n_debugobj++;