[cfe-dev] Clang building Clang (MinGW-w64) on Windows link error

Ruben Van Boxem vanboxem.ruben at gmail.com
Sun Jul 29 03:00:56 PDT 2012


Hi,

Using a Clang (built with GCC 4.6.3 and MinGW-w64), which uses that GCC's
libstdc++, I am attempting to let it reproduce (ie build itself). This
Clang is currently revision 160923, so very recent, although below problem
has been present for a long time. To reproduce, you can download this
package<http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/experimental>,
which includes the necessary Clang and GCC stuff to have a working 32-bit
Clang on Windows. It is an older revision, but exhibits the same problem.

Easiest is by using configure under MSYS (a bash environment for Windows),
setting CXX=clang++. Another possibility is using attached CMake scripts
(put them in share/cmake-2.8/Modules/Platform) and calling cmake with
-DCMAKE_CXX_COMPILER=clang++.

The link error is the following:

Linking CXX shared library ..\..\..\..\bin\liblibclang.dll
Creating library file: ..\..\..\..\lib\liblibclang.dll.a
..\..\..\..\lib\libclangFrontend.a(ASTUnit.cpp.obj):fake:(.rdata$_ZTVN4llvm37CrashRecoveryContextReleaseRefCleanupIN5clang17DiagnosticsEngineEEE[vtable
for
llvm::CrashRecoveryContextReleaseRefCleanup<clang::DiagnosticsEngine>]+0x0):
multiple definition of `vtable for
llvm::CrashRecoveryContextReleaseRefCleanup<clang::DiagnosticsEngine>'
CMakeFiles\libclang.dir/objects.a(CIndex.cpp.obj):fake:(.data$_ZTVN4llvm37CrashRecoveryContextReleaseRefCleanupIN5clang17DiagnosticsEngineEEE[vtable
for
llvm::CrashRecoveryContextReleaseRefCleanup<clang::DiagnosticsEngine>]+0x0):
first defined here
..\..\..\..\lib\libclangFrontend.a(ASTUnit.cpp.obj):fake:(.rdata$_ZTVN4llvm31CrashRecoveryContextCleanupBaseINS_37CrashRecoveryContextReleaseRefCleanupIN5clang17DiagnosticsEngineEEES3_EE[vtable
for
llvm::CrashRecoveryContextCleanupBase<llvm::CrashRecoveryContextReleaseRefCleanup<clang::DiagnosticsEngine>,
clang::DiagnosticsEngine>]+0x0): multiple definition of `vtable for
llvm::CrashRecoveryContextCleanupBase<llvm::CrashRecoveryContextReleaseRefCleanup<clang::DiagnosticsEngine>,
clang::DiagnosticsEngine>'
CMakeFiles\libclang.dir/objects.a(CIndex.cpp.obj):fake:(.data$_ZTVN4llvm31CrashRecoveryContextCleanupBaseINS_37CrashRecoveryContextReleaseRefCleanupIN5clang17DiagnosticsEngineEEES3_EE[vtable
for
llvm::CrashRecoveryContextCleanupBase<llvm::CrashRecoveryContextReleaseRefCleanup<clang::DiagnosticsEngine>,
clang::DiagnosticsEngine>]+0x0): first defined here
..\..\..\..\lib\libclangAST.a(AttrImpl.cpp.obj): In function
`ZN5clang27X86ForceAlignArgPointerAttrD1Ev':
M:/Development/Source/LLVM/tools/clang/lib/AST/AttrImpl.cpp:20: multiple
definition of `clang::InheritableAttr::~InheritableAttr()'
..\..\..\..\lib\libclangSerialization.a(ASTReaderDecl.cpp.obj):fake:(.text$_ZN5clang15InheritableAttrD0Ev[clang::InheritableAttr::~InheritableAttr()]+0x0):
first defined here
..\..\..\..\lib\libclangAST.a(AttrImpl.cpp.obj): In function
`ZN5clang27X86ForceAlignArgPointerAttrD1Ev':
M:/Development/Source/LLVM/tools/clang/lib/AST/AttrImpl.cpp:20: multiple
definition of `clang::InheritableParamAttr::~InheritableParamAttr()'
..\..\..\..\lib\libclangSerialization.a(ASTReaderDecl.cpp.obj):fake:(.text$_ZN5clang20InheritableParamAttrD0Ev[clang::InheritableParamAttr::~InheritableParamAttr()]+0x0):
first defined here
collect2: ld returned 1 exit status
clang++: error: linker (via gcc) command failed with exit code 1 (use -v to
see
invocation)
mingw32-make[2]: *** [bin/liblibclang.dll] Error 1
mingw32-make[1]: ***
[tools/clang/tools/libclang/CMakeFiles/libclang.dir/all] Error 2
mingw32-make: *** [all] Error 2

