Files
esp-idf/components/esp_common/CMakeLists.txt
T
Guillaume Souchere e7cf8cd3cb fix(mbedtls): fix undefined esp_mbedtls_mem_calloc/free at link time
platform.c (compiled into the 'builtin' archive) calls
esp_mbedtls_mem_calloc and esp_mbedtls_mem_free directly by name via
the MBEDTLS_PLATFORM_STD_CALLOC/FREE macros in esp_config.h.
Previously, esp_mem.c was compiled into the 'tfpsacrypto' archive, which
appears after 'builtin' in the link command, causing the linker to fail
with undefined reference errors when 'builtin' was processed first.

Moving esp_mem.c into 'builtin' to assure that the function used by
esp_mbedtls_mem_calloc and esp_mbedtls_mem_free are available when
pltform.c is linked.
2026-04-09 10:51:21 +02:00

55 lines
1.9 KiB
CMake

idf_build_get_property(target IDF_TARGET)
if(${target} STREQUAL "linux")
set(ldfragments)
else()
set(ldfragments common.lf soc.lf)
endif()
set(srcs "src/esp_err_to_name.c")
idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS include
LDFRAGMENTS ${ldfragments})
# Note: LINK_INTERFACE_MULTIPLICITY is needed to break circular static-library
# dependencies in the component graph. The core cycle is:
# esp_system -> bootloader_support -> efuse -> esp_system
# (efuse registers an ESP_SYSTEM_INIT_FN and calls esp_restart(), both of which
# pull in esp_system). Several more cycles exist through esp_partition, esp_mm,
# and mbedtls. All cycle-causing deps are already PRIV_REQUIRES, so the
# multiplicity property on this universal dependency is the established fix.
set_property(TARGET ${COMPONENT_LIB} APPEND PROPERTY LINK_INTERFACE_MULTIPLICITY 4)
# List of components needed for the error codes list
set(optional_reqs ulp
efuse
esp_http_client
esp_http_server
bootloader_support
nvs_flash
esp_wifi
app_update
lwip
spi_flash
wpa_supplicant
esp_serial_slave_link
esp_netif
soc
esp-tls
esp_https_ota
esp_hal_mspi
esp_hw_support)
if(IDF_BUILD_V2)
idf_component_optional_requires(PRIVATE ${optional_reqs})
else()
idf_build_get_property(build_components BUILD_COMPONENTS)
foreach(req ${optional_reqs})
if(req IN_LIST build_components)
idf_component_get_property(req_lib ${req} COMPONENT_LIB)
target_link_libraries(${COMPONENT_LIB} PRIVATE ${req_lib})
endif()
endforeach()
endif()