Compilation failure on FreeBSD 8.

Hello. I’m compiling trunk LLVM + trunk lldb on i386 FreeBSD 8 system (GCC 4.2.1) and see this error:

/usr/code/llvm/tools/lldb/source/Commands/…/…/include/lldb/Core/FormatNavigator.h: In member function ‘bool lldb_private::FormatNavigator<KeyType, ValueType>::Delete(lldb_private::ConstString) [with KeyType = lldb_private::SharingPtr<lldb_private::RegularExpression>, ValueType = lldb_private::SummaryFormat]’:
CommandObjectType.cpp:1064: instantiated from here
/usr/code/llvm/tools/lldb/source/Commands/…/…/include/lldb/Core/FormatNavigator.h:269: error: call of overloaded ‘Delete_Impl(lldb_private::ConstString&, lldb_private::FormatNavigator<lldb_private::SharingPtr<lldb_private::RegularExpression>, lldb_private::SummaryFormat>::Types<lldb_private::SharingPtr<lldb_private::RegularExpression>, lldb_private::SummaryFormat>)’ is ambiguous
/usr/code/llvm/tools/lldb/source/Commands/…/…/include/lldb/Core/FormatNavigator.h:333: note: candidates are: bool lldb_private::FormatNavigator<KeyType, ValueType>::Delete_Impl(lldb_private::ConstString, lldb_private::FormatNavigator<KeyType, ValueType>::Types<K, V>) [with K = lldb_private::SharingPtr<lldb_private::RegularExpression>, V = lldb_private::SummaryFormat, KeyType = lldb_private::SharingPtr<lldb_private::RegularExpression>, ValueType = lldb_private::SummaryFormat]
/usr/code/llvm/tools/lldb/source/Commands/…/…/include/lldb/Core/FormatNavigator.h:340: note: bool lldb_private::FormatNavigator<KeyType, ValueType>::Delete_Impl(lldb_private::ConstString, lldb_private::FormatNavigator<KeyType, ValueType>::Types<lldb_private::SharingPtr<lldb_private::RegularExpression>, V>) [with V = lldb_private::SummaryFormat, KeyType = lldb_private::SharingPtr<lldb_private::RegularExpression>, ValueType = lldb_private::SummaryFormat]

The reason for this error looks like an ambiguity in template resolution. In order to implement a “special” behavior for regex-based summaries, the Delete_Impl call uses template specialization:

template<typename K, typename V>
bool
Delete_Impl (ConstString type, Types<K,V>)

vs.

template
bool
Delete_Impl (ConstString type, Typeslldb::RegularExpressionSP,V)

Your compiler seems to be inferring correctly the template arguments, but has a doubt on whether it should pick the specialized function, or the general one replacing K = lldb::RegularExpressionSP

This is the first time I see a compiler being confused at this (LLDB is routinely compiled with clang and I guess several people compile it on Linux with GCC as well). This idiom is actually a quite common way to obtain one-function-specialization-inside-class-template.

In order to try and solve this, could you try to clean your LLDB build folder and try to build LLDB alone without the rest of LLVM, or using a different more recent version of GCC?

  • Enrico Granata

Hi,

The versions of gcc that are available on FreeBSD (even on the 9.0 beta, though I haven’t tested them all) will yield that error. clang compiles it fine, though. What I did was use clang to compile that file. You can also compile lldb using only clang.

If you have any more problems, please tell. But I remind you that the FreeBSD port is still very incomplete and can’t be used for debugging, yet.

Regards,

Filipe

I get this same error (and 17 others like it) compiling on Mac OS/X
in XCode version 3.2.6. gcc --version says 4.2.1 (I assume that's the
gcc XCode is using but can't be sure). uname -a says version is 10.8.0.

I followed the instructions documented here http://lldb.llvm.org/build.html
and started with a clean build. This is building just lldb (no llvm/clang)
inside the XCode IDE.

What's the actual source change to fix this? Can you please send a patch?

Thanks in advance,
    -Dawn

Hi,

I think the latest gcc on FreeBSD is 4.6.something, and it also didn’t work. But I only had that error in some 3 or 4 files (I think).

For XCode, I only tried XCode 4.something (on Snow Leopard and Lion), and it worked. But it always used clang to compile everything.

clang on FreeBSD worked fine, even if I only compiled the problematic files on clang (and compiled the rest with g++).

For compiling with XCode, you don’t need any change, it just works (at least in the 4.x versions). Compiling with the makefiles and gcc will give you that error. If you use “make VERBOSE=1”, you can see the commands issued and simply substitute clang++ for g++ in the erroneous commands(or you can configure the Makefiles to use clang).

Regards,

Filip