From be8033701cf1046e4bfb22a7e93310894ee14173 Mon Sep 17 00:00:00 2001 From: morris Date: Mon, 4 Mar 2024 11:04:03 +0800 Subject: [PATCH] fix(hal): use __builtin_unreachable in no-assert mode otherwise due to esp-idf using -Werror, we can get errors in code which uses HAL_ASSERT if for example the compiler believes that a variable is used uninitialised, or similar. Inspired by https://github.com/espressif/esp-idf/pull/13256 --- components/hal/platform_port/include/hal/assert.h | 2 +- .../test_apps/system/cxx_pthread_bluetooth/sdkconfig.defaults | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/components/hal/platform_port/include/hal/assert.h b/components/hal/platform_port/include/hal/assert.h index 19847d9936..48e5c3ba65 100644 --- a/components/hal/platform_port/include/hal/assert.h +++ b/components/hal/platform_port/include/hal/assert.h @@ -38,7 +38,7 @@ extern void abort(void); #elif CONFIG_HAL_DEFAULT_ASSERTION_LEVEL == 2 // full assertion #define HAL_ASSERT(__e) (__builtin_expect(!!(__e), 1) ? (void)0 : __assert_func(__FILE__, __LINE__, __ASSERT_FUNC, #__e)) #else // no assert -#define HAL_ASSERT(__e) ((void)(__e)) +#define HAL_ASSERT(__e) (__builtin_expect(!!(__e), 1) ? (void)0 : __builtin_unreachable()) #endif #ifdef __cplusplus diff --git a/tools/test_apps/system/cxx_pthread_bluetooth/sdkconfig.defaults b/tools/test_apps/system/cxx_pthread_bluetooth/sdkconfig.defaults index 6a7406f9e9..3a70f4c6aa 100644 --- a/tools/test_apps/system/cxx_pthread_bluetooth/sdkconfig.defaults +++ b/tools/test_apps/system/cxx_pthread_bluetooth/sdkconfig.defaults @@ -1,3 +1,6 @@ CONFIG_PARTITION_TABLE_OFFSET=0x9000 CONFIG_BT_ENABLED=y CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER=n + +# want to test clang build with HAL assertion disabled +CONFIG_HAL_ASSERTION_DISABLE=y