From f16bb34ff7f4d6b9d1a31b20c1f705820d2171e5 Mon Sep 17 00:00:00 2001 From: Alexey Gerenkov Date: Wed, 19 Nov 2025 17:17:50 +0300 Subject: [PATCH] fix(build): fix Clang 21 build warnings/errors --- CMakeLists.txt | 3 +++ components/bt/common/tinycrypt/src/hmac.c | 3 ++- components/esp_hal_gpio/esp32s31/include/hal/gpio_ll.h | 1 + components/esp_hw_support/CMakeLists.txt | 6 ------ .../esp_hw_support/lowpower/port/esp32h4/sleep_cpu.c | 2 +- .../lowpower/port/esp32h4/sleep_cpu_dynamic.c | 2 +- .../lowpower/port/esp32h4/sleep_cpu_retention.h | 2 +- .../lowpower/port/esp32h4/sleep_cpu_static.c | 2 +- .../lowpower/port/esp32p4/p4_rev3_mspi_workaround.S | 3 ++- .../esp_hw_support/lowpower/port/esp32p4/sleep_cpu.c | 2 +- .../lowpower/port/esp32p4/sleep_cpu_dynamic.c | 2 +- .../lowpower/port/esp32p4/sleep_cpu_retention.h | 2 +- .../lowpower/port/esp32p4/sleep_cpu_static.c | 2 +- components/esp_system/ld/ld.flash.sections | 2 ++ components/esp_wifi/CMakeLists.txt | 8 +++----- components/mbedtls/CMakeLists.txt | 5 +++-- tools/ci/ignore_build_warnings.txt | 1 + tools/idf_py_actions/hints.yml | 2 +- 18 files changed, 26 insertions(+), 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4669a8f3333..c87bc17b38c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -155,6 +155,9 @@ if(CMAKE_C_COMPILER_ID MATCHES "Clang") # warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 list(APPEND compile_options "-Wno-single-bit-bitfield-constant-conversion") endif() + # warning: initializer overrides prior initialization of this subobject + # in esp32c61 pmu_param.c when static unions are initialized (e.g. in pmu_hp_system_analog_param_default) + list(APPEND compile_options "-Wno-initializer-overrides") endif() # More warnings may exist in unit tests and example projects. diff --git a/components/bt/common/tinycrypt/src/hmac.c b/components/bt/common/tinycrypt/src/hmac.c index 77232434755..1c5ea74b50a 100644 --- a/components/bt/common/tinycrypt/src/hmac.c +++ b/components/bt/common/tinycrypt/src/hmac.c @@ -64,7 +64,7 @@ int tc_hmac_set_key(TCHmacState_t ctx, const uint8_t *key, return TC_CRYPTO_FAIL; } - const uint8_t dummy_key[key_size]; + uint8_t dummy_key[key_size]; struct tc_hmac_state_struct dummy_state; if (key_size <= TC_SHA256_BLOCK_SIZE) { @@ -76,6 +76,7 @@ int tc_hmac_set_key(TCHmacState_t ctx, const uint8_t *key, * consumed in this process. */ (void)tc_sha256_init(&dummy_state.hash_state); + _set(dummy_key, 0, sizeof(dummy_key)); (void)tc_sha256_update(&dummy_state.hash_state, dummy_key, key_size); diff --git a/components/esp_hal_gpio/esp32s31/include/hal/gpio_ll.h b/components/esp_hal_gpio/esp32s31/include/hal/gpio_ll.h index 0237313723f..b9c8f712f61 100644 --- a/components/esp_hal_gpio/esp32s31/include/hal/gpio_ll.h +++ b/components/esp_hal_gpio/esp32s31/include/hal/gpio_ll.h @@ -542,6 +542,7 @@ static inline bool gpio_ll_is_digital_io_hold(gpio_dev_t *hw, uint32_t gpio_num) return !!(LP_SYS.hp_gpio_o_hold_ctrl1.hp_gpio_0_hold_ctrl1 & (bit_mask >> (32 + SOC_RTCIO_PIN_COUNT))); } } + return false; } /** diff --git a/components/esp_hw_support/CMakeLists.txt b/components/esp_hw_support/CMakeLists.txt index 7c059e65c45..f63b382a249 100644 --- a/components/esp_hw_support/CMakeLists.txt +++ b/components/esp_hw_support/CMakeLists.txt @@ -186,12 +186,6 @@ if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/include/soc/${target}") ) endif() -if(NOT CONFIG_ESP32P4_SELECTS_REV_LESS_V3 AND CONFIG_IDF_TARGET_ESP32P4) - if(CMAKE_C_COMPILER_ID MATCHES "Clang") # TODO: LLVM-478 IDF-14338 - message(FATAL_ERROR "ESP32-P4 rev. 3.0 or higher is not supported in Clang-based toolchain") - endif() -endif() - if(${target} STREQUAL "esp32p4") # for mipi_csi_share_hw_ctrl.c list(APPEND priv_requires esp_hal_cam) diff --git a/components/esp_hw_support/lowpower/port/esp32h4/sleep_cpu.c b/components/esp_hw_support/lowpower/port/esp32h4/sleep_cpu.c index 6b3749a890c..e5c69961bd8 100644 --- a/components/esp_hw_support/lowpower/port/esp32h4/sleep_cpu.c +++ b/components/esp_hw_support/lowpower/port/esp32h4/sleep_cpu.c @@ -40,7 +40,7 @@ #endif #if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE -static DRAM_ATTR smp_retention_state_t s_smp_retention_state[portNUM_PROCESSORS]; +static DRAM_ATTR _Atomic(smp_retention_state_t) s_smp_retention_state[portNUM_PROCESSORS]; #endif static bool s_fpu_saved[portNUM_PROCESSORS]; diff --git a/components/esp_hw_support/lowpower/port/esp32h4/sleep_cpu_dynamic.c b/components/esp_hw_support/lowpower/port/esp32h4/sleep_cpu_dynamic.c index b5de6b40508..441d6f54762 100644 --- a/components/esp_hw_support/lowpower/port/esp32h4/sleep_cpu_dynamic.c +++ b/components/esp_hw_support/lowpower/port/esp32h4/sleep_cpu_dynamic.c @@ -74,7 +74,7 @@ static inline void * cpu_domain_clic_sleep_frame_alloc_and_init(uint8_t core_id) } #if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE -esp_err_t esp_sleep_cpu_retention_init_impl(sleep_cpu_retention_t *sleep_cpu_retention_ptr, smp_retention_state_t *s_smp_retention_state) +esp_err_t esp_sleep_cpu_retention_init_impl(sleep_cpu_retention_t *sleep_cpu_retention_ptr, _Atomic(smp_retention_state_t) *s_smp_retention_state) { for (uint8_t core_id = 0; core_id < portNUM_PROCESSORS; ++core_id) { if (sleep_cpu_retention_ptr->retent.critical_frame[core_id] == NULL) { diff --git a/components/esp_hw_support/lowpower/port/esp32h4/sleep_cpu_retention.h b/components/esp_hw_support/lowpower/port/esp32h4/sleep_cpu_retention.h index 7b4e6bfaee3..e7e14f8333a 100644 --- a/components/esp_hw_support/lowpower/port/esp32h4/sleep_cpu_retention.h +++ b/components/esp_hw_support/lowpower/port/esp32h4/sleep_cpu_retention.h @@ -49,7 +49,7 @@ typedef struct { } sleep_cpu_retention_t; #if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE - esp_err_t esp_sleep_cpu_retention_init_impl(sleep_cpu_retention_t *sleep_cpu_retention_ptr, smp_retention_state_t *s_smp_retention_state); + esp_err_t esp_sleep_cpu_retention_init_impl(sleep_cpu_retention_t *sleep_cpu_retention_ptr, _Atomic(smp_retention_state_t) *s_smp_retention_state); #else esp_err_t esp_sleep_cpu_retention_init_impl(sleep_cpu_retention_t *sleep_cpu_retention_ptr); #endif diff --git a/components/esp_hw_support/lowpower/port/esp32h4/sleep_cpu_static.c b/components/esp_hw_support/lowpower/port/esp32h4/sleep_cpu_static.c index a07461ce7f8..cf6ef359fd6 100644 --- a/components/esp_hw_support/lowpower/port/esp32h4/sleep_cpu_static.c +++ b/components/esp_hw_support/lowpower/port/esp32h4/sleep_cpu_static.c @@ -143,7 +143,7 @@ static inline void * cpu_domain_clic_sleep_frame_alloc_and_init(uint8_t core_id) } #if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE -esp_err_t esp_sleep_cpu_retention_init_impl(sleep_cpu_retention_t *sleep_cpu_retention_ptr, smp_retention_state_t *s_smp_retention_state) +esp_err_t esp_sleep_cpu_retention_init_impl(sleep_cpu_retention_t *sleep_cpu_retention_ptr, _Atomic(smp_retention_state_t) *s_smp_retention_state) { static DRAM_ATTR uint8_t rv_core_critical_regs[RV_SLEEP_CTX_FRMSZ * portNUM_PROCESSORS] __attribute__((aligned(4))); static DRAM_ATTR uint8_t rv_core_non_critical_regs[sizeof(RvCoreNonCriticalSleepFrame)* portNUM_PROCESSORS] __attribute__((aligned(4))); diff --git a/components/esp_hw_support/lowpower/port/esp32p4/p4_rev3_mspi_workaround.S b/components/esp_hw_support/lowpower/port/esp32p4/p4_rev3_mspi_workaround.S index 64a105929d2..14dd5143978 100644 --- a/components/esp_hw_support/lowpower/port/esp32p4/p4_rev3_mspi_workaround.S +++ b/components/esp_hw_support/lowpower/port/esp32p4/p4_rev3_mspi_workaround.S @@ -38,7 +38,8 @@ .macro REG_CLR_BIT addr, value li a0, \addr /* Since all our parameters will be constants, we can pre-calculate it at assemble time */ - li a1, ~\value + li a1, \value + not a1, a1 lw a2, (a0) and a2, a2, a1 sw a2, (a0) diff --git a/components/esp_hw_support/lowpower/port/esp32p4/sleep_cpu.c b/components/esp_hw_support/lowpower/port/esp32p4/sleep_cpu.c index affb48d3472..4c14c4e4a32 100644 --- a/components/esp_hw_support/lowpower/port/esp32p4/sleep_cpu.c +++ b/components/esp_hw_support/lowpower/port/esp32p4/sleep_cpu.c @@ -41,7 +41,7 @@ #if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE -static SPM_DRAM_ATTR smp_retention_state_t s_smp_retention_state[portNUM_PROCESSORS]; +static SPM_DRAM_ATTR _Atomic(smp_retention_state_t) s_smp_retention_state[portNUM_PROCESSORS]; #endif static bool s_fpu_saved[portNUM_PROCESSORS]; diff --git a/components/esp_hw_support/lowpower/port/esp32p4/sleep_cpu_dynamic.c b/components/esp_hw_support/lowpower/port/esp32p4/sleep_cpu_dynamic.c index beff8bce7b6..9e884c544b1 100644 --- a/components/esp_hw_support/lowpower/port/esp32p4/sleep_cpu_dynamic.c +++ b/components/esp_hw_support/lowpower/port/esp32p4/sleep_cpu_dynamic.c @@ -51,7 +51,7 @@ static inline void * cpu_domain_clic_sleep_frame_alloc_and_init(uint8_t core_id) } #if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE -esp_err_t esp_sleep_cpu_retention_init_impl(sleep_cpu_retention_t *sleep_cpu_retention_ptr, smp_retention_state_t *s_smp_retention_state) +esp_err_t esp_sleep_cpu_retention_init_impl(sleep_cpu_retention_t *sleep_cpu_retention_ptr, _Atomic(smp_retention_state_t) *s_smp_retention_state) { for (uint8_t core_id = 0; core_id < portNUM_PROCESSORS; ++core_id) { if (sleep_cpu_retention_ptr->retent.critical_frame[core_id] == NULL) { diff --git a/components/esp_hw_support/lowpower/port/esp32p4/sleep_cpu_retention.h b/components/esp_hw_support/lowpower/port/esp32p4/sleep_cpu_retention.h index 78d3ae2cf71..b8e069dbb5e 100644 --- a/components/esp_hw_support/lowpower/port/esp32p4/sleep_cpu_retention.h +++ b/components/esp_hw_support/lowpower/port/esp32p4/sleep_cpu_retention.h @@ -47,7 +47,7 @@ typedef struct { } sleep_cpu_retention_t; #if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE - esp_err_t esp_sleep_cpu_retention_init_impl(sleep_cpu_retention_t *sleep_cpu_retention_ptr, smp_retention_state_t *s_smp_retention_state); + esp_err_t esp_sleep_cpu_retention_init_impl(sleep_cpu_retention_t *sleep_cpu_retention_ptr, _Atomic(smp_retention_state_t) *s_smp_retention_state); #else esp_err_t esp_sleep_cpu_retention_init_impl(sleep_cpu_retention_t *sleep_cpu_retention_ptr); #endif diff --git a/components/esp_hw_support/lowpower/port/esp32p4/sleep_cpu_static.c b/components/esp_hw_support/lowpower/port/esp32p4/sleep_cpu_static.c index 491ff21294a..f555718ed69 100644 --- a/components/esp_hw_support/lowpower/port/esp32p4/sleep_cpu_static.c +++ b/components/esp_hw_support/lowpower/port/esp32p4/sleep_cpu_static.c @@ -83,7 +83,7 @@ static inline void * cpu_domain_clic_sleep_frame_alloc_and_init(uint8_t core_id) } #if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE -esp_err_t esp_sleep_cpu_retention_init_impl(sleep_cpu_retention_t *sleep_cpu_retention_ptr, smp_retention_state_t *s_smp_retention_state) +esp_err_t esp_sleep_cpu_retention_init_impl(sleep_cpu_retention_t *sleep_cpu_retention_ptr, _Atomic(smp_retention_state_t) *s_smp_retention_state) { static DRAM_ATTR uint8_t rv_core_critical_regs[RV_SLEEP_CTX_FRMSZ * portNUM_PROCESSORS] __attribute__((aligned(4))); static DRAM_ATTR uint8_t rv_core_non_critical_regs[sizeof(RvCoreNonCriticalSleepFrame)* portNUM_PROCESSORS] __attribute__((aligned(4))); diff --git a/components/esp_system/ld/ld.flash.sections b/components/esp_system/ld/ld.flash.sections index 8d06bde52ab..22cc9e2ae47 100644 --- a/components/esp_system/ld/ld.flash.sections +++ b/components/esp_system/ld/ld.flash.sections @@ -148,6 +148,7 @@ .eh_frame_hdr : { ALIGNED_SYMBOL(4, __eh_frame_hdr) + ALIGNED_SYMBOL(4, __eh_frame_hdr_start) KEEP (*(.eh_frame_hdr)) @@ -160,6 +161,7 @@ .eh_frame : { ALIGNED_SYMBOL(4, __eh_frame) + ALIGNED_SYMBOL(4, __eh_frame_start) KEEP (*(.eh_frame)) diff --git a/components/esp_wifi/CMakeLists.txt b/components/esp_wifi/CMakeLists.txt index ce0f841a38d..b8b6bcc484b 100644 --- a/components/esp_wifi/CMakeLists.txt +++ b/components/esp_wifi/CMakeLists.txt @@ -122,11 +122,9 @@ if(CONFIG_ESP_WIFI_ENABLED OR CONFIG_ESP_HOST_WIFI_ENABLED) endforeach() endif() # TODO IDF-13365: remove the following lines - if(CMAKE_C_COMPILER_ID MATCHES "GNU") - set_source_files_properties(regulatory/esp_wifi_regulatory.c - PROPERTIES COMPILE_FLAGS - -Wno-unterminated-string-initialization) - endif() + set_source_files_properties(regulatory/esp_wifi_regulatory.c + PROPERTIES COMPILE_FLAGS + -Wno-unterminated-string-initialization) endif() if(CONFIG_SPIRAM) diff --git a/components/mbedtls/CMakeLists.txt b/components/mbedtls/CMakeLists.txt index 6d5c314338e..fffeec93aab 100644 --- a/components/mbedtls/CMakeLists.txt +++ b/components/mbedtls/CMakeLists.txt @@ -259,10 +259,11 @@ if(${IDF_TARGET} STREQUAL "linux") set(mbedtls_target_sources ${mbedtls_target_sources} "${COMPONENT_DIR}/port/net_sockets.c") endif() -# While updating to MbedTLS release/v3.4.0, building mbedtls/library/psa_crypto.c -# clang produces an unreachable-code warning. if(CMAKE_C_COMPILER_ID MATCHES "Clang") target_compile_options(tfpsacrypto PRIVATE "-Wno-unreachable-code") + # while building mbedtls/library/x509_crt.c + # clang 21 produces an uninitialized-const-pointer warning + target_compile_options(mbedx509 PRIVATE "-Wno-uninitialized-const-pointer") endif() # net_sockets.c should only be compiled if BSD socket functions are available. diff --git a/tools/ci/ignore_build_warnings.txt b/tools/ci/ignore_build_warnings.txt index 0b77e1a5f28..7dea2e38e2e 100644 --- a/tools/ci/ignore_build_warnings.txt +++ b/tools/ci/ignore_build_warnings.txt @@ -46,3 +46,4 @@ warning: unknown kconfig symbol 'ETHERNET_MDC_GPIO' assigned to '23' in .*/examp warning: unknown kconfig symbol 'ETHERNET_MDIO_GPIO' assigned to '18' in .*/examples/protocols/esp_http_client/sdkconfig.ci.* warning: unknown kconfig symbol 'ETHERNET_PHY_RST_GPIO' assigned to '5' in .*/examples/protocols/esp_http_client/sdkconfig.ci.* warning: unknown kconfig symbol 'ETHERNET_PHY_ADDR' assigned to '1' in .*/examples/protocols/esp_http_client/sdkconfig.ci.* +warning: \S+ changed binding to STB_WEAK diff --git a/tools/idf_py_actions/hints.yml b/tools/idf_py_actions/hints.yml index 3cdcd17f101..94cc8b37b43 100644 --- a/tools/idf_py_actions/hints.yml +++ b/tools/idf_py_actions/hints.yml @@ -59,7 +59,7 @@ hint: "'esp_secure_boot_verify_rsa_signature_block()' has been made private and is no longer available." - - re: "error: implicit declaration of function '{}'" + re: "error: (implicit declaration of function|use of undeclared identifier) '{}'" hint: '{0}.h header file is not included by esp_system.h anymore. It shall then be manually included with #include "{0}.h"' variables: -