[LLVMbugs] [Bug 11646] New: Unable to build shared libraries of llvm/clang-3.0 on MinGW32 (MSYS)

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Dec 22 22:56:30 PST 2011


http://llvm.org/bugs/show_bug.cgi?id=11646

             Bug #: 11646
           Summary: Unable to build shared libraries of llvm/clang-3.0 on
                    MinGW32 (MSYS)
           Product: Build scripts
           Version: 3.0
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: cmake
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: oroppas at gmail.com
                CC: llvmbugs at cs.uiuc.edu, ofv at wanadoo.es
    Classification: Unclassified


Created attachment 7799
  --> http://llvm.org/bugs/attachment.cgi?id=7799
The patch for clang/lib/Serialization/CMakeLists.txt

Hi,

I've got the following link error (lots of lots of error messages) of the
shared library (libclangSerialization.dll):

<snip>

CMakeFiles/clangSerialization.dir/objects.a(ModuleManager.cpp.obj):ModuleManager
.cpp:(.text+0x13c7): undefined reference to
`llvm::SmallPtrSetImpl::FindBucketFo
r(void const*) const'
CMakeFiles/clangSerialization.dir/objects.a(ModuleManager.cpp.obj):ModuleManager
.cpp:(.text+0x1a94): undefined reference to
`llvm::SmallVectorBase::grow_pod(uns
igned int, unsigned int)'
CMakeFiles/clangSerialization.dir/objects.a(ModuleManager.cpp.obj):ModuleManager
.cpp:(.text+0x1abc): undefined reference to
`llvm::SmallVectorBase::grow_pod(uns
igned int, unsigned int)'
CMakeFiles/clangSerialization.dir/objects.a(ModuleManager.cpp.obj):ModuleManager
.cpp:(.text+0x1b7a): undefined reference to
`llvm::SmallPtrSetImpl::~SmallPtrSet
Impl()'
CMakeFiles/clangSerialization.dir/objects.a(ModuleManager.cpp.obj):ModuleManager
.cpp:(.text+0x1cc2): undefined reference to
`llvm::SmallPtrSetImpl::insert_imp(v
oid const*)'
CMakeFiles/clangSerialization.dir/objects.a(ModuleManager.cpp.obj):ModuleManager
.cpp:(.text+0x1cff): undefined reference to
`llvm::SmallPtrSetImpl::insert_imp(v
oid const*)'
CMakeFiles/clangSerialization.dir/objects.a(ModuleManager.cpp.obj):ModuleManager
.cpp:(.text+0x1e5c): undefined reference to
`llvm::SmallVectorBase::grow_pod(uns
igned int, unsigned int)'
CMakeFiles/clangSerialization.dir/objects.a(ModuleManager.cpp.obj):ModuleManager
.cpp:(.text+0x1ede): undefined reference to
`llvm::SmallVectorBase::grow_pod(uns
igned int, unsigned int)'
CMakeFiles/clangSerialization.dir/objects.a(ModuleManager.cpp.obj):ModuleManager
.cpp:(.text+0x1fd6): undefined reference to
`llvm::SmallPtrSetImpl::insert_imp(v
oid const*)'
CMakeFiles/clangSerialization.dir/objects.a(ModuleManager.cpp.obj):ModuleManager
.cpp:(.text+0x2000): undefined reference to
`llvm::SmallPtrSetImpl::~SmallPtrSet
Impl()'
CMakeFiles/clangSerialization.dir/objects.a(ModuleManager.cpp.obj):ModuleManager
.cpp:(.text+0x2067): undefined reference to
`clang::FileManager::getFile(llvm::S
tringRef, bool, bool)'
CMakeFiles/clangSerialization.dir/objects.a(ModuleManager.cpp.obj):ModuleManager
.cpp:(.text+0x223e): undefined reference to
`llvm::SmallPtrSetImpl::insert_imp(v
oid const*)'
CMakeFiles/clangSerialization.dir/objects.a(ModuleManager.cpp.obj):ModuleManager
.cpp:(.text+0x2290): undefined reference to
`llvm::SmallPtrSetImpl::insert_imp(v
oid const*)'
CMakeFiles/clangSerialization.dir/objects.a(ModuleManager.cpp.obj):ModuleManager
.cpp:(.text+0x27ad): undefined reference to
`llvm::SmallVectorBase::grow_pod(uns
igned int, unsigned int)'
CMakeFiles/clangSerialization.dir/objects.a(ModuleManager.cpp.obj):ModuleManager
.cpp:(.text+0x27cb): undefined reference to `llvm::system_category()'
CMakeFiles/clangSerialization.dir/objects.a(ModuleManager.cpp.obj):ModuleManager
.cpp:(.text+0x27fd): undefined reference to
`clang::FileManager::getBufferForFil
e(llvm::StringRef, std::string*)'
CMakeFiles/clangSerialization.dir/objects.a(ModuleManager.cpp.obj):ModuleManager
.cpp:(.text+0x2839): undefined reference to
`llvm::MemoryBuffer::getSTDIN(llvm::
OwningPtr<llvm::MemoryBuffer>&)'
CMakeFiles/clangSerialization.dir/objects.a(ModuleManager.cpp.obj):ModuleManager
.cpp:(.text+0x285b): undefined reference to `llvm::error_code::message() const'
collect2: ld returned 1 exit status
make[2]: *** [bin/libclangSerialization.dll] Error 1
make[1]: ***
[tools/clang/lib/Serialization/CMakeFiles/clangSerialization.dir/al
l] Error 2
make: *** [all] Error 2

