Building KDevelop/KDevPlatform with clang?

Milian Wolff mail at milianw.de
Sat Jan 11 13:23:37 UTC 2014


On Saturday 11 January 2014 00:33:18 Andreas Pakulat wrote:
> Hi,
> 
> since I recall Milian bringing up one or two problems with the KDE cmake
> scripts and clang I'm wondering wether those are resolved for KDE 4.113
> already? I happened to try out clang just earlier today and instantly ran
> into multiple problems in kdevplatform (while kate built just fine):

I'm building KDev* with clang & ccache on my laptop just fine. What clang 
version do you use? Could you try to run make VERBOSE=1 and verify that there 
is _no_ trace of -fdelayed-template-parsing ? That could explain at least some 
of the STL issues below.

Generally, what verison of GCC & clang do you use? I have 4.8.2 and 3.3 
respectively.

> n file included from /usr/include//c++/4.8/bits/stl_tree.h:66:
> /usr/include//c++/4.8/bits/alloc_traits.h:57:35: error: in-class
> initializer for static data member is not a constant expression
>       static const bool __value = _S_chk<_Alloc, _Tp>(nullptr);
>                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /usr/include//c++/4.8/bits/alloc_traits.h:64:19: note: in instantiation of
> template class
> 'std::__alloctr_rebind_helper<std::allocator<KDevelop::TopDUContext *>,
> KDevelop::TopDUContext *>' requested here
>            bool = __alloctr_rebind_helper<_Alloc, _Tp>::__value>
>                   ^
> /usr/include//c++/4.8/bits/alloc_traits.h:202:9: note: in instantiation of
> default argument for
> '__alloctr_rebind<std::allocator<KDevelop::TopDUContext *>,
> KDevelop::TopDUContext *>' required here
>         using rebind_alloc = typename __alloctr_rebind<_Alloc, _Tp>::__type;
> ^~~~~
> /usr/include//c++/4.8/ext/alloc_traits.h:196:47: note: in instantiation of
> template type alias 'rebind_alloc' requested here
>       { typedef typename _Base_type::template rebind_alloc<_Tp> other; };
>                                               ^
> /usr/include//c++/4.8/bits/stl_vector.h:74:59: note: in instantiation of
> template class
> '__gnu_cxx::__alloc_traits<std::allocator<KDevelop::TopDUContext *>
> 
> >::rebind<KDevelop::TopDUContext *>' requested here
> 
>       typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template
>                                                           ^
> /usr/include//c++/4.8/bits/stl_vector.h:210:30: note: in instantiation of
> template class 'std::_Vector_base<KDevelop::TopDUContext *,
> std::allocator<KDevelop::TopDUContext *> >' requested here
>     class vector : protected _Vector_base<_Tp, _Alloc>
>                              ^
> /home/andreas/src/kdevplatform/language/duchain/duchain.h:177:23: note: in
> instantiation of template class 'std::vector<KDevelop::TopDUContext *,
> std::allocator<KDevelop::TopDUContext *> >' requested here
>       if(chainsByIndex.size() > index)
> 
> And also
> 
> In file included from
> /home/andreas/src/kdevplatform/language/backgroundparser/parsejob.cpp:44:
> /home/andreas/src/kdevplatform/language/duchain/duchain.h:179:23: error:
> cannot initialize a variable of type 'KDevelop::TopDUContext *' with an
> lvalue of type 'value_type' (aka 'int')
>         TopDUContext* top = chainsByIndex[index];
>                       ^     ~~~~~~~~~~~~~~~~~~~~

Somehow I guess you still have the delayed-template-parsing option active 
which breaks clang in many ways... Esp. since the above references std::vector 
which is also where I encountered issues. Note that before we didn't enable 
C++11 everywhere, which is why I didn't get these errors but only build errors 
in the one test where we enabled it.

> So I'm just wondering wether this is supposed to work and these really are
> genuine problems in the codebase (which gcc accepts for whatever reason) or
> there's still some general issue with using clang for KDE projects (at
> least for kdevplatform)?

It should certainly work. And any issues found by clang I try to fix. If you 
spot more, please don't hesitate to report them and/or fix them directly.

> Andreas
> 
> PS: Could this be triggered/caused by using ccache with clang? I believe I
> read such comments somewhere, but since other (non-KDE) projects work fine
> since quite some time now I thought that might have been FUD.

With clang 3.4 it might become more troublesome as apparently they will error 
out on unknown options and ccache adds some GCC-specific arguments afaik. 
Anyhow, nothing one couldn't fix or workaround one way or the other. It works 
just fine for me with ccache & clang.

Bye

-- 
Milian Wolff
mail at milianw.de
http://milianw.de


More information about the KDevelop-devel mailing list