LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 20106 - MS ABI: RTTI data cannot be imported from a DLL and should be linkonce_odr
Summary: MS ABI: RTTI data cannot be imported from a DLL and should be linkonce_odr
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: Frontend (show other bugs)
Version: unspecified
Hardware: PC Windows NT
: P normal
Assignee: David Majnemer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-23 09:33 PDT by Ehsan Akhgari [:ehsan]
Modified: 2014-07-03 00:52 PDT (History)
5 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ehsan Akhgari [:ehsan] 2014-06-23 09:33:04 PDT
This bug hits us when building ICU as a DLL on Windows:

$ cat type.h
#ifdef DLL
#define API __declspec(dllexport)
#else
#define API __declspec(dllimport)
#endif

struct API VFoo {
virtual ~VFoo();
};

$ cat type.cpp
#include "type.h"

VFoo::~VFoo() {};

$ cat test.cpp
#include "type.h"

class XYZ : public VFoo {};

int main() {
  new XYZ();
}

$ clang-cl -GR type.cpp -DDLL -link -dll -out:type.dll
   Creating library type.lib and object type.exp

$ clang-cl -GR test.cpp type.lib -D_HAS_EXCEPTIONS=0
test-97d7d3.obj : error LNK2001: unresolved external symbol "struct VFoo `RTTI Type Descriptor'" (??_R0?AUVFoo@@@8)
test-97d7d3.obj : error LNK2001: unresolved external symbol "VFoo::`RTTI Class Hierarchy Descriptor'" (??_R3VFoo@@8)
test.exe : fatal error LNK1120: 2 unresolved externals
clang-cl.exe: error: linker command failed with exit code 1120 (use -v to see invocation)
Comment 1 Reid Kleckner 2014-06-23 11:41:36 PDT
Note that we haven't finished implementing RTTI yet: http://llvm.org/PR18951

It looks like RTTI data is *not* exported by MSVC though, so our initial implementation has already gotten the linkage wrong.

This line from our IR is incorrect:
@"\01??_R3VFoo@@8" = available_externally constant %MSRTTIClassHierarchyDescriptor ...

_R3VFoo is not actually available externally.  I think it would be correct to say it is linkonce_odr, so that if we discard the vtable, which is available externally, we can discard the RTTI data.
Comment 2 Ehsan Akhgari [:ehsan] 2014-07-02 17:39:43 PDT
This has not been fixed yet, right?  I just hit it again on a fresh clang build as of this morning.
Comment 3 David Majnemer 2014-07-02 21:26:44 PDT
No, it has not. I've prioritized this, should take a look soon.
Comment 4 Ehsan Akhgari [:ehsan] 2014-07-02 21:43:59 PDT
Thsnks!
Comment 5 David Majnemer 2014-07-03 00:52:11 PDT
Fixed in r212256.