Bug 50616 - lto1.exe: internal compiler error: invalid resolution in the resolution file
Summary: lto1.exe: internal compiler error: invalid resolution in the resolution file
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: lto (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: 4.7.0
Assignee: Not yet assigned to anyone
URL:
Keywords: lto
Depends on:
Blocks:
 
Reported: 2011-10-04 18:34 UTC by niXman
Modified: 2012-04-28 21:19 UTC (History)
2 users (show)

See Also:
Host: i686-pc-mingw32
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2012-01-02 00:00:00


Attachments
LTO test sources (653 bytes, application/x-gzip)
2011-10-04 18:35 UTC, niXman
Details
sources + temp files + logs (118.82 KB, application/x-gzip)
2012-01-03 09:53 UTC, niXman
Details

Note You need to log in before you can comment on or make changes to this bug.
Description niXman 2011-10-04 18:34:22 UTC
I compile the files attached with this command-line: "g++ ltotest.cpp int.cpp -oltotest -s -O3 -flto"
and get the following error: "lto1.exe: internal compiler error: invalid resolution in the resolution file"

configured with:
g++ -v Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/i686-pc-mingw32/4.7.0/lto-wrapper.exe
Target: i686-pc-mingw32
Configured with: ../../mingw-src/gcc-4.7-20111001/configure \
--host=i686-pc-mingw32 \
--build=i686-pc-mingw32 \
--target=i686-pc-mingw32 \
--prefix=/mingw-sjlj-x86 \
--with-arch=i686 \
--with-tune=generic \
--enable-languages=c,c++,lto,objc,obj-c++,fortran \
--with-host-libstdcxx=-lstdc++ \
--disable-shared \
--enable-static \
--enable-cxx-flags='-fno-function-sections -fno-data-sections' \
--enable-libstdcxx-time=yes \
--enable-libgomp \
--enable-lto \
--enable-graphite \
--enable-cloog-backend=isl \
--enable-checking=release \
--enable-fully-dynamic-string \
--enable-threads=posix \
--disable-libstdcxx-pch \
--enable-libstdcxx-debug \
--enable-sjlj-exceptions \
--disable-debug \
--disable-bootstrap \
--disable-multilib \
--disable-rpath \
--disable-win32-registry \
--disable-nls \
--disable-werror \
--disable-symvers \
--with-gmp=/mingw-libs \
--with-mpfr=/mingw-libs \
--with-mpc=/mingw-libs \
--with-ppl=/mingw-libs \
--with-cloog=/mingw-libs \
--with-libiconv-prefix=/mingw-libs \
Thread model: posix
gcc version 4.7.0 20111001 (experimental)
Comment 1 niXman 2011-10-04 18:35:30 UTC
Created attachment 25416 [details]
LTO test sources
Comment 2 Richard Biener 2012-01-02 11:17:47 UTC
Please attach the resolution file (you can obtain it by adding -v -save-temps
to the command-line, the file is the one mentioned as argument to the
-fresolution= command-line argument to lto1.exe)

What binutils version are you using?  I suspect a mismatch between
binutils/gcc here.
Comment 3 niXman 2012-01-03 09:53:59 UTC
Created attachment 26229 [details]
sources + temp files + logs
Comment 4 Richard Biener 2012-01-03 10:31:53 UTC
I think the (null)'s are odd at least.

2
ltotest.o 15
1068 a2f6b3c8 (null) PREVAILING_DEF
1010 a2f6b3c8 (null) RESOLVED_EXEC
1082 a2f6b3c8 (null) RESOLVED_EXEC
1086 a2f6b3c8 (null) RESOLVED_EXEC
1093 a2f6b3c8 (null) RESOLVED_EXEC
...

First of all, the symbol name should come 4th, not 3rd - the resolution
belongs there.

This means you are very likely using a bogus lto-plugin shared object that
does not match the GCC version you are using.  Though I do not remeber
any version that dumped things in the order I see in your attached file.

So, please check which file is specified as -plugin argument to the linker
(it should be visible in the -v dump) and remove that and/or replace it
with a current version.

Hmm.  We use

      fprintf (f, "%u %llx %s %s\n",
               (unsigned int) slot, symtab->aux[j].id,
               lto_resolution_str[resolution],
               symtab->syms[j].name);

maybe that falls foul of some special Window-ism (aka unportable %llx?).
Kai?
Comment 5 niXman 2012-01-08 15:15:19 UTC
I don't have other GCC versions or lto-pugins on my computer.

Here is a fragment of code from gcc-4.6.2-release:
      fprintf (f, "%u %x %s %s\n", (unsigned int) slot, symtab->aux[j].id,
	       lto_resolution_str[resolution], 
	       symtab->syms[j].name);

This one is the same fragment from gcc-4.6.3-branch:
      fprintf (f, "%u %x %s %s\n", (unsigned int) slot, symtab->aux[j].id,
               lto_resolution_str[resolution], 
               symtab->syms[j].name);

And this one is the same fragment from gcc-trunk:
      fprintf (f, "%u %llx %s %s\n",
               (unsigned int) slot, symtab->aux[j].id,
               lto_resolution_str[resolution], 
               symtab->syms[j].name);
Comment 6 niXman 2012-01-16 01:43:56 UTC
Replacing "%llx" to "%I64x" solves the problem.

http://msdn.microsoft.com/en-us/library/3b2e7499(v=vs.80).aspx

Thanks, niXman.
Comment 7 Andrew Pinski 2012-01-16 02:52:29 UTC
This is a host side issue really.  Anyways we should use uin64_t with PRIx64 so it is more portable.
Comment 8 Stefan Reichardt 2012-02-19 14:29:16 UTC
Could you please tell which file you are speaking of, where to apply your fix from comment #6?

This bug does not occur on my system. i compiled gcc-4.7.0-20120217 on mingw32 on Windows 7 - 64bit for target=avr.
But my compiler will generate the bug when run on 32-bit Windows.

If i apply your hack from comment #6, will my compiler-lto then be usable on 32-bit but not on 64bit?
Comment 9 niXman 2012-02-19 16:22:52 UTC
lto-plugin/lto-plugin.c

http://gcc.gnu.org/viewcvs/trunk/lto-plugin/lto-plugin.c?view=markup
line 363.
Comment 10 Kai Tietz 2012-02-19 16:31:32 UTC
Yes, not all msvcrt versions are supporting %ll width modifier.  Modern versions of it (as 64-bit versions) are supporting it, but older (and still pretty common on 32-bit OSes) don't.  Therefore it is for native Windows apps more compatible to use here instead %I64.
As Andrew mentioned we might should use here instead PRIx64 for output of 64-bit integer-scalars.
Any patch in this direction would be welcome for me.
Comment 11 Kai Tietz 2012-02-22 10:19:27 UTC
Author: ktietz
Date: Wed Feb 22 10:19:22 2012
New Revision: 184462

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=184462
Log:
        PR lto/50616
        * lto-plugin.c (PRI_LL): New macro.
        (dump_symtab): Use PRI_LL instead of ll in print.
        (process_symtab): Use PRI_LL instead of ll in scan.


Modified:
    trunk/lto-plugin/ChangeLog
    trunk/lto-plugin/lto-plugin.c
Comment 12 Kai Tietz 2012-02-22 10:21:18 UTC
Fixed.