Skip to content

Commit 3525da9

Browse files
committed
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.
1 parent fdf075a commit 3525da9

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

builder/bdwgc.go

+6
Original file line numberDiff line numberDiff line change
@@ -30,6 +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_CLOCK", // don't use system clock
34+
"-DNO_DEBUGGING", // reduce code size
35+
"-DGC_NO_FINALIZATION", // finalization is not used at the moment
36+
"-DNO_GETENV", // smaller binary, more predictable configuration
3337

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

3943
// Do not scan the stack. We have our own mechanism to do this.
4044
"-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
4147

4248
// Assertions can be enabled while debugging GC issues.
4349
//"-DGC_ASSERTIONS",

0 commit comments

Comments
 (0)