aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2026-03-21 15:17:04 +0000
committerRon Yorston <rmy@pobox.com>2026-03-21 15:17:04 +0000
commit8d97f41766c905bf527ee1b08d021fc4ae9d5af3 (patch)
treeb15a098c0062b976f9a30f1e06e0f23c9b7d2507
parent5b1e02cde21fef4fb9d8e8130818bb49e422dcfa (diff)
downloadbusybox-w32-8d97f41766c905bf527ee1b08d021fc4ae9d5af3.tar.gz
busybox-w32-8d97f41766c905bf527ee1b08d021fc4ae9d5af3.tar.bz2
busybox-w32-8d97f41766c905bf527ee1b08d021fc4ae9d5af3.zip
build system: add option to place statics in .bss
Upstream BusyBox uses the '-fdata-sections' compiler flag. On Windows this has the unfortunate side effect that static variables are placed in the .data section, thus increasing the size of the binary. Add a configuration option, STATICS_IN_BSS, to force statics into .bss on Windows, saving 2-5KB for most binaries. It has no effect on POSIX builds, where statics are always placed in .bss.
-rw-r--r--Config.in10
-rw-r--r--Makefile.flags4
-rw-r--r--configs/mingw32_defconfig1
-rw-r--r--configs/mingw32w_defconfig1
-rw-r--r--configs/mingw64_defconfig1
-rw-r--r--configs/mingw64a_defconfig1
-rw-r--r--configs/mingw64u_defconfig1
7 files changed, 19 insertions, 0 deletions
diff --git a/Config.in b/Config.in
index 51de85284..33fdd4466 100644
--- a/Config.in
+++ b/Config.in
@@ -582,6 +582,16 @@ config UNWIND_TABLES
582 normally required in BusyBox, but Windows' Control Flow Guard 582 normally required in BusyBox, but Windows' Control Flow Guard
583 needs it. Disabling this reduces the size of the binaries. 583 needs it. Disabling this reduces the size of the binaries.
584 584
585config STATICS_IN_BSS
586 bool "Place static variables in .bss"
587 default y
588 depends on PLATFORM_MINGW32
589 help
590 Upstream BusyBox sets a compiler flag which results in static
591 variables being placed in the .data section on Windows, thus
592 increasing the size of the binary. Disable this setting to use
593 the upstream default, probably only for diagnostic purposes.
594
585comment 'Build Options' 595comment 'Build Options'
586 596
587config STATIC 597config STATIC
diff --git a/Makefile.flags b/Makefile.flags
index 29fabcfb5..37200c89a 100644
--- a/Makefile.flags
+++ b/Makefile.flags
@@ -54,7 +54,11 @@ ifneq ($(lastword $(subst -, ,$(CC))),clang)
54CFLAGS += $(call cc-option,-finline-limit=0,) 54CFLAGS += $(call cc-option,-finline-limit=0,)
55endif 55endif
56 56
57ifneq ($(CONFIG_STATICS_IN_BSS),y)
57CFLAGS += $(call cc-option,-fno-builtin-strlen -fomit-frame-pointer -ffunction-sections -fdata-sections,) 58CFLAGS += $(call cc-option,-fno-builtin-strlen -fomit-frame-pointer -ffunction-sections -fdata-sections,)
59else
60CFLAGS += $(call cc-option,-fno-builtin-strlen -fomit-frame-pointer -ffunction-sections,)
61endif
58# -fno-guess-branch-probability: prohibit pseudo-random guessing 62# -fno-guess-branch-probability: prohibit pseudo-random guessing
59# of branch probabilities (hopefully makes bloatcheck more stable): 63# of branch probabilities (hopefully makes bloatcheck more stable):
60CFLAGS += $(call cc-option,-fno-guess-branch-probability,) 64CFLAGS += $(call cc-option,-fno-guess-branch-probability,)
diff --git a/configs/mingw32_defconfig b/configs/mingw32_defconfig
index d63a65eda..4f7da4ec3 100644
--- a/configs/mingw32_defconfig
+++ b/configs/mingw32_defconfig
@@ -66,6 +66,7 @@ CONFIG_FEATURE_IMPROVED_COLOUR_MAPPING=y
66CONFIG_FEATURE_EXTRA_FILE_DATA=y 66CONFIG_FEATURE_EXTRA_FILE_DATA=y
67CONFIG_OVERRIDE_APPLETS="" 67CONFIG_OVERRIDE_APPLETS=""
68# CONFIG_UNWIND_TABLES is not set 68# CONFIG_UNWIND_TABLES is not set
69CONFIG_STATICS_IN_BSS=y
69 70
70# 71#
71# Build Options 72# Build Options
diff --git a/configs/mingw32w_defconfig b/configs/mingw32w_defconfig
index 2e8172246..f0da4060e 100644
--- a/configs/mingw32w_defconfig
+++ b/configs/mingw32w_defconfig
@@ -66,6 +66,7 @@ CONFIG_FEATURE_IMPROVED_COLOUR_MAPPING=y
66CONFIG_FEATURE_EXTRA_FILE_DATA=y 66CONFIG_FEATURE_EXTRA_FILE_DATA=y
67CONFIG_OVERRIDE_APPLETS="" 67CONFIG_OVERRIDE_APPLETS=""
68# CONFIG_UNWIND_TABLES is not set 68# CONFIG_UNWIND_TABLES is not set
69CONFIG_STATICS_IN_BSS=y
69 70
70# 71#
71# Build Options 72# Build Options
diff --git a/configs/mingw64_defconfig b/configs/mingw64_defconfig
index f2b788bf7..e667571e1 100644
--- a/configs/mingw64_defconfig
+++ b/configs/mingw64_defconfig
@@ -66,6 +66,7 @@ CONFIG_FEATURE_IMPROVED_COLOUR_MAPPING=y
66CONFIG_FEATURE_EXTRA_FILE_DATA=y 66CONFIG_FEATURE_EXTRA_FILE_DATA=y
67CONFIG_OVERRIDE_APPLETS="" 67CONFIG_OVERRIDE_APPLETS=""
68CONFIG_UNWIND_TABLES=y 68CONFIG_UNWIND_TABLES=y
69CONFIG_STATICS_IN_BSS=y
69 70
70# 71#
71# Build Options 72# Build Options
diff --git a/configs/mingw64a_defconfig b/configs/mingw64a_defconfig
index 4e82560d7..b5b7a7a52 100644
--- a/configs/mingw64a_defconfig
+++ b/configs/mingw64a_defconfig
@@ -66,6 +66,7 @@ CONFIG_FEATURE_IMPROVED_COLOUR_MAPPING=y
66CONFIG_FEATURE_EXTRA_FILE_DATA=y 66CONFIG_FEATURE_EXTRA_FILE_DATA=y
67CONFIG_OVERRIDE_APPLETS="" 67CONFIG_OVERRIDE_APPLETS=""
68# CONFIG_UNWIND_TABLES is not set 68# CONFIG_UNWIND_TABLES is not set
69CONFIG_STATICS_IN_BSS=y
69 70
70# 71#
71# Build Options 72# Build Options
diff --git a/configs/mingw64u_defconfig b/configs/mingw64u_defconfig
index 08df0a86e..b3780040d 100644
--- a/configs/mingw64u_defconfig
+++ b/configs/mingw64u_defconfig
@@ -66,6 +66,7 @@ CONFIG_FEATURE_IMPROVED_COLOUR_MAPPING=y
66CONFIG_FEATURE_EXTRA_FILE_DATA=y 66CONFIG_FEATURE_EXTRA_FILE_DATA=y
67CONFIG_OVERRIDE_APPLETS="" 67CONFIG_OVERRIDE_APPLETS=""
68CONFIG_UNWIND_TABLES=y 68CONFIG_UNWIND_TABLES=y
69CONFIG_STATICS_IN_BSS=y
69 70
70# 71#
71# Build Options 72# Build Options