mirror of
https://github.com/espressif/esp-idf.git
synced 2026-08-18 06:35:35 +03:00
fix(mbedtls): compile esp_mem.c in IDF component lib instead of builtin target
esp_mem.c in the builtin target via target_sources(builtin PRIVATE ...) called from the parent CMakeLists. This cross-directory source injection causes CMake's Ninja generator on Windows to produce unstable TARGET_PDB/RSP_FILE paths across reconfigures, changing the ninja command hash and forcing a re-archive of libmbed-builtin.a on every cmake run — even when no source changed. This broke test_rebuild_source_files. Fix by adding esp_mem.c to the IDF mbedtls component library (mbedtls_srcs) instead. The final ELF link uses --start-group, so builtin's platform.o resolves esp_mbedtls_mem_calloc/free from the component library regardless of archive order. esp_mem.c is IDF-specific code (heap_caps_calloc, sdkconfig.h) and belongs in the port layer, not in any submodule target.
This commit is contained in:
@@ -27,10 +27,7 @@ idf_component_register(SRCS "${srcs}"
|
||||
|
||||
|
||||
if(NOT ${IDF_TARGET} STREQUAL "linux")
|
||||
# Increase link multiplicity to get some lwip symbols correctly resolved by the linker
|
||||
# due to cyclic dependencies present in IDF for lwip/esp_netif/mbedtls
|
||||
idf_component_get_property(lwip lwip COMPONENT_LIB)
|
||||
set_property(TARGET ${lwip} APPEND PROPERTY LINK_INTERFACE_MULTIPLICITY 5)
|
||||
else()
|
||||
# For linux target, define ESP_TLS_WITH_LWIP if LWIP is enabled in the build
|
||||
if(CONFIG_LWIP_ENABLE)
|
||||
|
||||
@@ -26,7 +26,7 @@ if(NOT ${IDF_TARGET} STREQUAL "linux")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(mbedtls_srcs "")
|
||||
set(mbedtls_srcs "port/esp_mem.c")
|
||||
set(mbedtls_include_dirs
|
||||
"port/include"
|
||||
"mbedtls/include"
|
||||
@@ -55,14 +55,8 @@ idf_component_register(SRCS "${mbedtls_srcs}"
|
||||
# Add MBEDTLS_MAJOR_VERSION definition to the component library
|
||||
target_compile_definitions(${COMPONENT_LIB} INTERFACE MBEDTLS_MAJOR_VERSION=4)
|
||||
|
||||
# Determine the type of mbedtls component library
|
||||
if(mbedtls_srcs STREQUAL "")
|
||||
# For no sources in component library we must use "INTERFACE"
|
||||
set(linkage_type INTERFACE)
|
||||
else()
|
||||
set(linkage_type PUBLIC)
|
||||
endif()
|
||||
|
||||
# Set the type of mbedtls component library
|
||||
set(linkage_type PUBLIC)
|
||||
|
||||
if(CONFIG_MBEDTLS_CERTIFICATE_BUNDLE)
|
||||
set(bundle_name "x509_crt_bundle")
|
||||
@@ -343,7 +337,6 @@ endif()
|
||||
if(NOT ${IDF_TARGET} STREQUAL "linux")
|
||||
target_sources(tfpsacrypto PRIVATE "${COMPONENT_DIR}/port/esp_hardware.c")
|
||||
endif()
|
||||
target_sources(tfpsacrypto PRIVATE "${COMPONENT_DIR}/port/esp_mem.c")
|
||||
|
||||
if(CONFIG_SOC_AES_SUPPORTED)
|
||||
target_include_directories(tfpsacrypto PRIVATE "${COMPONENT_DIR}/port/aes/include")
|
||||
|
||||
Reference in New Issue
Block a user