From b0fc1922c578121c195c78e1fe88f15ac22e36ec Mon Sep 17 00:00:00 2001 From: Ashish Sharma Date: Fri, 5 Jun 2026 15:01:56 +0800 Subject: [PATCH] fix(mbedtls): fixes build failure with clang21 Closes https://github.com/espressif/esp-idf/issues/18456 --- components/mbedtls/CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/mbedtls/CMakeLists.txt b/components/mbedtls/CMakeLists.txt index 7fb2eecbb49..9168ba84a84 100644 --- a/components/mbedtls/CMakeLists.txt +++ b/components/mbedtls/CMakeLists.txt @@ -155,6 +155,14 @@ endif() # clang produces an unreachable-code warning. if(CMAKE_C_COMPILER_ID MATCHES "Clang") target_compile_options(mbedcrypto PRIVATE "-Wno-unreachable-code") + # While building mbedtls/library/x509_crt.c, clang 21 produces an + # uninitialized-const-pointer warning. The warning flag only exists in + # newer clang versions, so probe for it before use. + include(CheckCCompilerFlag) + check_c_compiler_flag("-Wuninitialized-const-pointer" C_COMPILER_HAS_UNINIT_CONST_PTR_WARNING) + if(C_COMPILER_HAS_UNINIT_CONST_PTR_WARNING) + target_compile_options(mbedx509 PRIVATE "-Wno-uninitialized-const-pointer") + endif() endif() # net_sockets.c should only be compiled if BSD socket functions are available.