linkage errors for VS2005 Release build

Hi all,

I’ve tried to build Release version of clang obtained from the head of SVN using Visual C++ 2005 and got the linkage errors listed at the end of this letter. Has anyone tried to do the same and found some solution/workaround for this? Interestingly enough the Debug version is building without any errors.

One more detail: I used CMake in combination with nmake.

Best regards,

Victor

The errors:

39>clangSema.lib(ParseAST.obj) : error LNK2001: unresolved external symbol “public: virtual class clang::ASTOwningResult<&[thunk]: __thiscall clang::ActionBase::vcall'{4,{flat}}' }'> __thiscall clang::Sema::ActOnCallExpr(class clang::Scope *,class clang::ASTOwningResult<&[thunk]: __thiscall clang::ActionBase::vcall’{4,{flat}}’ }‘>,class clang::SourceLocation,class clang::ASTMultiPtr<&[thunk]: __thiscall clang::ActionBase::`vcall’{4,{flat}}’ }'>,class clang::SourceLocation *,class clang::SourceLocation)” (?ActOnCallExpr@Sema@clang@@UAE?AV?$ASTOwningResult@$1??_9ActionBase@clang@@$B3AE@2@PAVScope@2@V32@VSourceLocation@2@V?$ASTMultiPtr@$1??_9ActionBase@clang@@$B3AE@2@PAV52@2@Z)

39>clangSema.lib(Sema.obj) : error LNK2001: unresolved external symbol “public: virtual class clang::ASTOwningResult<&[thunk]: __thiscall clang::ActionBase::vcall'{4,{flat}}' }'> __thiscall clang::Sema::ActOnCallExpr(class clang::Scope *,class clang::ASTOwningResult<&[thunk]: __thiscall clang::ActionBase::vcall’{4,{flat}}’ }‘>,class clang::SourceLocation,class clang::ASTMultiPtr<&[thunk]: __thiscall clang::ActionBase::`vcall’{4,{flat}}’ }'>,class clang::SourceLocation *,class clang::SourceLocation)” (?ActOnCallExpr@Sema@clang@@UAE?AV?$ASTOwningResult@$1??_9ActionBase@clang@@$B3AE@2@PAVScope@2@V32@VSourceLocation@2@V?$ASTMultiPtr@$1??_9ActionBase@clang@@$B3AE@2@PAV52@2@Z)

39>clangSema.lib(Sema.obj) : error LNK2001: unresolved external symbol “public: virtual class clang::ASTOwningResult<&[thunk]: __thiscall clang::ActionBase::vcall'{8,{flat}}' }'> __thiscall clang::Sema::ActOnCompoundStmt(class clang::SourceLocation,class clang::SourceLocation,class clang::ASTMultiPtr<&[thunk]: __thiscall clang::ActionBase::vcall’{8,{flat}}’ }'>,bool)” (?ActOnCompoundStmt@Sema@clang@@UAE?AV?$ASTOwningResult@$1??_9ActionBase@clang@@$B7AE@2@VSourceLocation@2@0V?$ASTMultiPtr@$1??_9ActionBase@clang@@$B7AE@2@_N@Z)

