Skip to content

Commit 57e446d

Browse files
author
Asiri Rathnayake
committedMay 31, 2016
[libcxxabi] Introduce a -fno-exceptions libc++abi libary variant
Currently there is only support for a -fno-exceptions libc++ build. This is problematic for functions such as std::terminate() which are defined in libc++abi and using any of those functions throws away most of the benefits of using -fno-exceptions (code-size). This patch introduces a -fno-exceptions libc++abi build to address this issue. This new variant of libc++abi cannot be linked against any with-exceptions code as some symbols necessary for handling exceptions are missing in this library. Differential revision: http://reviews.llvm.org/D20677 Reviewers: EricWF, mclow.lists, bcraig llvm-svn: 271267
1 parent 8f961aa commit 57e446d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+450
-17
lines changed
 

Diff for: ‎libcxxabi/CMakeLists.txt

+13-5
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ endif()
108108
#===============================================================================
109109

110110
# Define options.
111+
option(LIBCXXABI_ENABLE_EXCEPTIONS "Use exceptions." ON)
111112
option(LIBCXXABI_ENABLE_ASSERTIONS "Enable assertions independent of build mode." ON)
112113
option(LIBCXXABI_ENABLE_PEDANTIC "Compile with pedantic enabled." ON)
113114
option(LIBCXXABI_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
@@ -242,13 +243,20 @@ if (LIBCXXABI_ENABLE_PEDANTIC)
242243
endif()
243244

244245
# Get feature flags.
245-
# Exceptions
246-
# Catches C++ exceptions only and tells the compiler to assume that extern C
247-
# functions never throw a C++ exception.
248246
append_if(LIBCXXABI_CXX_FLAGS LIBCXXABI_HAS_FSTRICT_ALIASING_FLAG -fstrict-aliasing)
249-
append_if(LIBCXXABI_CXX_FLAGS LIBCXXABI_HAS_EHSC_FLAG -EHsc)
250247

251-
append_if(LIBCXXABI_C_FLAGS LIBCXXABI_HAS_FUNWIND_TABLES -funwind-tables)
248+
# Exceptions
249+
if (LIBCXXABI_ENABLE_EXCEPTIONS)
250+
# Catches C++ exceptions only and tells the compiler to assume that extern C
251+
# functions never throw a C++ exception.
252+
append_if(LIBCXXABI_CXX_FLAGS LIBCXXABI_HAS_EHSC_FLAG -EHsc)
253+
append_if(LIBCXXABI_C_FLAGS LIBCXXABI_HAS_FUNWIND_TABLES -funwind-tables)
254+
else()
255+
add_definitions(-D_LIBCXXABI_NO_EXCEPTIONS)
256+
append_if(LIBCXXABI_CXX_FLAGS LIBCXXABI_HAS_NO_EXCEPTIONS_FLAG -fno-exceptions)
257+
append_if(LIBCXXABI_CXX_FLAGS LIBCXXABI_HAS_NO_EHS_FLAG -EHs-)
258+
append_if(LIBCXXABI_CXX_FLAGS LIBCXXABI_HAS_NO_EHA_FLAG -EHa-)
259+
endif()
252260

253261
append_if(LIBCXXABI_COMPILE_FLAGS LIBCXXABI_HAS_FVISIBILITY_HIDDEN_FLAG -fvisibility=hidden)
254262

Diff for: ‎libcxxabi/src/CMakeLists.txt

+7-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ set(LIBCXXABI_SOURCES
44
cxa_aux_runtime.cpp
55
cxa_default_handlers.cpp
66
cxa_demangle.cpp
7-
cxa_exception.cpp
87
cxa_exception_storage.cpp
98
cxa_guard.cpp
109
cxa_handlers.cpp
1110
cxa_new_delete.cpp
12-
cxa_personality.cpp
1311
cxa_unexpected.cpp
1412
cxa_vector.cpp
1513
cxa_virtual.cpp
@@ -19,6 +17,13 @@ set(LIBCXXABI_SOURCES
1917
typeinfo.cpp
2018
)
2119

20+
if (LIBCXXABI_ENABLE_EXCEPTIONS)
21+
list(APPEND LIBCXXABI_SOURCES cxa_exception.cpp)
22+
list(APPEND LIBCXXABI_SOURCES cxa_personality.cpp)
23+
else()
24+
list(APPEND LIBCXXABI_SOURCES cxa_noexception.cpp)
25+
endif()
26+
2227
if (UNIX AND NOT (APPLE OR CYGWIN))
2328
list(APPEND LIBCXXABI_SOURCES cxa_thread_atexit.cpp)
2429
endif()

0 commit comments

Comments
 (0)