Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MS ABI: RTTI data cannot be imported from a DLL and should be linkonce_odr #20480

Closed
ehsan opened this issue Jun 23, 2014 · 6 comments
Closed
Assignees
Labels
bugzilla Issues migrated from bugzilla clang:frontend Language frontend issues, e.g. anything involving "Sema"

Comments

@ehsan
Copy link
Contributor

ehsan commented Jun 23, 2014

Bugzilla Link 20106
Resolution FIXED
Resolved on Jul 03, 2014 00:52
Version unspecified
OS Windows NT
CC @majnemer,@zmodem,@jrmuizel,@rnk

Extended Description

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)

@ehsan
Copy link
Contributor Author

ehsan commented Jun 23, 2014

assigned to @majnemer

@rnk
Copy link
Collaborator

rnk commented Jun 23, 2014

Note that we haven't finished implementing RTTI yet: #19325

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.

@ehsan
Copy link
Contributor Author

ehsan commented Jul 3, 2014

This has not been fixed yet, right? I just hit it again on a fresh clang build as of this morning.

@majnemer
Copy link
Mannequin

majnemer mannequin commented Jul 3, 2014

No, it has not. I've prioritized this, should take a look soon.

@ehsan
Copy link
Contributor Author

ehsan commented Jul 3, 2014

Thsnks!

@majnemer
Copy link
Mannequin

majnemer mannequin commented Jul 3, 2014

Fixed in r212256.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 9, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang:frontend Language frontend issues, e.g. anything involving "Sema"
Projects
None yet
Development

No branches or pull requests

2 participants