Skip to content

Commit

Permalink
chef: Use -u flag to force linking non-weak functions for esp32 examp…
Browse files Browse the repository at this point in the history
…le (#33209)
  • Loading branch information
wqx6 authored Apr 30, 2024
1 parent a30b439 commit 1b9d971
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions examples/chef/common/stubs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
3 changes: 3 additions & 0 deletions examples/chef/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 1b9d971

Please sign in to comment.