[cfe-dev] libc++ fails to build with exception disabled

Howard Hinnant hhinnant at apple.com
Mon Jun 11 14:57:48 PDT 2012


On Jun 11, 2012, at 8:24 AM, Konstantin Tokarev wrote:

> Hi all,
> 
> I've tried to build libc++ on Linux using clang with LIBCXX_ENABLE_EXCEPTIONS=OFF in CMake-based build system, but got compilation error:
> 
> cd /home/kostya/src/git/libcxx/build-noexcept/lib && /usr/local/bin/clang++   -Dcxx_EXPORTS -D_LIBCPP_NO_EXCEPTIONS -DNDEBUG -fPIC -I/home/kostya/src/git/libcxx/include    -nostdinc++ -std=c++0x -Wall -W -Wno-unused-parameter -Wwrite-strings -Wno-long-long -fno-exceptions -fPIC -o CMakeFiles/cxx.dir/__/src/debug.cpp.o -c /home/kostya/src/git/libcxx/src/debug.cpp
> /home/kostya/src/git/libcxx/src/debug.cpp:149:13: error: cannot use 'throw' with exceptions disabled
>            throw bad_alloc();
>            ^
> /home/kostya/src/git/libcxx/src/debug.cpp:170:9: error: cannot use 'throw' with exceptions disabled
>        throw bad_alloc();
>        ^
> /home/kostya/src/git/libcxx/src/debug.cpp:405:13: error: cannot use 'throw' with exceptions disabled
>            throw bad_alloc();
>            ^
> /home/kostya/src/git/libcxx/src/debug.cpp:427:13: error: cannot use 'throw' with exceptions disabled
>            throw bad_alloc();
>            ^
> /home/kostya/src/git/libcxx/src/debug.cpp:448:9: error: cannot use 'throw' with exceptions disabled
>        throw bad_alloc();
>        ^
> 5 errors generated.
> 
> 
> Is it a bug or LIBCXX_ENABLE_EXCEPTIONS option is not supported and should be removed?

It is a bug that LIBCXX_ENABLE_EXCEPTIONS doesn't work with debug.cpp.  It is also a bug (or actually incomplete feature) that debug.cpp is not currently supported at all.  I expect you could simply remove it from your compile and things would just be ok.

Howard




More information about the cfe-dev mailing list