aboutsummaryrefslogtreecommitdiffhomepage
path: root/Makefile
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2022-10-12 19:14:41 +0200
committerRon Evans <[email protected]>2022-10-14 11:17:51 +0200
commit5548b5999bc5693597305eec7899295f5b8e075f (patch)
tree4c756e6dd165891da5426914a3e84577bc6709ff /Makefile
parent8f33721b882b79f6f224698823bf5e3354fccd3b (diff)
downloadtinygo-5548b5999bc5693597305eec7899295f5b8e075f.tar.gz
tinygo-5548b5999bc5693597305eec7899295f5b8e075f.zip
Makefile: add ASAN=1 flag to build with AddressSanitizer enabled
This sanitizer is useful to detect use-after-free, double free, buffer overflows, and more such errors. I've found it useful lately to detect some bugs in TinyGo, and having a single flag to enable it makes it much easier to enable AddressSanitizer.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile6
1 files changed, 6 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 99f67c29e..4345290b4 100644
--- a/Makefile
+++ b/Makefile
@@ -56,6 +56,12 @@ else
LLVM_OPTION += '-DLLVM_ENABLE_ASSERTIONS=OFF'
endif
+# Enable AddressSanitizer
+ifeq (1, $(ASAN))
+ LLVM_OPTION += -DLLVM_USE_SANITIZER=Address
+ CGO_LDFLAGS += -fsanitize=address
+endif
+
ifeq (1, $(STATIC))
# Build TinyGo as a fully statically linked binary (no dynamically loaded
# libraries such as a libc). This is not supported with glibc which is used