Here's my CMake script:

cmake -DCMAKE_INSTALL_PREFIX:PATH=/mingw \
      -DCMAKE_BUILD_TYPE=Release \
      -DBUILD_SHARED_LIBS:BOOL=ON \
      -DLLVM_TARGETS_TO_BUILD:STRING=X86 \
      -G "MSYS Makefiles" \
      ../llvm-3.0.src

To fix the undefined reference to LLVM libraries all we need is to set
LLVM_LINK_COMPONENTS with the "support" component (i.e. libLLVMSupport).

But then, we still get huge number of undefined reference errors where
the linker is unable to link to, say libclangAST, etc.

With the attached patch, I finally managed to bring down the number of
undefined reference errors to the reasonable level:

cd /D/packages/llvm-build/tools/clang/lib/Serialization && /C/MinGW/bin/g++.exe
    -shared -o ../../../../bin/libclangSerialization.dll
-Wl,--out-implib,../../
../../lib/libclangSerialization.dll.a
-Wl,--major-image-version,0,--minor-image-
version,0 -Wl,--whole-archive CMakeFiles/clangSerialization.dir/objects.a
-Wl,--
no-whole-archive ../../../../lib/libclangAST.dll.a
../../../../lib/libclangSema.
dll.a ../../../../lib/libLLVMSupport.dll.a -limagehlp -lpsapi
../../../../lib/li
bclangAnalysis.dll.a ../../../../lib/libclangIndex.dll.a
../../../../lib/libclan
gAST.dll.a ../../../../lib/libclangLex.dll.a
../../../../lib/libclangBasic.dll.a
 ../../../../lib/libLLVMMC.dll.a ../../../../lib/libLLVMObject.dll.a
