Merge branch 'feature/update-esp-clang-to-esp-21.1.3_20260304' into 'master'

feat(tools): update esp-clang version to esp-21.1.3_20260408

Closes IDF-14965, LLVM-501, and LLVM-531

See merge request espressif/esp-idf!46361
This commit is contained in:
Alexey Gerenkov
2026-05-13 22:54:10 +08:00
42 changed files with 263 additions and 523 deletions
@@ -275,7 +275,8 @@ if(LOG_COMPRESSED_MODULE)
"${jump_table_opts}")
endif()
if(CMAKE_C_COMPILER_ID MATCHES "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 15.0)
if((CMAKE_C_COMPILER_ID MATCHES "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 15.0) OR
CMAKE_C_COMPILER_ID MATCHES "Clang")
set(files_with_compile_flags "host/bluedroid/device/controller.c")
add_flags_if_in_list("${src}"
"${files_with_compile_flags}"
+2 -1
View File
@@ -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);
+2 -1
View File
@@ -22,7 +22,8 @@ function(set_bluedroid_host_compile_flags)
PROPERTIES COMPILE_FLAGS "${jump_table_opts}")
endif()
if(CMAKE_C_COMPILER_ID MATCHES "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 15.0)
if((CMAKE_C_COMPILER_ID MATCHES "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 15.0) OR
CMAKE_C_COMPILER_ID MATCHES "Clang")
set_source_files_properties("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/device/controller.c"
PROPERTIES COMPILE_FLAGS "-Wno-unterminated-string-initialization")
endif()
+4 -2
View File
@@ -6,7 +6,8 @@ if(${idf_target} STREQUAL "linux")
return() # This component is not supported by the POSIX/Linux simulator
endif()
if(CONFIG_ESP_COEX_ENABLED)
# There are no subdir with implementation for esp32h4
if(CONFIG_ESP_COEX_ENABLED AND NOT CONFIG_IDF_TARGET_ESP32H4)
if(CONFIG_ESP_COEX_SW_COEXIST_ENABLE OR CONFIG_ESP_COEX_EXTERNAL_COEXIST_ENABLE)
if(CONFIG_APP_NO_BLOBS)
set(link_binary_libs 0)
@@ -32,7 +33,8 @@ idf_component_register(SRCS "${srcs}"
PRIV_REQUIRES esp_timer esp_driver_gpio
LDFRAGMENTS "${ldfragments}")
if(CONFIG_ESP_COEX_ENABLED)
# There are no subdir with implementation for esp32h4
if(CONFIG_ESP_COEX_ENABLED AND NOT CONFIG_IDF_TARGET_ESP32H4)
if(CONFIG_ESP_COEX_SW_COEXIST_ENABLE OR CONFIG_ESP_COEX_EXTERNAL_COEXIST_ENABLE)
idf_build_get_property(build_dir BUILD_DIR)
@@ -633,6 +633,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;
}
/**
-6
View File
@@ -187,12 +187,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)
@@ -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];
@@ -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) {
@@ -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
@@ -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)));
@@ -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)
@@ -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];
@@ -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) {
@@ -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
@@ -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)));
+3
View File
@@ -158,6 +158,9 @@ if(CONFIG_LIBC_NEWLIB_NANO_FORMAT)
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
set(libc_dir_cmd ${CMAKE_C_COMPILER})
string(REPLACE " " ";" cflags_list ${CMAKE_C_FLAGS})
# execute_process() quotes every argument, so we need to unquote response file path
# otherwise it will be treated in wrong way and clang will ignore it
string(REGEX REPLACE "@\"([^\"]*)\"" "@\\1" cflags_list ${cflags_list})
list(APPEND libc_dir_cmd ${cflags_list} "-print-file-name=libc.a")
execute_process(
COMMAND ${libc_dir_cmd}
@@ -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))
+3 -5
View File
@@ -123,11 +123,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)
+3 -2
View File
@@ -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.
+19
View File
@@ -84,4 +84,23 @@ if(CONFIG_IDF_TOOLCHAIN_GCC)
else()
message(FATAL_ERROR "Unknown Espressif architecture: ${CONFIG_IDF_TARGET_ARCH}")
endif()
elseif(CONFIG_IDF_TOOLCHAIN_CLANG)
idf_toolchain_add_flags(LINK_OPTIONS "-nostartfiles --ld-path=${CMAKE_LINKER} -z noexecstack")
# Clean compile options that were added by previous configurations and may be outdated
idf_toolchain_remove_flags(COMPILE_OPTIONS "-mcpu=")
if(CONFIG_IDF_TARGET_ARCH_XTENSA)
idf_toolchain_add_flags(COMPILE_OPTIONS "--target=xtensa-esp-elf")
idf_toolchain_add_flags(ASM_COMPILE_OPTIONS "-Xassembler --longcalls")
idf_toolchain_add_flags(COMPILE_OPTIONS "-mcpu=${CONFIG_IDF_TARGET}")
elseif(CONFIG_IDF_TARGET_ARCH_RISCV)
idf_toolchain_add_flags(COMPILE_OPTIONS "--target=riscv32-esp-elf")
if(CONFIG_IDF_TARGET_ESP32P4 AND CONFIG_ESP32P4_SELECTS_REV_LESS_V3)
idf_toolchain_add_flags(COMPILE_OPTIONS "-mcpu=esp32p4eco4")
else()
idf_toolchain_add_flags(COMPILE_OPTIONS "-mcpu=${CONFIG_IDF_TARGET}")
endif()
idf_toolchain_rerun_abi_detection()
else()
message(FATAL_ERROR "Unknown Espressif architecture: ${CONFIG_IDF_TARGET_ARCH}")
endif()
endif()