diff --git a/libs/libxx/libcxxabi.cmake b/libs/libxx/libcxxabi.cmake index 9f552e664d..f55d842a17 100644 --- a/libs/libxx/libcxxabi.cmake +++ b/libs/libxx/libcxxabi.cmake @@ -75,12 +75,9 @@ list(APPEND SRCS stdlib_exception.cpp stdlib_new_delete.cpp # Internal files list(APPEND SRCS abort_message.cpp fallback_malloc.cpp private_typeinfo.cpp) -if(CONFIG_CXX_EXCEPTION) - add_compile_definitions(LIBCXXABI_ENABLE_EXCEPTIONS) - list(APPEND SRCS cxa_exception.cpp cxa_personality.cpp) -else() - list(APPEND SRCS cxa_noexception.cpp) -endif() +# Always compile libcxxabi with exception +list(APPEND SRCS cxa_exception.cpp cxa_personality.cpp) +target_compile_options(libcxxabi PRIVATE -fexceptions) if(CONFIG_LIBCXXABI) add_compile_definitions(LIBCXX_BUILDING_LIBCXXABI) @@ -100,6 +97,16 @@ if(CONFIG_SIM_UBSAN OR CONFIG_MM_UBSAN) target_compile_options(libcxxabi PRIVATE -fno-sanitize=vptr) endif() +# Fix compilation error on ARM32:libcxxabi/src/cxa_personality.cpp:594:22: +# error: '_URC_FATAL_PHASE1_ERROR' was not declared in this scope 594 | +# results.reason = _URC_FATAL_PHASE1_ERROR; +if(CONFIG_ARCH_ARM) + target_compile_definitions(libcxxabi + PRIVATE _URC_FATAL_PHASE2_ERROR=_URC_FAILURE) + target_compile_definitions(libcxxabi + PRIVATE _URC_FATAL_PHASE1_ERROR=_URC_FAILURE) +endif() + target_sources(libcxxabi PRIVATE ${TARGET_SRCS}) target_compile_options(libcxxabi PRIVATE -frtti) target_include_directories( diff --git a/libs/libxx/libcxxabi.defs b/libs/libxx/libcxxabi.defs index a25c24bb23..40f95afc72 100644 --- a/libs/libxx/libcxxabi.defs +++ b/libs/libxx/libcxxabi.defs @@ -65,11 +65,15 @@ CPPSRCS += stdlib_exception.cpp stdlib_new_delete.cpp stdlib_stdexcept.cpp stdli # Internal files CPPSRCS += abort_message.cpp fallback_malloc.cpp private_typeinfo.cpp -ifeq ($(CONFIG_CXX_EXCEPTION), y) -CXXFLAGS += ${DEFINE_PREFIX}LIBCXXABI_ENABLE_EXCEPTIONS +# Always compile libcxxabi with exception CPPSRCS += cxa_exception.cpp cxa_personality.cpp -else -CPPSRCS += cxa_noexception.cpp +CXXFLAGS += -fexceptions + +# Fix compilation error on ARM32: +# libcxxabi/src/cxa_personality.cpp:594:22: error: '_URC_FATAL_PHASE1_ERROR' was not declared in this scope +# 594 | results.reason = _URC_FATAL_PHASE1_ERROR; +ifeq ($(CONFIG_ARCH_ARM),y) +CXXFLAGS += -D_URC_FATAL_PHASE2_ERROR=_URC_FAILURE -D_URC_FATAL_PHASE1_ERROR=_URC_FAILURE endif # RTTI is required for building the libcxxabi library