diff mbox

[RFC] Getting LTO incremental linking work

Message ID 56598994.2010703@mentor.com
State New
Headers show

Commit Message

Tom de Vries Nov. 28, 2015, 11:01 a.m. UTC
On 28/11/15 10:35, Tom de Vries wrote:
> On 26/11/15 00:07, Jan Hubicka wrote:
>> (flinker_output): New flag.
>
> Hi,
>
> this seems to have cause a regression when using a compiler configured
> for offloading (giving ~1000 fails in libgomp testing).
>
> For test-case libgomp.c/examples-4/array_sections-3.c, we enter run_gcc
> in lto-wrapper with args:
> ...
> Breakpoint 1, run_gcc (argc=4, argv=0x7fffffffde68) at
> src/gcc-gomp-4_0-branch/gcc/lto-wrapper.c:897
> 897       char *list_option_full = NULL;
> (gdb) p argv[0]
> $8 = 0x7fffffffe104 "lto-wrapper"
> (gdb) p argv[1]
> $9 = 0x7fffffffe1af "-fresolution=array_sections-3.res"
> (gdb) p argv[2]
> $10 = 0x7fffffffe1d1 "-flinker-output=exec"
> (gdb) p argv[3]
> $11 = 0x7fffffffe1e6 "array_sections-3.o"
> ...
>
> And here (cc-ing author of this bit) we decide that -flinker-output=exec
> is a file:
> ...
> /* If object files contain offload sections, but do not contain LTO
>     sections,
>     then there is no need to perform a link-time recompilation, i.e.
>     lto-wrapper is used only for a compilation of offload images. */
> if (have_offload && !have_lto)
>    {
>      for (i = 1; i < argc; ++i)
>        if (strncmp (argv[i], "-fresolution=",
>             sizeof ("-fresolution=") - 1))
>      {
>        char *out_file;
>        /* Can be ".o" or ".so". */
>        char *ext = strrchr (argv[i], '.');
>        if (ext == NULL)
>          out_file = make_temp_file ("");
>        else
>          out_file = make_temp_file (ext);
>        /* The linker will delete the files we give it, so make
>           copies. */
>        copy_file (out_file, argv[i]);
>        printf ("%s\n", out_file);
>      }
>      goto finish;
>    }
> ...
>
> And try to copy it:
> ...
> Program received signal SIGSEGV, Segmentation fault.
> 0x00007ffff783d7e0 in feof () from /lib/libc.so.6
> (gdb) bt
> #0  0x00007ffff783d7e0 in feof () from /lib/libc.so.6
> #1  0x0000000000406ff5 in copy_file (dest=0x71cdd0 "/tmp/ccL6HCCe",
> src=0x7fffffffe1d1 "-flinker-output=exec")
>      at lto-wrapper.c:769
> #2  0x00000000004080b7 in run_gcc (argc=4, argv=0x7fffffffde68) at
> gcc/lto-wrapper.c:1109
> #3  0x0000000000409873 in main (argc=4, argv=0x7fffffffde68) at
> gcc/lto-wrapper.c:1396
> ...
>

This patch fixes the failures. I'm not sure if this is the right or 
complete fix though.

Thanks,
- Tom

Comments

Ilya Verbin Nov. 28, 2015, 12:02 p.m. UTC | #1
2015-11-28 14:01 GMT+03:00 Tom de Vries <Tom_deVries@mentor.com>:
> This patch fixes the failures. I'm not sure if this is the right or complete
> fix though.

I think it's ok, at least until we decide how to rework the offloading
stuff in lto-wrapper (see PR68463).

Thanks,
  -- Ilya
diff mbox

Patch

diff --git a/gcc/lto-wrapper.c b/gcc/lto-wrapper.c
index b9ac535..e4772d1 100644
--- a/gcc/lto-wrapper.c
+++ b/gcc/lto-wrapper.c
@@ -1096,7 +1096,10 @@  run_gcc (unsigned argc, char *argv[])
   if (have_offload && !have_lto)
     {
       for (i = 1; i < argc; ++i)
-	if (strncmp (argv[i], "-fresolution=", sizeof ("-fresolution=") - 1))
+	if (strncmp (argv[i], "-fresolution=",
+		     sizeof ("-fresolution=") - 1) != 0
+	    && strncmp (argv[i], "-flinker-output=",
+			sizeof ("-flinker-output=") - 1) != 0)
 	  {
 	    char *out_file;
 	    /* Can be ".o" or ".so".  */