39>clangSema.lib(Sema.obj) : error LNK2001: unresolved external symbol “public: virtual class clang::ASTOwningResult<&[thunk]: __thiscall clang::ActionBase::vcall'{8,{flat}}' }'> __thiscall clang::Sema::ActOnAsmStmt(class clang::SourceLocation,bool,bool,unsigned int,unsigned int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *,class clang::ASTMultiPtr<&[thunk]: __thiscall clang::ActionBase::vcall’{4,{flat}}’ }‘>,class clang::ASTMultiPtr<&[thunk]: __thiscall clang::ActionBase::vcall'{4,{flat}}' }'>,class clang::ASTOwningResult<&[thunk]: __thiscall clang::ActionBase::vcall’{4,{flat}}’ }‘>,class clang::ASTMultiPtr<&[thunk]: __thiscall clang::ActionBase::`vcall’{4,{flat}}’ }'>,class clang::SourceLocation)” (?ActOnAsmStmt@Sema@clang@@UAE?AV?$ASTOwningResult@$1??_9ActionBase@clang@@$B7AE@2@VSourceLocation@2@_N1IIPAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$ASTMultiPtr@$1??_9ActionBase@clang@@$B3AE@2@3V?$ASTOwningResult@$1??_9ActionBase@clang@@$B3AE@2@30@Z)

39>clangSema.lib(Sema.obj) : error LNK2001: unresolved external symbol “public: virtual void * __thiscall clang::Sema::ActOnClassTemplate(class clang::Scope *,unsigned int,enum clang::Action::TagKind,class clang::SourceLocation,class clang::CXXScopeSpec const &,class clang::IdentifierInfo *,class clang::SourceLocation,class clang::AttributeList *,class clang::ASTMultiPtr<&[thunk]: __thiscall clang::ActionBase::`vcall’{12,{flat}}’ }'>)” (?ActOnClassTemplate@Sema@clang@@UAEPAXPAVScope@2@IW4TagKind@Action@2@VSourceLocation@2@ABVCXXScopeSpec@2@PAVIdentifierInfo@2@2PAVAttributeList@2@V?$ASTMultiPtr@$1??_9ActionBase@clang@@$BM@AE@2@@Z)

Make sure the Release version is compiled with “Disable Language Extensions” (/Za). This option is under clangParse/Properties/Configuration Properties/C/C++/Language.

The parser won’t compile without enabling this switch.

HTH,

snaroff

Hi Steve,

Actually all the clang libraries are compiled successfully. The errors occur when it comes to linking clang executable.

Thanks,

Victor

Viktar Zviarovich wrote:

Hi all,

I’ve tried to build Release version of clang obtained from the head of
SVN using Visual C++ 2005 and got the linkage errors listed at the end
of this letter. Has anyone tried to do the same and found some
solution/workaround for this? Interestingly enough the Debug version
is building without any errors.

One more detail: I used CMake in combination with nmake.

Best regards,

Victor

The errors:

Hmm, strange. Is this the full list of all errors? If not, i.e. if every
single function that uses the smart pointers fails, then this could be a
mismatch of DISABLE_SMART_POINTERS between object files.
If it is the full list, I don't think that's possible. It's a peculiar
selection of functions that's missing: ActOnCallExpr, ActOnCompoundStmt,
ActOnAsmStmt and ActOnClassTemplate, all in Sema.

Sebastian

Hi Sebastian,

This is the full list of errors. As you already figured out from the
messages there are 4 unresolved externals reported which are Sema
member-functions. May be you know the tool that can dump the list of
symbols defined in the library?

Victor

Viktar Zviarovich wrote:

Hi Sebastian,

This is the full list of errors. As you already figured out from the
messages there are 4 unresolved externals reported which are Sema
member-functions. May be you know the tool that can dump the list of
symbols defined in the library?
  

bindump /symbols libname

Should be in the path if you open a Visual Studio command prompt.

Sebastian

In the output of 'dumpbin /symbols clangSema.lib' for debug version I see the following entries for Sema::ActOnCallExpr where obviously the first one is wrong (Sema::SourceLocation and Sema::clang instead of clang::SourceLocation):

20F2 00000000 SECTBAF notype () External | ?ActOnCallExpr@Sema@clang@@UAE?AV?$ASTOwningResult@$1??_9ActionBase@clang@@$B3AE@2@PAVScope@2@V32@VSourceLocation@2@V?$ASTMultiPtr@$1??_9ActionBase@clang@@$B3AE@clang@@PAVSourceLocation@1@V21@@Z (public: virtual class clang::ASTOwningResult<&[thunk]: __thiscall clang::ActionBase::`vcall'{4,{flat}}' }'> __thiscall clang::Sema::ActOnCallExpr(class clang::Scope *,class clang::ASTOwningResult<&[thunk]: __thiscall clang::ActionBase::`vcall'{4,{flat}}' }'>,class clang::SourceLocation,class clang::ASTMultiPtr<&[thunk]: __thiscall clang::ActionBase::`vcall'{4,{flat}}' }'>,class Sema::SourceLocation *,class Sema::clang))

