Skip to content

Commit

Permalink
Merge pull request envoyproxy#30 from lizan/bazelrc
Browse files Browse the repository at this point in the history
Add bazel.rc for TSAN and ASAN
  • Loading branch information
lizan authored Jan 6, 2017
2 parents e2fec35 + 7958b1e commit ddb4d80
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,56 @@
test --test_output=errors
test --test_size_filters=-large,-enormous

# Address sanitizer
build:asan --strip=never
build:asan --copt -fsanitize=address
build:asan --copt -g
build:asan --copt -O1
build:asan --copt -fno-omit-frame-pointer
build:asan --copt -Wno-error=maybe-uninitialized
build:asan --linkopt -fsanitize=address
test:asan --test_tag_filters=-no_asan

# Thread sanitizer
build:tsan --strip=never
build:tsan --copt -fsanitize=thread
build:tsan --copt -fPIE
build:tsan --copt -O2
build:tsan --copt -g
build:tsan --copt -fno-omit-frame-pointer
build:tsan --copt -DGRPC_TSAN
build:tsan --linkopt -fsanitize=thread
build:tsan --linkopt -pie
# Use -Wl,-ltsan instead of -ltsan to make Bazel link libtsan before all other
# libs in particularly before -lpthread. This allows TSAN to pull in it's own
# version of -lpthread.
build:tsan --linkopt -Wl,-ltsan
test:tsan --test_tag_filters=-no_tsan

# Our default TSAN setup with -pie does not work with some linux versions (e.g.,
# on Travis's trusty). See https://github.com/google/sanitizers/issues/503
# So for TSAN on Travis we use gcc-5, which supports TSAN for non-pie binaries.
build:tsan_nopie --strip=never
build:tsan_nopie --copt -fsanitize=thread
build:tsan_nopie --copt -O2
build:tsan_nopie --copt -g
build:tsan_nopie --copt -fno-omit-frame-pointer
build:tsan_nopie --copt -DGRPC_TSAN
build:tsan_nopie --linkopt -fsanitize=thread
build:tsan_nopie --linkopt -Wl,-ltsan

# Explicitly instruct the compiler to use the gold linker. TSAN uses linker
# options (e.g., --push-state) that are only available in gold linker. On some
# linux versions (e.g., Travis's latest trusty), specifying -fsanitize=thread
# doesn't automatically use the gold linker.
build:tsan_nopie --linkopt -fuse-ld=gold
test:tsan_nopie --test_tag_filters=-no_tsan

# Release builds
build:release -c opt

# Add compile option for all C++ files
build --cxxopt -Wnon-virtual-dtor
build --cxxopt -Wformat
build --cxxopt -Wformat-security

0 comments on commit ddb4d80

Please sign in to comment.