Bug 66027 - lto1: internal compiler error: in odr_types_equivalent_p
Summary: lto1: internal compiler error: in odr_types_equivalent_p
Status: RESOLVED DUPLICATE of bug 65948
Alias: None
Product: gcc
Classification: Unclassified
Component: lto (show other bugs)
Version: 5.1.0
: P3 normal
Target Milestone: 5.4
Assignee: Jan Hubicka
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-05 19:06 UTC by JD
Modified: 2015-12-10 08:39 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 4.9.2, 6.0
Known to fail: 5.0
Last reconfirmed: 2015-05-05 00:00:00


Attachments
complete commandline used to link (1.24 KB, text/plain)
2015-05-05 19:06 UTC, JD
Details
preprocessed sources and makefile (735.20 KB, application/x-7z-compressed)
2015-05-07 21:26 UTC, JD
Details
output of gcc -march=native -Q --help=target (1.43 KB, text/plain)
2015-05-07 22:09 UTC, JD
Details

Note You need to log in before you can comment on or make changes to this bug.
Description JD 2015-05-05 19:06:24 UTC
Created attachment 35468 [details]
complete commandline used to link

"openSUSE 13.2 (Harlequin) (x86_64)"

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=gcc5.1/lib/gcc/x86_64-unknown-linux-gnu/5.1.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-5.1.0/configure --prefix=gcc5.1 --enable-languages=c,c++ --enable-gold=yes --enable-ld=yes --enable-lto --enable-bootstrap --disable-multilib
Thread model: posix
gcc version 5.1.0 (GCC)

llvm[4]: Linking Release+Asserts Shared Library libclang.so
 <nullptr_type 0x7f717e5c92a0 decltype(nullptr) unsigned DI
    size <integer_cst 0x7f717f5a9bb8 type <integer_type 0x7f717f5ad150 bitsizetype> constant 64>
    unit size <integer_cst 0x7f717f5a9bd0 type <integer_type 0x7f717f5ad0a8 sizetype> constant 8>
    align 8 symtab 0 alias set 0 canonical type 0x7f717e5c92a0
    pointer_to_this <pointer_type 0x7f7178ac0d20> reference_to_this <reference_type 0x7f7178e68930>>
lto1: internal compiler error: in odr_types_equivalent_p, at ipa-devirt.c:1543
0x807397 odr_types_equivalent_p
        ../../gcc-5.1.0/gcc/ipa-devirt.c:1543
0x8076ad odr_types_equivalent_p
        ../../gcc-5.1.0/gcc/ipa-devirt.c:1440
0x804ca1 add_type_duplicate
        ../../gcc-5.1.0/gcc/ipa-devirt.c:1770
0x804ca1 get_odr_type(tree_node*, bool)
        ../../gcc-5.1.0/gcc/ipa-devirt.c:1959
0x80642c register_odr_type(tree_node*)
        ../../gcc-5.1.0/gcc/ipa-devirt.c:2034
0x63876d lto_read_decls
        ../../gcc-5.1.0/gcc/lto/lto.c:1952
0x6394ae lto_file_finalize
        ../../gcc-5.1.0/gcc/lto/lto.c:2249
0x6394ae lto_create_files_from_ids
        ../../gcc-5.1.0/gcc/lto/lto.c:2259
0x6394ae lto_file_read
        ../../gcc-5.1.0/gcc/lto/lto.c:2300
0x6394ae read_cgraph_and_symbols
        ../../gcc-5.1.0/gcc/lto/lto.c:3005
0x6394ae lto_main()
        ../../gcc-5.1.0/gcc/lto/lto.c:3475
Comment 1 Andrew Pinski 2015-05-05 23:32:53 UTC
This is not enough information as we need to be able to reproduce it.  Can you provide the preprocessed source for each of the objects and each of the libraries? Or better yet reduce how the number of object files you need to reproduce the failure.
Comment 2 JD 2015-05-07 21:19:35 UTC
I managed create a minimal example.

