From 3da3ca961a88f528cb85c9763cd0a1b06c712330 Mon Sep 17 00:00:00 2001 From: Alexey Lapshin Date: Thu, 9 Apr 2026 21:56:24 +0700 Subject: [PATCH] fix(system): linux: avoid process initialization, all should be done by __libc_start_main --- components/esp_system/startup.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/esp_system/startup.c b/components/esp_system/startup.c index 5d68d49c01..3b56183dcd 100644 --- a/components/esp_system/startup.c +++ b/components/esp_system/startup.c @@ -85,7 +85,7 @@ const sys_startup_fn_t g_startup_fn[1] = { start_cpu0 }; ESP_LOG_ATTR_TAG(TAG, "cpu_start"); -#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS +#if CONFIG_COMPILER_CXX_EXCEPTIONS && !CONFIG_IDF_TARGET_LINUX /** * @brief A helper function for __do_global_ctors, which is in crtend.o. * It has been adapted from GCC source code. In GCC, it resides under @@ -104,7 +104,7 @@ static void __do_global_ctors_1(void) static struct object ob; __register_frame_info(__eh_frame, &ob); } -#endif // CONFIG_COMPILER_CXX_EXCEPTIONS +#endif // CONFIG_COMPILER_CXX_EXCEPTIONS && !CONFIG_IDF_TARGET_LINUX /* declare the start and stop symbols surrounding the array of init functions * registered by calling the system init function macros */ @@ -203,11 +203,11 @@ static void start_cpu0_default(void) // Operations that needs the cache to be disabled have to be done here. do_core_init(); +#if !CONFIG_IDF_TARGET_LINUX // Execute constructors. -#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS +#if CONFIG_COMPILER_CXX_EXCEPTIONS __do_global_ctors_1(); #endif -#if !CONFIG_IDF_TARGET_LINUX extern void __libc_init_array(void); __libc_init_array(); #endif // !CONFIG_IDF_TARGET_LINUX