From 5ab121b26f0bc116d37928aeb0947474e211b2a4 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, the library becomes a lot smaller. With `-no-debug`, binaries become ~25kB smaller on Linux, ~5kB smaller on MacOS, and ~11kB smaller on Windows. This isn't really important on Linux/macOS/Windows, but will become important when we start using bdwgc on WebAssembly. --- builder/bdwgc.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/builder/bdwgc.go b/builder/bdwgc.go index 88e7a26732..8dd03a509b 100644 --- a/builder/bdwgc.go +++ b/builder/bdwgc.go @@ -30,6 +30,10 @@ var BoehmGC = Library{ // Use a minimal environment. "-DNO_MSGBOX_ON_ERROR", // don't call MessageBoxA on Windows "-DDONT_USE_ATEXIT", + "-DNO_CLOCK", // don't use system clock + "-DNO_DEBUGGING", // reduce code size + "-DGC_NO_FINALIZATION", // finalization is not used at the moment + "-DNO_GETENV", // smaller binary, more predictable configuration // 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 @@ -38,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", @@ -59,7 +65,6 @@ var BoehmGC = Library{ "blacklst.c", "dbg_mlc.c", "dyn_load.c", - "finalize.c", "headers.c", "mach_dep.c", "malloc.c",