diff options
| author | Ron Yorston <rmy@pobox.com> | 2026-03-21 15:17:04 +0000 |
|---|---|---|
| committer | Ron Yorston <rmy@pobox.com> | 2026-03-21 15:17:04 +0000 |
| commit | 8d97f41766c905bf527ee1b08d021fc4ae9d5af3 (patch) | |
| tree | b15a098c0062b976f9a30f1e06e0f23c9b7d2507 | |
| parent | 5b1e02cde21fef4fb9d8e8130818bb49e422dcfa (diff) | |
| download | busybox-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.in | 10 | ||||
| -rw-r--r-- | Makefile.flags | 4 | ||||
| -rw-r--r-- | configs/mingw32_defconfig | 1 | ||||
| -rw-r--r-- | configs/mingw32w_defconfig | 1 | ||||
| -rw-r--r-- | configs/mingw64_defconfig | 1 | ||||
| -rw-r--r-- | configs/mingw64a_defconfig | 1 | ||||
| -rw-r--r-- | configs/mingw64u_defconfig | 1 |
7 files changed, 19 insertions, 0 deletions
| @@ -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 | ||
| 585 | config 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 | |||
| 585 | comment 'Build Options' | 595 | comment 'Build Options' |
| 586 | 596 | ||
| 587 | config STATIC | 597 | config 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) | |||
| 54 | CFLAGS += $(call cc-option,-finline-limit=0,) | 54 | CFLAGS += $(call cc-option,-finline-limit=0,) |
| 55 | endif | 55 | endif |
| 56 | 56 | ||
| 57 | ifneq ($(CONFIG_STATICS_IN_BSS),y) | ||
| 57 | CFLAGS += $(call cc-option,-fno-builtin-strlen -fomit-frame-pointer -ffunction-sections -fdata-sections,) | 58 | CFLAGS += $(call cc-option,-fno-builtin-strlen -fomit-frame-pointer -ffunction-sections -fdata-sections,) |
| 59 | else | ||
| 60 | CFLAGS += $(call cc-option,-fno-builtin-strlen -fomit-frame-pointer -ffunction-sections,) | ||
| 61 | endif | ||
| 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): |
| 60 | CFLAGS += $(call cc-option,-fno-guess-branch-probability,) | 64 | CFLAGS += $(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 | |||
| 66 | CONFIG_FEATURE_EXTRA_FILE_DATA=y | 66 | CONFIG_FEATURE_EXTRA_FILE_DATA=y |
| 67 | CONFIG_OVERRIDE_APPLETS="" | 67 | CONFIG_OVERRIDE_APPLETS="" |
| 68 | # CONFIG_UNWIND_TABLES is not set | 68 | # CONFIG_UNWIND_TABLES is not set |
| 69 | CONFIG_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 | |||
| 66 | CONFIG_FEATURE_EXTRA_FILE_DATA=y | 66 | CONFIG_FEATURE_EXTRA_FILE_DATA=y |
| 67 | CONFIG_OVERRIDE_APPLETS="" | 67 | CONFIG_OVERRIDE_APPLETS="" |
| 68 | # CONFIG_UNWIND_TABLES is not set | 68 | # CONFIG_UNWIND_TABLES is not set |
| 69 | CONFIG_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 | |||
| 66 | CONFIG_FEATURE_EXTRA_FILE_DATA=y | 66 | CONFIG_FEATURE_EXTRA_FILE_DATA=y |
| 67 | CONFIG_OVERRIDE_APPLETS="" | 67 | CONFIG_OVERRIDE_APPLETS="" |
| 68 | CONFIG_UNWIND_TABLES=y | 68 | CONFIG_UNWIND_TABLES=y |
| 69 | CONFIG_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 | |||
| 66 | CONFIG_FEATURE_EXTRA_FILE_DATA=y | 66 | CONFIG_FEATURE_EXTRA_FILE_DATA=y |
| 67 | CONFIG_OVERRIDE_APPLETS="" | 67 | CONFIG_OVERRIDE_APPLETS="" |
| 68 | # CONFIG_UNWIND_TABLES is not set | 68 | # CONFIG_UNWIND_TABLES is not set |
| 69 | CONFIG_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 | |||
| 66 | CONFIG_FEATURE_EXTRA_FILE_DATA=y | 66 | CONFIG_FEATURE_EXTRA_FILE_DATA=y |
| 67 | CONFIG_OVERRIDE_APPLETS="" | 67 | CONFIG_OVERRIDE_APPLETS="" |
| 68 | CONFIG_UNWIND_TABLES=y | 68 | CONFIG_UNWIND_TABLES=y |
| 69 | CONFIG_STATICS_IN_BSS=y | ||
| 69 | 70 | ||
| 70 | # | 71 | # |
| 71 | # Build Options | 72 | # Build Options |
