From a95620fcdbb7fe60018eb38e2a21173c50f89682 Mon Sep 17 00:00:00 2001 From: WanqQixiang Date: Mon, 29 Apr 2024 15:45:51 +0800 Subject: [PATCH] chef: Use -u flag to force linking non-weak functions for esp32 example --- examples/chef/common/stubs.cpp | 4 ++++ examples/chef/esp32/main/CMakeLists.txt | 3 +++ 2 files changed, 7 insertions(+) diff --git a/examples/chef/common/stubs.cpp b/examples/chef/common/stubs.cpp index 91a7b5a84d10e1..5756aaa35b7e26 100644 --- a/examples/chef/common/stubs.cpp +++ b/examples/chef/common/stubs.cpp @@ -235,3 +235,7 @@ void emberAfWakeOnLanClusterInitCallback(EndpointId endpoint) WakeOnLan::SetDefaultDelegate(endpoint, &wakeOnLanManager); } #endif + +// No-op function, used to force linking this file, +// instead of the weak functions from other files +extern "C" void chef_include_stubs_impl(void) {} diff --git a/examples/chef/esp32/main/CMakeLists.txt b/examples/chef/esp32/main/CMakeLists.txt index 75cf0b85222d95..549f98abcfac9c 100644 --- a/examples/chef/esp32/main/CMakeLists.txt +++ b/examples/chef/esp32/main/CMakeLists.txt @@ -121,6 +121,9 @@ idf_component_register(PRIV_INCLUDE_DIRS PRIV_REQUIRES chip nvs_flash bt console mbedtls QRCode tft screen-framework spidriver SRC_DIRS ${SRC_DIRS_LIST}) +# Forces the linker to include common/stubs.cpp +target_link_libraries(${COMPONENT_LIB} INTERFACE "-u chef_include_stubs_impl") + include("${CHIP_ROOT}/build/chip/esp32/esp32_codegen.cmake") chip_app_component_codegen("${CHEF}/devices/${SAMPLE_NAME}.matter") chip_app_component_zapgen("${CHEF}/devices/${SAMPLE_NAME}.zap")