From f4ef2bc965b5d52dc716dd1d006d53659cd5f1ac Mon Sep 17 00:00:00 2001 From: wangmingrong1 Date: Mon, 14 Oct 2024 21:43:11 +0800 Subject: [PATCH] llvm clang: llvm comes with unwind library, add unwind compilation 1. In the llvm clang15 version, the gcov implementation calls the unwind symbol __aeabi_unwind_cpp_pr0 2. Add default link, similar to COMPILER_RT_LIB 3. libUnwind needs to call the __assert_func API Signed-off-by: wangmingrong1 --- arch/arm/src/common/Toolchain.defs | 6 ++++++ include/assert.h | 7 +++++++ libs/libc/assert/lib_assert.c | 6 ++++++ 3 files changed, 19 insertions(+) diff --git a/arch/arm/src/common/Toolchain.defs b/arch/arm/src/common/Toolchain.defs index 7c3e01082c434..524d677d6bd12 100644 --- a/arch/arm/src/common/Toolchain.defs +++ b/arch/arm/src/common/Toolchain.defs @@ -465,6 +465,12 @@ endif EXTRA_LIBS += $(COMPILER_RT_LIB) +ifeq ($(CONFIG_ARCH_TOOLCHAIN_CLANG),y) + COMPILER_UNWIND_LIB := $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name libunwind.a)) +endif + +EXTRA_LIBS += $(COMPILER_UNWIND_LIB) + ifeq ($(CONFIG_LIBM_TOOLCHAIN),y) ifeq ($(CONFIG_ARM_TOOLCHAIN_GHS),y) ifeq ($(CONFIG_ARCH_FPU),y) diff --git a/include/assert.h b/include/assert.h index cac7cb3a241f5..ec4bd57894605 100644 --- a/include/assert.h +++ b/include/assert.h @@ -197,6 +197,13 @@ void _assert(FAR const char *filename, int linenum, void __assert(FAR const char *filename, int linenum, FAR const char *msg) noreturn_function; +/**************************************************************************** + * Name: __assert_func + ****************************************************************************/ + +void __assert_func(const char *file, int linenum, + const char *func, const char *msg); + #undef EXTERN #ifdef __cplusplus } diff --git a/libs/libc/assert/lib_assert.c b/libs/libc/assert/lib_assert.c index 4a71163d55ab6..4af8c6bf07d07 100644 --- a/libs/libc/assert/lib_assert.c +++ b/libs/libc/assert/lib_assert.c @@ -38,3 +38,9 @@ void __assert(FAR const char *filename, int linenum, FAR const char *msg) _assert(filename, linenum, msg, NULL); abort(); } + +void __assert_func(const char *file, int linenum, + const char *func, const char *msg) +{ + __assert(file, linenum, msg); +}