Linker error on fresh working copy

Hello people,

I got the lldb source fresh from SVN, and even after doing the little Python dance for Mavericks (setting SDKROOT to macosx10.8 like Jason Molenda suggested yesterday), I still get compile errors. The linker bails out with this when it tries to link lldb-platform:

Undefined symbols for architecture x86_64:
“llvm::SmallPtrSetImpl::SmallPtrSetImpl(void const**, unsigned int, llvm::SmallPtrSetImpl&&)”, referenced from:
llvm::SmallPtrSet<DWARFDebugInfoEntry const*, 4u>::SmallPtrSet(llvm::SmallPtrSet<DWARFDebugInfoEntry const*, 4u>&&) in liblldb-core.a(SymbolFileDWARF.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Looking deeper, I found that it is declared like that:

#if LLVM_HAS_RVALUE_REFERENCES
SmallPtrSetImpl(const void **SmallStorage, unsigned SmallSize,
SmallPtrSetImpl &&that);
#endif

Could it be that llvm is built without LLVM_HAS_RVALUE_REFERENCES but lldb is built with it?

Félix

Hi Felix, I also got this problem. It comes from the fact that lldb is built in c++11 mode (required), whereas your llvm codebase is built without. You should compile llvm in c++11 as well, or some functions will simply not be in the libraries. If your are using cmake, I submitted (but diid not commit) a patch to optionally enable c++11 building with cmake a few hours ago on the llvm-commit list. For an autoconf build, there is an --enable-cxx11 to configure. Cheers, – Arnaud

I’m building from Xcode, so I guess I need to change scripts/build-llvm.pl. Xcode reports this when I build:

% cd ‘/Users/felix/Projets/OpenSource/lldb/llvm-build/Release+Asserts/x86_64’ && ‘/Users/felix/Projets/OpenSource/lldb/llvm/configure’ --enable-targets=x86_64,arm --disable-terminfo --enable-cxx11 --enable-optimized --enable-assertions --enable-libcpp --build=x86_64-apple-darwin11

–enable-cxx11 is there, but even with that build completing successfully I still get the same error.

Félix

I added --enable-cxx11 to build-llvm.pl, removed my existing llvm-build directory, did a clean build with Xcode and I got a successful link.

The problem came up due to the changes in r195239. When included in C++11 mode, SmallPtrSet.h calls a method in SmallPtrSet.cpp (in llvm). llvm was being built in C++03 mode so the additional method wasn't emitted for SmallPtrSet.o; lldb included SmallPtrSet.h in C++11 mode so a reference to that function was emitted.

(just to state the obvious - I'm sure we were all on the same page here)

Right, I forgot to delete llvm-build.

I deleted llvm-build and made a clean build, but now I get different linker errors. First, I get about 50 warnings that there is direct access to several weak symbols from lldb-platform:

ld: warning: direct access in (anonymous namespace)::ASTInfoCollector::ReadLanguageOptions(clang::LangOptions const&, bool) to global weak symbol llvm::IntrusiveRefCntPtrclang::TargetInfo::getPtr() const means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in (anonymous namespace)::ASTInfoCollector::ReadTargetOptions(clang::TargetOptions const&, bool) to global weak symbol llvm::IntrusiveRefCntPtrclang::TargetInfo::getPtr() const means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in (anonymous namespace)::ASTInfoCollector::ReadTargetOptions(clang::TargetOptions const&, bool) to global weak symbol llvm::IntrusiveRefCntPtrclang::TargetInfo::getPtr() const means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.

[…]

lldb-platform still compiles (although this looks very odd), but the LLDB framework doesn’t compile because symbols used by LLDBWrapPython.cpp are apparently not found (54 of them):

“lldb::SBDebugger::GetSummaryForType(lldb::SBTypeNameSpecifier)”, referenced from:
__wrap_SBDebugger_GetSummaryForType in LLDBWrapPython.o
“lldb::SBDebugger::GetSyntheticForType(lldb::SBTypeNameSpecifier)”, referenced from:
__wrap_SBDebugger_GetSyntheticForType in LLDBWrapPython.o
“lldb::SBTypeSummary::GetOptions()”, referenced from:
__wrap_SBTypeSummary_GetOptions in LLDBWrapPython.o
“lldb::SBTypeSummary::SetOptions(unsigned int)”, referenced from:
__wrap_SBTypeSummary_SetOptions in LLDBWrapPython.o
“lldb::SBTypeSummary::GetDescription(lldb::SBStream&, lldb::DescriptionLevel)”, referenced from:
wrap_SBTypeSummary_GetDescription in LLDBWrapPython.o
lldb_SBTypeSummary___str
(lldb::SBTypeSummary*) in LLDBWrapPython.o

[…]

Any idea?

Disregard the Python errors, that was because of me. (The warnings remain, though.)

Ignore these warnings for now, I will fix them soon. The "lldb-platform" binary links against many internal LLDB and clang libraries and the visibility settings are set incorrectly which is an easy fix.

Greg