FindKDE4Internal.cmake & clang & c++11 & -fdelayed-template-parsing

Alexander Neundorf neundorf at kde.org
Fri Nov 15 20:46:41 GMT 2013


On Friday 15 November 2013, Milian Wolff wrote:
> On Tuesday 22 October 2013 10:17:02 Raphael Kubo da Costa wrote:
> > Milian Wolff <mail at milianw.de> writes:
> > > Hey Raphael!
> > > 
> > > Thank you for working on clang support in FindKDE4Internal.cmake.
> > > 
> > > Since recently though I have build issues with clang due to the
> > > -fdelayed- template-parsing flag passed in FindKDE4Internal.cmake. A
> > > simple example such as this:
> > > 
> > > #include <vector>
> > > int main() { std::vector<int> v; return 0; }
> > > 
> > > produces with: clang++ -std=c++11 -fdelayed-template-parsing test.cpp
> > 
> > [...]
> > 
> > > Apparently, delayed template parsing is not yet mature. So - can we
> > > disable it in FindKDE4Internal.cmake again? Or do you know a workaround
> > > for that?
> > 
> > Hi,
> > 
> > Sorry for not answering earlier.
> > 
> > As explained in the comment in FindKDE4Internal.cmake, simply not
> > passing -fdelayed-template-parsing causes a lot of problems due to us
> > building most repositories with -fno-exceptions and including template
> > code that does not get instantiated and throws exceptions: for example,
> > kdepimlibs' akonadi/itempayloadinternals_p.h throws some exceptions in
> > code that should not be reached, and while that code is built with
> > exceptions enabled, kdepim may end up indirectly including that header
> > without ever knowing it needs to enable exceptions in the first place
> > (which is what happened when I was testing clang support). The same
> > thing happened with kdelibs and OpenEXR too.
> 
> Well, take this code snippet:
> 
> #include <vector>
> int main() { std::vector<int> v; return 0; }
> 
> And try to compile it with:
> 
> clang++ -fdelayed-template-parsing -std=c++11  test.cpp
> 
> You'll get quite funky errors: http://paste.kde.org/~mwolff/pfe4181c0
> 
> > Contrary to GCC, MSVC and ICC, clang complains and fails to build if
> > that happens (and is probably doing the right thing).
> > 
> > One option is to fix all places where this might arise (it's manual and
> > error-prone work), or just remove -fno-exceptions from the default
> > compiler flags for clang in FindKDE4Internal.cmake. I tend ot favor the
> > latter, but it will increase the size of the generated binaries (thiago
> > estimated them to increase by ~5-7%).
> 
> There is no alternative, see above. Rather have bigger binaries than not
> being able to compile at all.

Yes, definitely.

Alex




More information about the kde-core-devel mailing list