This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/57375] gnu multiversioning selects different version depending on link order


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57375

--- Comment #3 from davidxl at google dot com ---
(In reply to Sriraman Tallam from comment #2)
> IMO, This is working as expected.
> 
> You define corei7 only in mv12-aux1.cc, so the compilation of mv12.C and
> mv12-aux.cc do not see the corei7 version.  The version resolver function
> that is generated is a comdat function, and there are 2 copies generated for
> the 2 source files with a call to foo, mv12.C and mv12-aux1.cc. However, one
> of the copies is different, that generated when compiling mv12-aux1.cc
> because it has the extra corei7  version.  So, depending on the link order
> whichever comdat copy gets kept either calls the corei7 version or not.
> Usually, the linker keeps the first comdat copy seen so if you put
> mv12-aux1.cc ahead of mv12.C, the corei7 version will be called and the
> reverse will not call it.
> 
> The fix is in the source. Either make every source file see the corei7
> version or hide it from all. 
> 
> The linker can be made to complain that the comdats differ if it could be
> taught about version resolvers. This may be more involved.


There is no need to conditionally declare/define corei7 version in one file
only -- the additional time cost is very small.

David


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]