../../../..
/lib/libLLVMCore.dll.a ../../../../lib/libLLVMSupport.dll.a -limagehlp -lpsapi
-
lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid
-lcomd
lg32 -ladvapi32
Creating library file: ../../../../lib/libclangSerialization.dll.a
CMakeFiles/clangSerialization.dir/objects.a(ASTReader.cpp.obj):ASTReader.cpp:(.t
ext+0x16d6c): undefined reference to
`clang::NormalizeDashIncludePath(llvm::Stri
ngRef, clang::FileManager&)'
CMakeFiles/clangSerialization.dir/objects.a(ChainedIncludesSource.cpp.obj):Chain
edIncludesSource.cpp:(.text+0x874): undefined reference to
`clang::TextDiagnosti
cPrinter::TextDiagnosticPrinter(llvm::raw_ostream&, clang::DiagnosticOptions
con
st&, bool)'
CMakeFiles/clangSerialization.dir/objects.a(ChainedIncludesSource.cpp.obj):Chain
edIncludesSource.cpp:(.text+0x94f): undefined reference to
`clang::CompilerInsta
nce::CompilerInstance()'
CMakeFiles/clangSerialization.dir/objects.a(ChainedIncludesSource.cpp.obj):Chain
edIncludesSource.cpp:(.text+0x95b): undefined reference to
`clang::CompilerInsta
nce::setInvocation(clang::CompilerInvocation*)'
CMakeFiles/clangSerialization.dir/objects.a(ChainedIncludesSource.cpp.obj):Chain
edIncludesSource.cpp:(.text+0x967): undefined reference to
`clang::CompilerInsta
nce::setDiagnostics(clang::DiagnosticsEngine*)'
CMakeFiles/clangSerialization.dir/objects.a(ChainedIncludesSource.cpp.obj):Chain
edIncludesSource.cpp:(.text+0x98a): undefined reference to
`clang::CompilerInsta
nce::setTarget(clang::TargetInfo*)'
CMakeFiles/clangSerialization.dir/objects.a(ChainedIncludesSource.cpp.obj):Chain
edIncludesSource.cpp:(.text+0x992): undefined reference to
`clang::CompilerInsta
nce::createFileManager()'
CMakeFiles/clangSerialization.dir/objects.a(ChainedIncludesSource.cpp.obj):Chain
edIncludesSource.cpp:(.text+0x9a1): undefined reference to
`clang::CompilerInsta
nce::createSourceManager(clang::FileManager&)'
CMakeFiles/clangSerialization.dir/objects.a(ChainedIncludesSource.cpp.obj):Chain
edIncludesSource.cpp:(.text+0x9a9): undefined reference to
`clang::CompilerInsta
nce::createPreprocessor()'
CMakeFiles/clangSerialization.dir/objects.a(ChainedIncludesSource.cpp.obj):Chain
edIncludesSource.cpp:(.text+0x9d3): undefined reference to
`clang::CompilerInsta
nce::createASTContext()'
CMakeFiles/clangSerialization.dir/objects.a(ChainedIncludesSource.cpp.obj):Chain
edIncludesSource.cpp:(.text+0xa70): undefined reference to
`clang::CompilerInsta
nce::setASTConsumer(clang::ASTConsumer*)'
CMakeFiles/clangSerialization.dir/objects.a(ChainedIncludesSource.cpp.obj):Chain
edIncludesSource.cpp:(.text+0xa88): undefined reference to
`clang::CompilerInsta
nce::createSema(clang::TranslationUnitKind, clang::CodeCompleteConsumer*)'
CMakeFiles/clangSerialization.dir/objects.a(ChainedIncludesSource.cpp.obj):Chain
edIncludesSource.cpp:(.text+0xd40): undefined reference to
`clang::CompilerInsta
nce::InitializeSourceManager(llvm::StringRef)'
CMakeFiles/clangSerialization.dir/objects.a(ChainedIncludesSource.cpp.obj):Chain
edIncludesSource.cpp:(.text+0xd5b): undefined reference to
`clang::ParseAST(clan
g::Sema&, bool)'
collect2: ld returned 1 exit status
make[2]: *** [bin/libclangSerialization.dll] Error 1
make[2]: Leaving directory `/d/packages/llvm-build'
make[1]: ***
[tools/clang/lib/Serialization/CMakeFiles/clangSerialization.dir/al
l] Error 2
make[1]: Leaving directory `/d/packages/llvm-build'
make: *** [all] Error 2

At this point the missing library to be linked is libclangFrontend.
However, libclangFrontend depends on libclangSerialization as well,
resulting in the circular dependency.

How can we break this circular dependency between libclangFrontend and
libclangSerialization?

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list