MantisBT - Community
View Issue Details
0031680Community[OCCT] OCCT:Configurationpublic2020-07-21 14:322020-07-25 14:02
BenjaminBihler 
bugmaster 
normalminor 
verifiedfixed 
Mingw-w64Windows10
[OCCT] 7.4.0 
[OCCT] 7.5.0* 
Not required
0031680: Configuration - Compilation Fails With G++ 10.1, LD 2.34 and Link-Time Optimization
When building OCCT with g++ 10.1, ld 2.34 and link-time optimization (-flto) using Mingw-w64 on Windows 10, I get the following error:

C:/mingw-w64-10.1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: 
LDOM_OSStream.cxx.obj (symbol from plugin):(.gnu.linkonce.t._ZTV13LDOM_OSStream[_ZTV13LDOM_OSStream]+0x0): 
multiple definition of `VTT for LDOM_OSStream'; PCDM_ReadWriter.cxx.obj (symbol from plugin):(.gnu.linkonce.t._ZTV13LDOM_OSStream[_ZTC13LDOM_OSStream0_So]+0x0): 
first defined here
C:/mingw-w64-10.1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: 
LDOM_OSStream.cxx.obj (symbol from plugin):(.gnu.linkonce.t._ZTV13LDOM_OSStream[_ZTV13LDOM_OSStream]+0x0): 
multiple definition of `vtable for LDOM_OSStream'; PCDM_ReadWriter.cxx.obj (symbol from plugin):(.gnu.linkonce.t._ZTV13LDOM_OSStream[_ZTC13LDOM_OSStream0_So]+0x0): 
first defined here
C:/mingw-w64-10.1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: 
LDOM_OSStream.cxx.obj (symbol from plugin):(.gnu.linkonce.t._ZTV13LDOM_OSStream[_ZTV13LDOM_OSStream]+0x0): 
multiple definition of `construction vtable for std::ostream-in-LDOM_OSStream'; PCDM_ReadWriter.cxx.obj 
(symbol from plugin):(.gnu.linkonce.t._ZTV13LDOM_OSStream[_ZTC13LDOM_OSStream0_So]+0x0): first defined 
here


I have found more "multiple definition" errors with this tool combination, but I do not fully understand the reason. See https://stackoverflow.com/questions/62150048/why-does-g-10-1-complain-about-a-named-lambda-in-a-header-file-and-others-do-n [^] for another example. These errors haven't been there up to g++ 9.2 (I do not know the corresponding ld version number anymore), but appear here from g++ 10.1 on.

This post: https://stackoverflow.com/a/57504289/2492801 [^]
explains how to force vtable generation. According to my understanding the vtable of LDOM_OSStream is generated in more than one compilation unit, since that class does not have a non-inline virtual function.

Following the cited post, I propose to add a non-inline virtual destructor. Indeed this solves the compilation problems here.
Not required
No tags attached.
Issue History
2020-07-21 14:32BenjaminBihlerNew Issue
2020-07-21 14:32BenjaminBihlerAssigned To => BenjaminBihler
2020-07-21 14:38gitNote Added: 0093228
2020-07-21 14:38BenjaminBihlerAssigned ToBenjaminBihler => bugmaster
2020-07-21 14:38BenjaminBihlerStatusnew => resolved
2020-07-21 14:38BenjaminBihlerSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=23163#r23163
2020-07-21 15:14kgvStatusresolved => reviewed
2020-07-25 13:21bugmasterNote Added: 0093313
2020-07-25 13:21bugmasterStatusreviewed => tested
2020-07-25 13:29bugmasterTest case number => Not required
2020-07-25 13:57bugmasterChangeset attached => occt master 6531dfea
2020-07-25 13:57bugmasterStatustested => verified
2020-07-25 13:57bugmasterResolutionopen => fixed
2020-07-25 14:02gitNote Added: 0093336

Notes
(0093228)
git   
2020-07-21 14:38   
Branch CR31680 has been created by BenjaminBihler.

SHA-1: ca5ec1c316c7618a6ad46cd0f60662f7b3bfa48c


Detailed log of new commits:

Author: Benjamin Bihler
Date: Tue Jul 21 13:37:03 2020 +0200

    0031680: Configuration - Compilation Fails With G++ 10.1, LD 2.34 and Link-Time Optimization
    
    Added a non-inline empty virtual destructor to LDOM_OSStream to force vtable generation in one
    translation unit only.
(0093313)
bugmaster   
2020-07-25 13:21   
Combination -
OCCT branch : IR-2020-07-24
master SHA - 4c7a3faef5f292475c23ee615ad49d57fc039b58
a206de37fbfa0bf71bd534ae47192bbec23b8522
Products branch : IR-2020-07-24 SHA - be95aa91db3bd344c872901349e58022d3c687fc
was compiled on Linux, MacOS and Windows platforms and tested in optimize mode.

Number of compiler warnings:
No new/fixed warnings

Regressions/Differences/Improvements:
No regressions/differences

CPU differences:
Debian80-64:
OCCT
Total CPU difference: 17271.39000000011 / 17230.04000000007 [+0.24%]
Products
Total CPU difference: 800.6699999999917 / 791.7399999999936 [+1.13%]
Windows-64-VC14:
OCCT
Total CPU difference: 18742.140625 / 18745.390625 [-0.02%]
Products
Total CPU difference: 1329.234375 / 1321.390625 [+0.59%]


Image differences :
No differences that require special attention

Memory differences :
No differences that require special attention
(0093336)
git   
2020-07-25 14:02   
Branch CR31680 has been deleted by inv.

SHA-1: ca5ec1c316c7618a6ad46cd0f60662f7b3bfa48c