From fefdce3ee47ca6b833191a4364e0db696516c712 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Wed, 15 May 2024 21:12:54 +0200 Subject: [PATCH] macOS: Fix linking statically `__attribute__((constructor))` does not mark the symbol as used, so the linker ends up dead-stripping the symbol when linked statically. Adding the `used` attribute fixes that. --- src/prim/osx/alloc-override-zone.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/prim/osx/alloc-override-zone.c b/src/prim/osx/alloc-override-zone.c index 9a317750..1515b886 100644 --- a/src/prim/osx/alloc-override-zone.c +++ b/src/prim/osx/alloc-override-zone.c @@ -422,6 +422,7 @@ __attribute__((constructor(0))) #else __attribute__((constructor)) // seems not supported by g++-11 on the M1 #endif +__attribute__((used)) static void _mi_macos_override_malloc(void) { malloc_zone_t* purgeable_zone = NULL;