diff --git a/tools/system_libs.py b/tools/system_libs.py index 55cf0cb6b7b6a..53dab461c77fc 100644 --- a/tools/system_libs.py +++ b/tools/system_libs.py @@ -1889,8 +1889,6 @@ class libmimalloc(MTLibrary): '-DNDEBUG', # Emscripten uses musl libc internally '-DMI_LIBC_MUSL', - # enable use of `__builtin_thread_pointer()` - '-DMI_USE_BUILTIN_THREAD_POINTER', ] # malloc/free/calloc are runtime functions and can be generated during LTO @@ -1913,6 +1911,13 @@ class libmimalloc(MTLibrary): # Include sbrk.c in libc, it uses tracing and libc itself doesn't have a tracing variant. src_files += [utils.path_from_root('system/lib/libc/sbrk.c')] + def get_cflags(self): + cflags = super().get_cflags() + if self.is_mt: + # enable use of `__builtin_thread_pointer()` in multithreaded builds + cflags += ['-DMI_USE_BUILTIN_THREAD_POINTER'] + return cflags + def can_use(self): return super().can_use() and settings.MALLOC == 'mimalloc'