This does not happen when building with GCC. I can upload the fies in
question or info from these files if you want. I just don't know where to
start looking. All files (including the AttrImpl.inc file) are identical in
both builds. Could this have something to do with weak symbols, which are
absent on Windows, and static+inline or something? I can't find a visual
multiple definition of the InheritableAttr destructor, and vtable
definitions are hard to find at best.

Any help is much appreciated!

Ruben

PS: please reply to me as well, I'm not subscribed to cfe-dev
PS2: another build failed when linking the clang executable:
llvm[4]: Linking Release executable clang (without symbols)
M:/Development/msys/home/Ruben/LLVm/Release/lib/libclangAST.a(AttrImpl.o):fake:(.text$_ZN5clang15InheritableAttrD0Ev+0x0):
multiple definition of `clang::InheritableAttr::~InheritableAttr()'
M:/Development/msys/home/Ruben/LLVm/Release/lib/libclangSerialization.a(ASTReaderDecl.o):fake:(.text$_ZN5clang15InheritableAttrD0Ev[clang::InheritableAttr::~InheritableAttr()]+0x0):
first defined here
M:/Development/msys/home/Ruben/LLVm/Release/lib/libclangAST.a(AttrImpl.o):fake:(.text$_ZN5clang20InheritableParamAttrD0Ev+0x0):
multiple definition of
`clang::InheritableParamAttr::~InheritableParamAttr()'
M:/Development/msys/home/Ruben/LLVm/Release/lib/libclangSerialization.a(ASTReaderDecl.o):fake:(.text$_ZN5clang20InheritableParamAttrD0Ev[clang::InheritableParamAttr::~InheritableParamAttr()]+0x0):
first defined here
m:/development/mingw32-dw2/bin/../lib/gcc/i686-w64-mingw32/4.6.3/../../../../i686-w64-mingw32/bin/ld.exe:
M:/Development/msys/home/Ruben/LLVm/Release/lib/libclangSerialization.a(ASTReaderDecl.o):
bad reloc address 0x24 in section `.text$_ZN
5clang11DeclVisitorINS_13ASTDeclReaderEvE5VisitEPNS_4DeclE[clang::DeclVisitor<clang::ASTDeclReader,
void>::Visit(clang::Decl*)]'
collect2: ld returned 1 exit status
clang++: error: linker (via gcc) command failed with exit code 1 (use -v to
see
invocation)
make[4]: *** [/usr/home/Ruben/LLVm/Release/bin/clang.exe] Error 1
make[4]: Leaving directory `/home/Ruben/LLVm/tools/clang/tools/driver'
make[3]: *** [all] Error 1
make[3]: Leaving directory `/home/Ruben/LLVm/tools/clang/tools'
make[2]: *** [all] Error 1
make[2]: Leaving directory `/home/Ruben/LLVm/tools/clang'
make[1]: *** [clang/.makeall] Error 2
make[1]: Leaving directory `/home/Ruben/LLVm/tools'
make: *** [all] Error 1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120729/2216965b/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Windows-Clang-C.cmake
Type: application/octet-stream
Size: 121 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120729/2216965b/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Windows-Clang-CXX.cmake
Type: application/octet-stream
Size: 37 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120729/2216965b/attachment-0001.obj>


More information about the cfe-dev mailing list