From 443e0215d654715466b6b8c0221dd2abf195c40d Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Tue, 7 Feb 2023 20:40:27 +0100 Subject: [PATCH] Prevent inlining for empty placeholders of sthread_enable/disable. See the gcc documentation about function attribute noinline for details. Hope to fix hangs seen with optimized builds on recent Alpine/Linux. Let's see also if it works as is with all supported compilers. --- docs/source/Doxyfile | 5 ++--- include/xbt/base.h | 2 ++ src/xbt/xbt_main.cpp | 6 ++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/source/Doxyfile b/docs/source/Doxyfile index db9ec7e666..1595fcb1b7 100644 --- a/docs/source/Doxyfile +++ b/docs/source/Doxyfile @@ -59,10 +59,9 @@ PREDEFINED += \ SIMGRID_REGISTER_PLUGIN(id,desc,init)= \ XBT_PUBLIC= \ XBT_PUBLIC_DATA=extern \ - XBT_PUBLIC= \ - XBT_INLINE= \ - XBT_ALWAYS_INLINE= \ XBT_PRIVATE= \ + XBT_ALWAYS_INLINE= \ + XBT_ATTRIB_NOINLINE= \ XBT_ATTRIB_NORETURN= \ XBT_ATTRIB_UNUSED= \ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(cname,parent,desc)= \ diff --git a/include/xbt/base.h b/include/xbt/base.h index 5b55cb755f..4a18d1adbf 100644 --- a/include/xbt/base.h +++ b/include/xbt/base.h @@ -64,6 +64,8 @@ # define XBT_ATTRIB_DESTRUCTOR(prio) __attribute__((__destructor__)) #endif +#define XBT_ATTRIB_NOINLINE __attribute__((noinline)) + #if defined(__GNUC__) #define XBT_ALWAYS_INLINE inline __attribute__((always_inline)) #else diff --git a/src/xbt/xbt_main.cpp b/src/xbt/xbt_main.cpp index 75745262a3..4d41e07467 100644 --- a/src/xbt/xbt_main.cpp +++ b/src/xbt/xbt_main.cpp @@ -53,11 +53,13 @@ const int xbt_pagebits = static_cast(log2(xbt_pagesize)); */ static void xbt_preinit() XBT_ATTRIB_CONSTRUCTOR(200); static void xbt_postexit(); -void sthread_enable() +XBT_ATTRIB_NOINLINE void sthread_enable() { // These symbols are used from ContextSwapped in any case, but they are only useful + asm(""); } -void sthread_disable() +XBT_ATTRIB_NOINLINE void sthread_disable() { // when libsthread is LD_PRELOADED. In this case, sthread's implem gets used instead. + asm(""); } static void xbt_preinit() -- 2.20.1