[git commit] build: add a sanitizer debug option

Mike Frysinger vapier at gentoo.org
Sat Feb 13 03:12:47 UTC 2016

commit: https://git.busybox.net/busybox/commit/?id=43e56639c6739953d5a6686823bcd0d256512ea5
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

Building & running with ASAN is super helpful, so add a dedicated config
knob for it.  This way people don't have to guess at the right compiler
settings in order to get a good build.  We can just tell people to enable
this one option.

Signed-off-by: Mike Frysinger <vapier at gentoo.org>
 Config.in      | 10 ++++++++++
 Makefile.flags |  5 +++++
 2 files changed, 15 insertions(+)

diff --git a/Config.in b/Config.in
index 07b4bf3..0a0b5d7 100644
--- a/Config.in
+++ b/Config.in
@@ -688,6 +688,16 @@ config DEBUG_PESSIMIZE
 	  in a much bigger executable that more closely matches the source
+	bool "Enable runtime sanitizers (ASAN/LSAN/USAN/etc...)"
+	default n
+	help
+	  Say Y here if you want to enable runtime sanitizers. These help
+	  catch bad memory accesses (e.g. buffer overflows), but will make
+	  the executable larger and slow down runtime a bit.
+	  If you aren't developing/testing busybox, say N here.
 config UNIT_TEST
 	bool "Build unit tests"
 	default n
diff --git a/Makefile.flags b/Makefile.flags
index 9f77674..65021de 100644
--- a/Makefile.flags
+++ b/Makefile.flags
@@ -75,6 +75,11 @@ else
 CFLAGS += $(call cc-option,-Os,$(call cc-option,-O2,))
+CFLAGS += $(call cc-option,-fsanitize=address,)
+CFLAGS += $(call cc-option,-fsanitize=leak,)
+CFLAGS += $(call cc-option,-fsanitize=undefined,)
 # If arch/$(ARCH)/Makefile did not override it (with, say, -fPIC)...
 ARCH_FPIC ?= -fpic

More information about the busybox-cvs mailing list