diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2023-04-06 14:52:19 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2023-04-12 12:00:10 -0400 |
commit | a3bed764555f76003bb03c023123846fdff76f1b (patch) | |
tree | 4a1f98a61ca08c82bfc839c727f8da9ea81c51f0 /Makefile | |
parent | a812c5c8c9aabf6e0fd934bd55ec553c6dbb60c2 (diff) | |
download | bfs-a3bed764555f76003bb03c023123846fdff76f1b.tar.xz |
build: Fix tsan
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 72 |
1 files changed, 39 insertions, 33 deletions
@@ -65,7 +65,42 @@ MSAN := $(filter msan,$(MAKECMDGOALS)) TSAN := $(filter tsan,$(MAKECMDGOALS)) UBSAN := $(filter ubsan,$(MAKECMDGOALS)) -ifndef MSAN +ifdef ASAN +LOCAL_CFLAGS += -fsanitize=address +SANITIZE := y +endif + +ifdef LSAN +LOCAL_CFLAGS += -fsanitize=leak +SANITIZE := y +endif + +ifdef MSAN +# msan needs all code instrumented +NOLIBS := y +LOCAL_CFLAGS += -fsanitize=memory -fsanitize-memory-track-origins +SANITIZE := y +endif + +ifdef TSAN +# tsan needs all code instrumented +NOLIBS := y +# https://github.com/google/sanitizers/issues/342 +LOCAL_CPPFLAGS += -DBFS_TARGET_CLONES=false +LOCAL_CFLAGS += -fsanitize=thread +SANITIZE := y +endif + +ifdef UBSAN +LOCAL_CFLAGS += -fsanitize=undefined +SANITIZE := y +endif + +ifdef SANITIZE +LOCAL_CFLAGS += -fno-sanitize-recover=all +endif + +ifndef NOLIBS WITH_ONIGURUMA := y endif @@ -82,10 +117,10 @@ endif LOCAL_CFLAGS += $(ONIG_CFLAGS) LOCAL_LDLIBS += $(ONIG_LDLIBS) -endif +endif # WITH_ONIGURUMA ifeq ($(OS),Linux) -ifndef MSAN # These libraries are not built with msan +ifndef NOLIBS WITH_ACL := y WITH_ATTR := y WITH_LIBCAP := y @@ -111,41 +146,12 @@ endif LOCAL_LDFLAGS += -Wl,--as-needed LOCAL_LDLIBS += -lrt -endif +endif # Linux ifeq ($(OS),NetBSD) LOCAL_LDLIBS += -lutil endif -ifdef ASAN -LOCAL_CFLAGS += -fsanitize=address -SANITIZE := y -endif - -ifdef LSAN -LOCAL_CFLAGS += -fsanitize=leak -SANITIZE := y -endif - -ifdef MSAN -LOCAL_CFLAGS += -fsanitize=memory -fsanitize-memory-track-origins -SANITIZE := y -endif - -ifdef TSAN -LOCAL_CFLAGS += -fsanitize=thread -SANITIZE := y -endif - -ifdef UBSAN -LOCAL_CFLAGS += -fsanitize=undefined -SANITIZE := y -endif - -ifdef SANITIZE -LOCAL_CFLAGS += -fno-sanitize-recover=all -endif - ifneq ($(filter gcov,$(MAKECMDGOALS)),) LOCAL_CFLAGS += --coverage # gcov only intercepts fork()/exec() with -std=gnu* |