Merge remote-tracking branch 'origin/app-placement-new' into integration

This commit is contained in:
J. Nick Koston
2026-02-18 12:24:26 -06:00
2 changed files with 11 additions and 1 deletions
+8 -1
View File
@@ -669,7 +669,14 @@ void Application::yield_with_select_(uint32_t delay_ms) {
#endif
}
Application App; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
// App storage — asm label shares the linker symbol with "extern Application App".
// char[] is trivially destructible, so no __cxa_atexit or destructor chain is emitted.
// Constructed via placement new in the generated setup().
#ifndef __GXX_ABI_VERSION
#error "Application placement new requires Itanium C++ ABI (GCC/Clang)"
#endif
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
alignas(Application) char app_storage[sizeof(Application)] asm("_ZN7esphome3AppE");
#if defined(USE_SOCKET_SELECT_SUPPORT) && defined(USE_WAKE_LOOP_THREADSAFE)
void Application::setup_wake_loop_threadsafe_() {
+3
View File
@@ -512,6 +512,9 @@ async def to_code(config: ConfigType) -> None:
cg.add_global(cg.RawExpression("using std::min"))
cg.add_global(cg.RawExpression("using std::max"))
# Construct App via placement new — see application.cpp for storage details
cg.add_global(cg.RawExpression("#include <new>"))
cg.add(cg.RawExpression("new (&App) Application()"))
cg.add(
cg.App.pre_setup(
config[CONF_NAME],