Skip to content

Commit 1b9d971

Browse files
authored
chef: Use -u flag to force linking non-weak functions for esp32 example (#33209)
1 parent a30b439 commit 1b9d971

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

examples/chef/common/stubs.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -235,3 +235,7 @@ void emberAfWakeOnLanClusterInitCallback(EndpointId endpoint)
235235
WakeOnLan::SetDefaultDelegate(endpoint, &wakeOnLanManager);
236236
}
237237
#endif
238+
239+
// No-op function, used to force linking this file,
240+
// instead of the weak functions from other files
241+
extern "C" void chef_include_stubs_impl(void) {}

examples/chef/esp32/main/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ idf_component_register(PRIV_INCLUDE_DIRS
121121
PRIV_REQUIRES chip nvs_flash bt console mbedtls QRCode tft screen-framework spidriver
122122
SRC_DIRS ${SRC_DIRS_LIST})
123123

124+
# Forces the linker to include common/stubs.cpp
125+
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u chef_include_stubs_impl")
126+
124127
include("${CHIP_ROOT}/build/chip/esp32/esp32_codegen.cmake")
125128
chip_app_component_codegen("${CHEF}/devices/${SAMPLE_NAME}.matter")
126129
chip_app_component_zapgen("${CHEF}/devices/${SAMPLE_NAME}.zap")

0 commit comments

Comments
 (0)