From b721f2c84e7e3e6947d018c938c7f5cd21525342 Mon Sep 17 00:00:00 2001 From: yinshengkai Date: Tue, 28 May 2024 20:18:18 +0800 Subject: [PATCH] libcxx: Disable dynamic type checking when enabling libcxxabi It results in a recursive call, cxxabiv1::__dynamic_case -> is_equal -> __ubsan::checkDynamic -> cxxabiv1::__dynamic_case Signed-off-by: yinshengkai --- libs/libxx/libcxxabi.cmake | 4 ++++ libs/libxx/libcxxabi.defs | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/libs/libxx/libcxxabi.cmake b/libs/libxx/libcxxabi.cmake index 976fca9d7c..9f552e664d 100644 --- a/libs/libxx/libcxxabi.cmake +++ b/libs/libxx/libcxxabi.cmake @@ -96,6 +96,10 @@ endforeach() # RTTI is required for building the libcxxabi library target_compile_options(libcxxabi PRIVATE -frtti) +if(CONFIG_SIM_UBSAN OR CONFIG_MM_UBSAN) + target_compile_options(libcxxabi PRIVATE -fno-sanitize=vptr) +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 10c67d0655..a25c24bb23 100644 --- a/libs/libxx/libcxxabi.defs +++ b/libs/libxx/libcxxabi.defs @@ -47,6 +47,14 @@ endif ifeq ($(CONFIG_LIBCXXABI), y) CXXFLAGS += ${DEFINE_PREFIX}LIBCXX_BUILDING_LIBCXXABI CXXFLAGS += -I $(TOPDIR)/libs/libxx/libcxxabi/include + +# Disable dynamic type checking when enabling libcxxabi +# It results in a recursive call: +# cxxabiv1::__dynamic_case -> is_equal -> __ubsan::checkDynamic -> cxxabiv1::__dynamic_case + +ifneq ($(CONFIG_SIM_UBSAN)${CONFIG_MM_UBSAN},) +CXXFLAGS += -fno-sanitize=vptr +endif endif # C++ABI files