Build error on Windows (MinGW)

Hi,

With recent LLVM+Clang, I get several multiple definition errors when
building Clang and LLVM (both at revision 133168):

[100%] Building CXX object
tools/clang/tools/arcmt-test/CMakeFiles/arcmt-test.dir/arcmt-test.cpp.obj
Linking CXX executable ..\..\..\..\bin\arcmt-test.exe
..\..\..\..\lib\libLLVMSupport.a(CommandLine.cpp.obj):CommandLine.cpp:(.text+0x22b6):
multiple definition of `llvm::cl::ParseCommandLineOptions(int, char**,
char const*, bool)'
..\..\..\..\lib\liblibclang.dll.a(d008925.o):(.text+0x0): first defined here
..\..\..\..\lib\libLLVMSupport.a(CommandLine.cpp.obj):CommandLine.cpp:(.text+0x852b):
multiple definition of `llvm::cl::PrintHelpMessage()'
..\..\..\..\lib\liblibclang.dll.a(d008899.o):(.text+0x0): first defined here
..\..\..\..\lib\libLLVMSupport.a(CommandLine.cpp.obj):CommandLine.cpp:(.text$_ZN4llvm2cl3optIbLb0ENS0_6parserIbEEE4doneEv[llvm::cl::opt<bool,
false, llvm::cl::parser<bool> >::done()]+0x0): multiple definition of
`llvm::cl::opt<bool, false, llvm::cl::parser<bool> >::done()'
..\..\..\..\lib\liblibclang.dll.a(d008943.o):(.text+0x0): first defined here
..\..\..\..\lib\libLLVMSupport.a(CommandLine.cpp.obj):CommandLine.cpp:(.text+0x64):
multiple definition of `llvm::cl::extrahelp::extrahelp(char const*)'
..\..\..\..\lib\liblibclang.dll.a(d009065.o):(.text+0x0): first defined here
..\..\..\..\lib\libLLVMSupport.a(raw_ostream.cpp.obj):raw_ostream.cpp:(.text+0x282):
multiple definition of `llvm::raw_ostream::operator<<(unsigned long)'
..\..\..\..\lib\liblibclang.dll.a(d002228.o):(.text+0x0): first defined here
..\..\..\..\lib\libLLVMSupport.a(raw_ostream.cpp.obj):raw_ostream.cpp:(.text+0xb1a):
multiple definition of `llvm::raw_ostream::write(unsigned char)'
..\..\..\..\lib\liblibclang.dll.a(d002208.o):(.text+0x0): first defined here
..\..\..\..\lib\libLLVMSupport.a(raw_ostream.cpp.obj):raw_ostream.cpp:(.text+0xbda):
multiple definition of `llvm::raw_ostream::write(char const*, unsigned
long long)'
..\..\..\..\lib\liblibclang.dll.a(d002207.o):(.text+0x0): first defined here
..\..\..\..\lib\libLLVMSupport.a(raw_ostream.cpp.obj):raw_ostream.cpp:(.text+0x1f11):
multiple definition of `llvm::outs()'
..\..\..\..\lib\liblibclang.dll.a(d011520.o):(.text+0x0): first defined here
..\..\..\..\lib\libLLVMSupport.a(raw_ostream.cpp.obj):raw_ostream.cpp:(.text+0x20bf):
multiple definition of `llvm::errs()'
..\..\..\..\lib\liblibclang.dll.a(d011519.o):(.text+0x0): first defined here
..\..\..\..\lib\libLLVMSupport.a(PathV2.cpp.obj):PathV2.cpp:(.text+0x225e):
multiple definition of `llvm::sys::path::filename(llvm::StringRef)'
..\..\..\..\lib\liblibclang.dll.a(d010452.o):(.text+0x0): first defined here
..\..\..\..\lib\libLLVMSupport.a(Path.cpp.obj):Path.cpp:(.text+0x2cfc):
multiple definition of `llvm::sys::Path::GetMainExecutable(char
const*, void*)'
..\..\..\..\lib\liblibclang.dll.a(d010404.o):(.text+0x0): first defined here
..\..\..\..\lib\libLLVMSupport.a(Signals.cpp.obj):Signals.cpp:(.text+0x371):
multiple definition of `llvm::sys::PrintStackTraceOnErrorSignal()'
..\..\..\..\lib\liblibclang.dll.a(d010345.o):(.text+0x0): first defined here
..\..\..\..\lib\libclangLex.a(Lexer.cpp.obj):Lexer.cpp:(.text+0xd5c):
multiple definition of
`clang::Lexer::MeasureTokenLength(clang::SourceLocation,
clang::SourceManager const&, clang::LangOptions const&)'
..\..\..\..\lib\liblibclang.dll.a(d021476.o):(.text+0x0): first defined here
..\..\..\..\lib\libclangBasic.a(Diagnostic.cpp.obj):Diagnostic.cpp:(.text+0x36e):
multiple definition of
`clang::Diagnostic::setClient(clang::DiagnosticClient*, bool)'
..\..\..\..\lib\liblibclang.dll.a(d014750.o):(.text+0x0): first defined here
..\..\..\..\lib\libclangBasic.a(Diagnostic.cpp.obj):Diagnostic.cpp:(.text+0x6c):
multiple definition of
`clang::Diagnostic::Diagnostic(llvm::IntrusiveRefCntPtr<clang::DiagnosticIDs>
const&, clang::DiagnosticClient*, bool)'
..\..\..\..\lib\liblibclang.dll.a(d014751.o):(.text+0x0): first defined here
..\..\..\..\lib\libclangBasic.a(Diagnostic.cpp.obj):Diagnostic.cpp:(.text+0x24e):
multiple definition of `clang::Diagnostic::~Diagnostic()'
..\..\..\..\lib\liblibclang.dll.a(d014753.o):(.text+0x0): first defined here
..\..\..\..\lib\libclangBasic.a(DiagnosticIDs.cpp.obj):DiagnosticIDs.cpp:(.text+0x72e):
multiple definition of `clang::DiagnosticIDs::DiagnosticIDs()'
..\..\..\..\lib\liblibclang.dll.a(d016349.o):(.text+0x0): first defined here
..\..\..\..\lib\libclangBasic.a(DiagnosticIDs.cpp.obj):DiagnosticIDs.cpp:(.text+0x758):
multiple definition of `clang::DiagnosticIDs::~DiagnosticIDs()'
..\..\..\..\lib\liblibclang.dll.a(d016351.o):(.text+0x0): first defined here
..\..\..\..\lib\libclangBasic.a(SourceManager.cpp.obj):SourceManager.cpp:(.text+0x33c6):
multiple definition of
`clang::SourceManager::getPresumedLoc(clang::SourceLocation) const'
..\..\..\..\lib\liblibclang.dll.a(d028453.o):(.text+0x0): first defined here
collect2: ld returned 1 exit status

Using Mingw r133168 and r133209 fails here for me…

[ 76%] Building arm_neon.inc…
…\bin\tblgen.exe: Record VCVT_N_F32' does not have a field named isVCVT_N’!

make[2]: *** [tools/clang/include/clang/Basic/arm_neon.inc.tmp] Error 1
make[1]: *** [tools/clang/include/clang/Basic/CMakeFiles/ClangARMNeon.dir/all] Error 2
make: *** [all] Error 2

I was able to build using VS and cmake on windows. But that was using 2.9. Maybe you want to consider using a tag?

i’ll note that you may be missing headers and they are in the build folder. You may need python installed as well but i am unsure

Ruben,

It seems libclang.dll (and possibly cyclic deps) issue, ...
In arcmt-test/Makefile, libclang.dll (and import libs) is not touched.

...Takumi

Using Mingw r133168 and r133209 fails here for me...

[ 76%] Building arm_neon.inc...
..\..\..\..\..\bin\tblgen.exe: Record `VCVT_N_F32' does not have a field named `isVCVT_N'!

make[2]: *** [tools/clang/include/clang/

Basic/arm_neon.inc.tmp] Error 1
make[1]: *** [tools/clang/include/clang/Basic/CMakeFiles/ClangARMNeon.dir/all] Error 2
make: *** [all] Error 2

Nope, don't have that problem with r133168 or r133250. Maybe there's
something wrong with your setup?

I was able to build using VS and cmake on windows. But that was using 2.9. Maybe you want to consider using a tag?

i'll note that you may be missing headers and they are in the build folder. You may need python installed as well but i am unsure

I have all the tools and utilities installed. "make check", which
tests LLVM itself and uses Python and GNUWin32 tools, shows no failed
tests. It's the Clang part that isn't working.

Ruben, FYI, I have built arc-test to eliminate "libclang" from
CMakeLists.txt on mingw.
I will propose it when I checked on some platforms.

...Takumi

Great, thanks!

I can confirm it works.

Ruben