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:
Guillaume Souchere
2026-05-04 09:02:53 +02:00
parent 31538a67d5
commit ed9eefd94b
2 changed files with 3 additions and 13 deletions
-3
View File
@@ -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)