From 6697c46149df244d64de0885f72919f3ee2dbddd Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Wed, 26 Mar 2025 10:27:55 +0100 Subject: [PATCH] all: shrink bdwgc library By disabling some configuration options (and updating the library), the library becomes a lot smaller. With `-no-debug`, binaries become ~18kB smaller on Linux, ~4kB smaller on MacOS, ~9kB smaller on Windows, and ~12kB smaller on WebAssembly. --- builder/bdwgc.go | 9 ++++++--- lib/bdwgc | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/builder/bdwgc.go b/builder/bdwgc.go index eba126b919..b03b154203 100644 --- a/builder/bdwgc.go +++ b/builder/bdwgc.go @@ -30,7 +30,10 @@ var BoehmGC = Library{ // Use a minimal environment. "-DNO_MSGBOX_ON_ERROR", // don't call MessageBoxA on Windows "-DDONT_USE_ATEXIT", - "-DNO_GETENV", + "-DNO_GETENV", // smaller binary, more predictable configuration + "-DNO_CLOCK", // don't use system clock + "-DNO_DEBUGGING", // reduce code size + "-DGC_NO_FINALIZATION", // finalization is not used at the moment // Special flag to work around the lack of __data_start in ld.lld. // TODO: try to fix this in LLVM/lld directly so we don't have to @@ -39,6 +42,8 @@ var BoehmGC = Library{ // Do not scan the stack. We have our own mechanism to do this. "-DSTACK_NOT_SCANNED", + "-DNO_PROC_STAT", // we scan the stack manually (don't read /proc/self/stat on Linux) + "-DSTACKBOTTOM=0", // dummy value, we scan the stack manually // Assertions can be enabled while debugging GC issues. //"-DGC_ASSERTIONS", @@ -63,7 +68,6 @@ var BoehmGC = Library{ "blacklst.c", "dbg_mlc.c", "dyn_load.c", - "finalize.c", "headers.c", "mach_dep.c", "malloc.c", @@ -71,7 +75,6 @@ var BoehmGC = Library{ "mark_rts.c", "misc.c", "new_hblk.c", - "obj_map.c", "os_dep.c", "reclaim.c", } diff --git a/lib/bdwgc b/lib/bdwgc index 1166f11f7d..7577ca7c2d 160000 --- a/lib/bdwgc +++ b/lib/bdwgc @@ -1 +1 @@ -Subproject commit 1166f11f7dee08d7ad369296b24cf8c9582f8789 +Subproject commit 7577ca7c2dc7364bb6733dab23be34231279db6b