Skip to content

Commit 256e84f

Browse files
aykevldeadprogram
authored andcommitted
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.
1 parent 0a87846 commit 256e84f

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

builder/bdwgc.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ var BoehmGC = Library{
3030
// Use a minimal environment.
3131
"-DNO_MSGBOX_ON_ERROR", // don't call MessageBoxA on Windows
3232
"-DDONT_USE_ATEXIT",
33-
"-DNO_GETENV",
33+
"-DNO_GETENV", // smaller binary, more predictable configuration
34+
"-DNO_CLOCK", // don't use system clock
35+
"-DNO_DEBUGGING", // reduce code size
36+
"-DGC_NO_FINALIZATION", // finalization is not used at the moment
3437

3538
// Special flag to work around the lack of __data_start in ld.lld.
3639
// TODO: try to fix this in LLVM/lld directly so we don't have to
@@ -39,6 +42,8 @@ var BoehmGC = Library{
3942

4043
// Do not scan the stack. We have our own mechanism to do this.
4144
"-DSTACK_NOT_SCANNED",
45+
"-DNO_PROC_STAT", // we scan the stack manually (don't read /proc/self/stat on Linux)
46+
"-DSTACKBOTTOM=0", // dummy value, we scan the stack manually
4247

4348
// Assertions can be enabled while debugging GC issues.
4449
//"-DGC_ASSERTIONS",
@@ -63,15 +68,13 @@ var BoehmGC = Library{
6368
"blacklst.c",
6469
"dbg_mlc.c",
6570
"dyn_load.c",
66-
"finalize.c",
6771
"headers.c",
6872
"mach_dep.c",
6973
"malloc.c",
7074
"mark.c",
7175
"mark_rts.c",
7276
"misc.c",
7377
"new_hblk.c",
74-
"obj_map.c",
7578
"os_dep.c",
7679
"reclaim.c",
7780
}

lib/bdwgc

Submodule bdwgc updated from 1166f11 to 7577ca7

0 commit comments

Comments
 (0)