DE1 00000000 UNDEF notype () External | ?ActOnCallExpr@Sema@clang@@UAE?AV?$ASTOwningResult@$1??_9ActionBase@clang@@$B3AE@2@PAVScope@2@V32@VSourceLocation@2@V?$ASTMultiPtr@$1??_9ActionBase@clang@@$B3AE@2@PAV52@2@Z (public: virtual class clang::ASTOwningResult<&[thunk]: __thiscall clang::ActionBase::`vcall'{4,{flat}}' }'> __thiscall clang::Sema::ActOnCallExpr(class clang::Scope *,class clang::ASTOwningResult<&[thunk]: __thiscall clang::ActionBase::`vcall'{4,{flat}}' }'>,class clang::SourceLocation,class clang::ASTMultiPtr<&[thunk]: __thiscall clang::ActionBase::`vcall'{4,{flat}}' }'>,class clang::SourceLocation *,class clang::SourceLocation))

22E 00000000 UNDEF notype () External | ?ActOnCallExpr@Sema@clang@@UAE?AV?$ASTOwningResult@$1??_9ActionBase@clang@@$B3AE@2@PAVScope@2@V32@VSourceLocation@2@V?$ASTMultiPtr@$1??_9ActionBase@clang@@$B3AE@2@PAV52@2@Z (public: virtual class clang::ASTOwningResult<&[thunk]: __thiscall clang::ActionBase::`vcall'{4,{flat}}' }'> __thiscall clang::Sema::ActOnCallExpr(class clang::Scope *,class clang::ASTOwningResult<&[thunk]: __thiscall clang::ActionBase::`vcall'{4,{flat}}' }'>,class clang::SourceLocation,class clang::ASTMultiPtr<&[thunk]: __thiscall clang::ActionBase::`vcall'{4,{flat}}' }'>,class clang::SourceLocation *,class clang::SourceLocation))

In debug version all the entries agree.
Any ideas?

Victor

In the output of 'dumpbin /symbols clangSema.lib' for debug version I see
the following entries for Sema::ActOnCallExpr where obviously the first

one

is wrong (Sema::SourceLocation and Sema::clang instead of
clang::SourceLocation):

In debug version all the entries agree.
Any ideas?

None. I'll see if I can reproduce the error. This will take the weekend,
probably.

Sebastian

In debug version all the entries agree.
Any ideas?

I suppose you already tried, but a full rebuild of the solution may help?

another problem often encountered with llvm and hard to diagnose is when some class/struct is declared as struct and defined as class or vice-versa. this emit only a warning at compile time, but it must change the mangling as it make linking fail. you may want to correct all such warning.

The problem could be a forward declaration in one file with the incorrect class/struct.

just my 2cents.

Hi Cédric,

Unfortunately rebuilding doesn't help.

cl emits plenty of such warnings (type name first seen using 'class' now seen using 'struct') but I think it is not related since the debug version is built successfully and AFAIK the mangling scheme does not change in release version.

Victor

In the output of 'dumpbin /symbols clangSema.lib' for debug version I

see

the following entries for Sema::ActOnCallExpr where obviously the first

one

is wrong (Sema::SourceLocation and Sema::clang instead of
clang::SourceLocation):

In debug version all the entries agree.
Any ideas?

None. I'll see if I can reproduce the error. This will take the weekend,
probably.

First attempt, fail. Apparently, 2003 is not capable of compiling LLVM.

Now I'll have to get it working in 2008, since I don't have a 2005. The
trick is getting CMake to choose that over the 2003.

Sebastian

OK, done that. After fixing a lot of stuff to even get it to compile, it
links cleanly, in both debug and release mode. Sorry, can't help you
further.

I'll attach the patches against LLVM and Clang that I did, in case it
helps.

Sebastian

clang-vs2008.patch (1.95 KB)

llvm-vs2008.patch (4.62 KB)