bug66027 $ make -j 
g++ -std=c++14 -c -fPIC -march=native -O3 -flto -fuse-linker-plugin -fno-fat-lto-objects ASTContext_preproc.cpp -o ASTContext_preproc.o
g++ -std=c++14 -c -fPIC -march=native -O3 -flto -fuse-linker-plugin -fno-fat-lto-objects ASTConsumer_preproc.cpp -o ASTConsumer_preproc.o
ar cru libAST.a ASTContext_preproc.o ASTConsumer_preproc.o
g++ -flto=4 -std=c++14 -march=native -fuse-linker-plugin -shared -o bla.so CIndex_preproc.cpp libAST.a
 <nullptr_type 0x7f9352ff5d20 decltype(nullptr) unsigned DI
    size <integer_cst 0x7f9353b9bbb8 type <integer_type 0x7f9353b9f150 bitsizetype> constant 64>
    unit size <integer_cst 0x7f9353b9bbd0 type <integer_type 0x7f9353b9f0a8 sizetype> constant 8>
    align 8 symtab 0 alias set 0 canonical type 0x7f9352ff5d20
    pointer_to_this <pointer_type 0x7f9352782738> reference_to_this <reference_type 0x7f9352ff6000>>
lto1: internal compiler error: in odr_types_equivalent_p, at ipa-devirt.c:1543
0x807397 odr_types_equivalent_p
        ../../gcc-5.1.0/gcc/ipa-devirt.c:1543
0x8076ad odr_types_equivalent_p
        ../../gcc-5.1.0/gcc/ipa-devirt.c:1440
0x804ca1 add_type_duplicate
        ../../gcc-5.1.0/gcc/ipa-devirt.c:1770
0x804ca1 get_odr_type(tree_node*, bool)
        ../../gcc-5.1.0/gcc/ipa-devirt.c:1959
0x80642c register_odr_type(tree_node*)
        ../../gcc-5.1.0/gcc/ipa-devirt.c:2034
0x63876d lto_read_decls
        ../../gcc-5.1.0/gcc/lto/lto.c:1952
0x6394ae lto_file_finalize
        ../../gcc-5.1.0/gcc/lto/lto.c:2249
0x6394ae lto_create_files_from_ids
        ../../gcc-5.1.0/gcc/lto/lto.c:2259
0x6394ae lto_file_read
        ../../gcc-5.1.0/gcc/lto/lto.c:2300
0x6394ae read_cgraph_and_symbols
        ../../gcc-5.1.0/gcc/lto/lto.c:3005
0x6394ae lto_main()
        ../../gcc-5.1.0/gcc/lto/lto.c:3475
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
lto-wrapper: fatal error: g++ returned 1 exit status
compilation terminated.
/usr/bin/ld: lto-wrapper failed
collect2: error: ld returned 1 exit status
Makefile:7: recipe for target 'all' failed
make: *** [all] Error 1

ld -v
GNU ld (GNU Binutils; openSUSE 13.2) 2.24.0.20140403-6.1

gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/german/local/gcc5.1/lib/gcc/x86_64-unknown-linux-gnu/5.1.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-5.1.0/configure --prefix=/home/german/local/gcc5.1 --enable-languages=c,c++ --enable-gold=yes --enable-ld=yes --enable-lto --enable-bootstrap --disable-multilib
Thread model: posix
gcc version 5.1.0 (GCC)

ar --version
GNU ar (GNU Binutils; openSUSE 13.2) 2.24.0.20140403-6.1
Comment 3 JD 2015-05-07 21:26:49 UTC
Created attachment 35490 [details]
preprocessed sources and makefile
Comment 4 JD 2015-05-07 22:07:33 UTC
Removing the -O3 flag from the first two invocations changes the behavior:

