|
| 1 | +# Causes the build to default to the custom toolchain |
| 2 | +build --incompatible_enable_cc_toolchain_resolution |
| 3 | + |
1 | 4 | build --action_env=BAZEL_CXXOPTS='-std=c++14'
|
2 | 5 |
|
3 | 6 | build:clang-tidy --aspects @rules_swiftnav//clang_tidy:clang_tidy.bzl%clang_tidy_aspect
|
4 | 7 | build:clang-tidy --output_groups=report
|
| 8 | + |
| 9 | +# Shared sanitizer configuration |
| 10 | +common:sanitize -c dbg |
| 11 | +common:sanitize --cxxopt=-g3 |
| 12 | +common:sanitize --copt=-g3 |
| 13 | +common:sanitize --linkopt=-g3 |
| 14 | +#common:sanitize --cxxopt=-O1 |
| 15 | +#common:sanitize --copt=-O1 |
| 16 | +#common:sanitize --linkopt=-O1 |
| 17 | +common:sanitize --cxxopt=-fno-omit-frame-pointer |
| 18 | +common:sanitize --copt=-fno-omit-frame-pointer |
| 19 | +common:sanitize --linkopt=-fno-omit-frame-pointer |
| 20 | +common:sanitize --@rules_swiftnav//cc:enable_symbolizer=true |
| 21 | + |
| 22 | +# Sanitizer overhead can cause some functions to become so large that |
| 23 | +# the compiler falls back to a linear register allocator. This |
| 24 | +# shouldn't cause a sanitizer build to fail. |
| 25 | +common:sanitize --cxxopt=-Wno-error=disabled-optimization |
| 26 | +common:sanitize --copt=-Wno-error=disabled-optimization |
| 27 | +common:sanitize --linkopt=-Wno-error=disabled-optimization |
| 28 | +# https://github.com/bazelbuild/bazel/issues/12797#issuecomment-980641064 |
| 29 | +common:sanitize --linkopt='-fsanitize-link-c++-runtime' |
| 30 | +common:sanitize --cxxopt=-fPIC |
| 31 | +common:sanitize --copt=-fPIC |
| 32 | +common:sanitize --linkopt=-fPIC |
| 33 | + |
| 34 | +# Address sanitizer |
| 35 | +common:asan --config=sanitize |
| 36 | +common:asan --cxxopt=-fsanitize=address |
| 37 | +common:asan --copt=-fsanitize=address |
| 38 | +common:asan --linkopt=-fsanitize=address |
| 39 | +common:asan --cxxopt=-fno-optimize-sibling-calls |
| 40 | +common:asan --copt=-fno-optimize-sibling-calls |
| 41 | +common:asan --linkopt=-fno-optimize-sibling-calls |
| 42 | +common:asan --platform_suffix=asan |
| 43 | + |
| 44 | +# Undefined behavior sanitizer |
| 45 | +common:ubsan --config=sanitize |
| 46 | +common:ubsan --cxxopt=-fsanitize=undefined |
| 47 | +common:ubsan --copt=-fsanitize=undefined |
| 48 | +common:ubsan --linkopt=-fsanitize=undefined |
| 49 | +common:ubsan --cxxopt=-fno-sanitize-recover=all |
| 50 | +common:ubsan --copt=-fno-sanitize-recover=all |
| 51 | +common:ubsan --linkopt=-fno-sanitize-recover=all |
| 52 | +common:ubsan --cxxopt=-fsanitize=local-bounds |
| 53 | +common:ubsan --copt=-fsanitize=local-bounds |
| 54 | +common:ubsan --linkopt=-fsanitize=local-bounds |
| 55 | +common:ubsan --@rules_swiftnav//cc:enable_rtti=true |
| 56 | +# Unfortunately the current build setup doesn't seem to provide stack |
| 57 | +# frame names using clang++ and llvm-symbolizer. (This was also the |
| 58 | +# case in cmake, but the default of g++ there _did_ provide frame |
| 59 | +# names in backtraces.) |
| 60 | +test:ubsan --action_env="UBSAN_OPTIONS=print_stacktrace=1" |
| 61 | +run:ubsan --action_env="UBSAN_OPTIONS=print_stacktrace=1" |
| 62 | +# vptr sanitizer is horribly broken to the point of throwing false positives at a |
| 63 | +# rate that suppressions or an ignore list are impractical. |
| 64 | +common:ubsan --cxxopt=-fno-sanitize=vptr |
| 65 | +common:ubsan --linkopt=-fno-sanitize=vptr |
| 66 | +common:ubsan --platform_suffix=ubsan |
| 67 | + |
| 68 | +# Dynamic memory sanitizer |
| 69 | +# |
| 70 | +# Warning: takes an incredible amount of space! Try testing only one |
| 71 | +# target at a time. |
| 72 | +common:msan --config=sanitize |
| 73 | +common:msan --cxxopt=-fsanitize=memory |
| 74 | +common:msan --copt=-fsanitize=memory |
| 75 | +common:msan --linkopt=-fsanitize=memory |
| 76 | +common:msan --cxxopt=-fsanitize-memory-track-origins=2 |
| 77 | +common:msan --copt=-fsanitize-memory-track-origins=2 |
| 78 | +common:msan --linkopt=-fsanitize-memory-track-origins=2 |
| 79 | +common:msan --cxxopt=-fsanitize-memory-use-after-dtor |
| 80 | +common:msan --copt=-fsanitize-memory-use-after-dtor |
| 81 | +common:msan --linkopt=-fsanitize-memory-use-after-dtor |
| 82 | +common:msan --platform_suffix=msan |
| 83 | + |
| 84 | +# > Currently, ThreadSanitizer symbolizes its output using an external |
| 85 | +# > addr2line process (this will be fixed in future). |
| 86 | +# |
| 87 | +# https://clang.llvm.org/docs/ThreadSanitizer.html#usage |
| 88 | +common:tsan --config=sanitize |
| 89 | +common:tsan --cxxopt=-fsanitize=thread |
| 90 | +common:tsan --copt=-fsanitize=thread |
| 91 | +common:tsan --linkopt=-fsanitize=thread |
| 92 | +common:tsan --platform_suffix=tsan |
| 93 | + |
| 94 | +# Helpful aliases |
| 95 | +common:asan_ubsan --config=asan |
| 96 | +common:asan_ubsan --config=ubsan |
| 97 | +common:ubsan_asan --config=asan_ubsan |
0 commit comments