Skip to content

Commit 14f4c79

Browse files
committed
Add an ASAN config for bazel
This will be helpful for making sure we release memory properly when working with Rust FFI bindings. This is not yet enabled for CI yet, as there are a few other issues to work through to make that happen. (Also removing references to the noci tag in .bazelrc, which is no longer used by our project). Fixed: b/382074160 Change-Id: Ida9b2a86b2242c0486aab0ef862360d144640a24
1 parent d50d11b commit 14f4c79

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

.bazelrc

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,6 @@ build:ci --compilation_mode opt
7171
# Strip debug information from linked results.
7272
build:ci --linkopt=-Wl,--strip-all
7373

74-
# --build_tag_filters=-noci allow us to skip broken/flaky/specialized test
75-
# targets during CI builds by adding tags = ["noci"]
76-
build:ci --build_tag_filters=-noci
77-
7874
# --show_result leads to all of the built packages being logged at the
7975
# end, so we can visually verify that CI tasks are building everything we want.
8076
build:ci --show_result=1000000
@@ -101,6 +97,30 @@ build:unsafe-fast-presubmit --remote_cache=https://storage.googleapis.com/oak-ba
10197
build:unsafe-fast-presubmit --remote_upload_local_results=true
10298
build:unsafe-fast-presubmit --google_default_credentials=true
10399

100+
# Many of these flags were discovered by looking for `build:asan` examples internally.
101+
build:asan --strip=never
102+
build:asan --copt -fsanitize=address
103+
build:asan --copt -DADDRESS_SANITIZER=1
104+
build:asan --copt -O1
105+
build:asan --copt -g3
106+
build:asan --copt -fno-optimize-sibling-calls
107+
build:asan --copt -fno-omit-frame-pointer
108+
build:asan --compilation_mode=dbg
109+
build:asan --linkopt -fsanitize=address
110+
# The other options trigger a maybe-uninitialized error when compiling protobuf; this prevents it.
111+
build:asan --copt -Wno-error=maybe-uninitialized
112+
# The flags improve symbolication and rust stack trace expansion
113+
build:asan --@rules_rust//rust/settings:extra_rustc_flag=-Zsanitizer=address
114+
build:asan --@rules_rust//rust/settings:extra_rustc_flag=-Cdebuginfo=full
115+
build:asan --@rules_rust//rust/settings:extra_rustc_flag=-Ccodegen-units=1
116+
build:asan --@rules_rust//rust/settings:extra_rustc_flag=-Clink-dead-code
117+
build:asan --@rules_rust//rust/settings:extra_rustc_flag=-Cpasses=sancov-module
118+
build:asan --@rules_rust//rust/settings:extra_rustc_flag=-Cllvm-args=-sanitizer-coverage-level=4
119+
build:asan --@rules_rust//rust/settings:extra_rustc_flag=-Cllvm-args=-sanitizer-coverage-pc-table
120+
build:asan --@rules_rust//rust/settings:extra_rustc_flag=-Cllvm-args=-sanitizer-coverage-inline-8bit-counters
121+
build:asan --@rules_rust//rust/settings:extra_rustc_flag=-Cllvm-args=-sanitizer-coverage-trace-compares
122+
build:asan --@rules_rust//rust/settings:extra_rustc_flag=-Cllvm-args=-sanitizer-coverage-stack-depth
123+
104124
# Use a custom local bazelrc if present.
105125
#
106126
# To set up remote cache write credentials:

0 commit comments

Comments
 (0)