g++ -std=c++14 -c -fPIC -march=native -flto -fuse-linker-plugin -fno-fat-lto-objects ASTContext_preproc.cpp -o ASTContext_preproc.o
g++ -std=c++14 -c -fPIC -march=native -flto -fuse-linker-plugin -fno-fat-lto-objects ASTConsumer_preproc.cpp -o ASTConsumer_preproc.o
ar cru libAST.a ASTContext_preproc.o ASTConsumer_preproc.o
g++ -flto=4 -std=c++14 -march=native -fuse-linker-plugin -shared -o bla.so CIndex_preproc.cpp libAST.a
/usr/bin/ld: /tmp/ccPyzc8a.ltrans0.ltrans.o: relocation R_X86_64_32 against `_ZZN4llvm11isa_impl_clIN5clang24OMPThreadPrivateDeclAttrEPKNS1_4AttrEE4doitES5_E19__PRETTY_FUNCTION__.lto_priv.73' can not be used when making a shared object; recompile with -fPIC
/tmp/ccPyzc8a.ltrans0.ltrans.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status

Adding the -fPIC flag as told makes the example compile successfully with and without -O3.
---------------------

Removing the -march=native flags causes a compilation error:
g++ -std=c++14 -c -fPIC -O3 -flto -fuse-linker-plugin -fno-fat-lto-objects ASTContext_preproc.cpp -o ASTContext_preproc.o
g++ -std=c++14 -c -fPIC -O3 -flto -fuse-linker-plugin -fno-fat-lto-objects ASTConsumer_preproc.cpp -o ASTConsumer_preproc.o
ar cru libAST.a ASTContext_preproc.o ASTConsumer_preproc.o

g++ -flto=4 -std=c++14 -fuse-linker-plugin -shared -o bla.so CIndex_preproc.cpp libAST.a
In file included from gcc5.1/lib64/gcc/x86_64-unknown-linux-gnu/5.1.0/include/x86intrin.h:27:0,
                 from gcc5.1/include/c++/5.1.0/x86_64-unknown-linux-gnu/bits/opt_random.h:33,
                 from gcc5.1/include/c++/5.1.0/random:50,
                 from gcc5.1/include/c++/5.1.0/bits/stl_algo.h:66,
                 from gcc5.1/include/c++/5.1.0/algorithm:62,
                 from llvm/include/llvm/ADT/StringRef.h:13,
                 from CIndexer.h:19,
                 from CIndex.cpp:15:
gcc5.1/lib64/gcc/x86_64-unknown-linux-gnu/5.1.0/include/ia32intrin.h: In function 'unsigned int __crc32b(unsigned int, unsigned char)':
gcc5.1/lib64/gcc/x86_64-unknown-linux-gnu/5.1.0/include/ia32intrin.h:63:42: error: '__builtin_ia32_crc32qi' was not declared in this scope
   return __builtin_ia32_crc32qi (__C, __V);
                                          ^
...
...

I added the output of
gcc -march=native -Q --help=target
Comment 5 JD 2015-05-07 22:09:24 UTC
Created attachment 35492 [details]
output of gcc -march=native -Q --help=target
Comment 6 Markus Trippelsdorf 2015-05-17 07:31:25 UTC
Confirmed.


Linking CXX executable ../../bin/llvm-dsymutil
[100%] Built target clang-format  
 <nullptr_type 0x3fff8628a6b0 decltype(nullptr) unsigned DI
    size <integer_cst 0x3fff85b11158 type <integer_type 0x3fff85b402a0 bitsizetype> constant 64>
    unit size <integer_cst 0x3fff85b11170 type <integer_type 0x3fff85b401f8 sizetype> constant 8>
    align 8 symtab 0 alias set -1 canonical type 0x3fff85f1c438>
lto1: internal compiler error: in odr_types_equivalent_p, at ipa-devirt.c:1543
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
lto-wrapper: fatal error: /home/trippels/gcc_5/usr/local/bin/g++ returned 1 exit status
compilation terminated.
/home/trippels/bin/ld: fatal error: lto-wrapper failed
collect2: error: ld returned 1 exit status
tools/clang/tools/diagtool/CMakeFiles/diagtool.dir/build.make:228: recipe for target 'bin/diagtool' failed
make[2]: *** [bin/diagtool] Error 1
CMakeFiles/Makefile2:14311: recipe for target 'tools/clang/tools/diagtool/CMakeFiles/diagtool.dir/all' failed
make[1]: *** [tools/clang/tools/diagtool/CMakeFiles/diagtool.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
Linking CXX executable ../../../../bin/clang
 <nullptr_type 0x3fff800abda8 decltype(nullptr) unsigned DI
    size <integer_cst 0x3fff7f7b1158 type <integer_type 0x3fff7f7e02a0 bitsizetype> constant 64>
    unit size <integer_cst 0x3fff7f7b1170 type <integer_type 0x3fff7f7e01f8 sizetype> constant 8>
    align 8 symtab 0 alias set -1 canonical type 0x3fff7fddac98>
lto1: internal compiler error: in odr_types_equivalent_p, at ipa-devirt.c:1543
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
lto-wrapper: fatal error: /home/trippels/gcc_5/usr/local/bin/g++ returned 1 exit status
compilation terminated.
/home/trippels/bin/ld: fatal error: lto-wrapper failed
collect2: error: ld returned 1 exit status
tools/clang/tools/arcmt-test/CMakeFiles/arcmt-test.dir/build.make:108: recipe for target 'bin/arcmt-test' failed
make[2]: *** [bin/arcmt-test] Error 1
CMakeFiles/Makefile2:14900: recipe for target 'tools/clang/tools/arcmt-test/CMakeFiles/arcmt-test.dir/all' failed
make[1]: *** [tools/clang/tools/arcmt-test/CMakeFiles/arcmt-test.dir/all] Error 2
Linking CXX shared library ../../../../lib/libclang.so
/home/trippels/llvm/include/llvm/ADT/ImmutableMap.h:26:32: warning: type ‘const struct value_type’ violates one definition rule [-Wodr]
   typedef const std::pair<T,S> value_type;
                                ^
/home/trippels/llvm/include/llvm/ADT/ImmutableMap.h:26:32: note: a different type is defined in another translation unit
   typedef const std::pair<T,S> value_type;
                                ^
/home/trippels/gcc_5/usr/local/include/c++/5.0.1/bits/stl_pair.h:102:11: note: the first difference of corresponding definitions is field ‘second’
       _T2 second;                /// @c second is a copy of the second object
           ^
/home/trippels/gcc_5/usr/local/include/c++/5.0.1/bits/stl_pair.h:102:11: note: a field of same name but different type is defined in another translation unit
       _T2 second;                /// @c second is a copy of the second object
           ^
/home/trippels/llvm/tools/clang/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp:30:8: note: type ‘struct StreamState’ defined in anonymous namespace can not match type ‘struct StreamState’
 struct StreamState {
        ^
/home/trippels/llvm/tools/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:29:8: note: the incompatible type defined in anonymous namespace in another translation unit
 struct StreamState {
        ^
/home/trippels/llvm/include/llvm/ADT/ImmutableMap.h:30:21: warning: type ‘const struct data_type’ violates one definition rule [-Wodr]
   typedef const S   data_type;
                     ^
/home/trippels/llvm/include/llvm/ADT/ImmutableMap.h:30:21: note: a different type is defined in another translation unit
   typedef const S   data_type;
                     ^
/home/trippels/llvm/tools/clang/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp:32:32: note: the first difference of corresponding definitions is field ‘K’
   enum Kind { Opened, Closed } K;
                                ^
/home/trippels/llvm/tools/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:30:53: note: a field of same name but different type is defined in another translation unit
   enum Kind { Opened, Closed, OpenFailed, Escaped } K;
                                                     ^
/home/trippels/llvm/tools/clang/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp:32:8: note: type ‘Kind’ defined in anonymous namespace can not match type ‘Kind’
   enum Kind { Opened, Closed } K;
        ^
/home/trippels/llvm/tools/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:30:8: note: the incompatible type defined in anonymous namespace in another translation unit
   enum Kind { Opened, Closed, OpenFailed, Escaped } K;
        ^
 <nullptr_type 0x3fff73bf1500 decltype(nullptr) unsigned DI
    size <integer_cst 0x3fff73281158 type <integer_type 0x3fff732b02a0 bitsizetype> constant 64>
    unit size <integer_cst 0x3fff73281170 type <integer_type 0x3fff732b01f8 sizetype> constant 8>
    align 8 symtab 0 alias set -1 canonical type 0x3fff73bf1500>
lto1: internal compiler error: in odr_types_equivalent_p, at ipa-devirt.c:1543
Please submit a full bug report,
with preprocessed source if appropriate.
Comment 7 Markus Trippelsdorf 2015-05-17 14:10:40 UTC
trippels@gcc75 ~ % cat ASTContext_preproc.cpp
namespace std {
template <class _T1, class _T2> struct pair {
  _T1 first;
  _T2 second;
};
template <class _T1, class _T2> pair<_T1, _T2> make_pair(_T1, _T2);
}
namespace llvm {
class StringRef;
}
using llvm::StringRef;
namespace llvm {
class StringRef {
  char *Data;
  unsigned long Length;

public:
  StringRef(int);
};
}
class A {
public:
  void m_fn1(StringRef Name) { std::make_pair(Name, nullptr); }
};
class B {
  A &Idents;
  int m_fn2() const;
};
int B::m_fn2() const { Idents.m_fn1(0); }


trippels@gcc75 ~ % cat CIndex_preproc.cpp
namespace std {
template <class _T1, class _T2> struct pair {
  _T1 first;
  _T2 second;
};
template <class _T1, class _T2> pair<_T1, _T2> make_pair(_T1, _T2);
}
namespace llvm {
class StringRef {
  char *Data;
  unsigned long Length;
};
}
void annotatePreprocessorTokens() {
  llvm::StringRef Name;
  std::make_pair(Name, nullptr);
}

trippels@gcc75 ~ % ~/gcc_5/usr/local/bin/g++ -fPIC -flto -std=c++14 -O2 -c ASTContext_preproc.cpp
trippels@gcc75 ~ % ~/gcc_5/usr/local/bin/g++ -fPIC -flto -std=c++14 -shared -o /dev/null CIndex_preproc.cpp ASTContext_preproc.o
 <nullptr_type 0x7f2accfb9b28 decltype(nullptr) unsigned DI
    size <integer_cst 0x7f2accdc4bb8 type <integer_type 0x7f2accdc8150 bitsizetype> constant 64>
    unit size <integer_cst 0x7f2accdc4bd0 type <integer_type 0x7f2accdc80a8 sizetype> constant 8>
    align 8 symtab 0 alias set 0 canonical type 0x7f2accfb9b28>
lto1: internal compiler error: in odr_types_equivalent_p, at ipa-devirt.c:1543
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
lto-wrapper: fatal error: /home/trippels/gcc_5/usr/local/bin/g++ returned 1 exit status
compilation terminated.
/home/trippels/bin/ld: fatal error: lto-wrapper failed
collect2: error: ld returned 1 exit status
Comment 8 Jan Hubicka 2015-05-19 22:44:53 UTC
Hmm, type preloading strikes back.  We should not try to look into the main variant of VOIDTYPE.
Comment 9 Jan Hubicka 2015-05-19 23:04:23 UTC
Actually it turns out I already fixed this on mainline. The following hunk should be backported to GCC 5 I guess.
Index: ipa-devirt.c
===================================================================
--- ipa-devirt.c        (revision 223252)
+++ ipa-devirt.c        (working copy)
@@ -1536,6 +1536,7 @@ odr_types_equivalent_p (tree t1, tree t2
        break;
       }
     case VOID_TYPE:
+    case NULLPTR_TYPE:
       break;
 
     default:
Comment 10 Richard Biener 2015-07-16 09:12:26 UTC
GCC 5.2 is being released, adjusting target milestone to 5.3.
Comment 11 Richard Biener 2015-12-04 10:45:05 UTC
GCC 5.3 is being released, adjusting target milestone.
Comment 12 Martin Liška 2015-12-09 11:43:31 UTC
Dup.

*** This bug has been marked as a duplicate of bug 65948 ***
Comment 13 Martin Liška 2015-12-10 08:39:46 UTC
Fixed in gcc-5-branch.