From 91d865fa54b1a1105d50948426f27c5ef30e9616 Mon Sep 17 00:00:00 2001 From: Prashant Jaikumar Date: Wed, 17 Jul 2019 17:20:27 -0700 Subject: [PATCH] Create new build config for ASAN on Mac OS Workaround ASAN build issues on Mac OS. Disable LSAN as it's not supported by the version of clang that ships with Mac OS. --- tools/bazel.rc | 24 ++++++++++++++++--- .../internal_ci/macos/grpc_cfstream_asan.cfg | 2 +- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/tools/bazel.rc b/tools/bazel.rc index 411457a7cf5..e2d49355d8f 100644 --- a/tools/bazel.rc +++ b/tools/bazel.rc @@ -13,9 +13,6 @@ build:opt --copt=-Wframe-larger-than=16384 build:dbg --compilation_mode=dbg build:asan --strip=never -# Workaround for https://github.com/bazelbuild/bazel/issues/6932 -build:asan --copt -Wno-macro-redefined -build:asan --copt -D_FORTIFY_SOURCE=0 build:asan --copt=-fsanitize=address build:asan --copt=-O0 build:asan --copt=-fno-omit-frame-pointer @@ -25,6 +22,27 @@ build:asan --linkopt=-fsanitize=address build:asan --action_env=ASAN_OPTIONS=detect_leaks=1:color=always build:asan --action_env=LSAN_OPTIONS=suppressions=test/core/util/lsan_suppressions.txt:report_objects=1 +# We have a separate ASAN config for Mac OS to workaround a couple of bugs: +# 1. https://github.com/bazelbuild/bazel/issues/6932 +# _FORTIFY_SOURCE=1 is enabled by default on Mac OS, which breaks ASAN. +# We workaround it by setting _FORTIFY_SOURCE=0 and ignoring macro redefined +# warnings. +# 2. https://github.com/google/sanitizers/issues/1026 +# LSAN is not supported by the version of Clang that ships with Mac OS, so +# we disable it. +build:asan_macos --strip=never +build:asan_macos --copt=-fsanitize=address +build:asan_macos --copt -Wno-macro-redefined +build:asan_macos --copt -D_FORTIFY_SOURCE=0 +build:asan_macos --copt=-fsanitize=address +build:asan_macos --copt=-O0 +build:asan_macos --copt=-fno-omit-frame-pointer +build:asan_macos --copt=-DGPR_NO_DIRECT_SYSCALLS +build:asan_macos --copt=-DADDRESS_SANITIZER # used by absl +build:asan_macos --linkopt=-fsanitize=address +build:asan_macos --action_env=ASAN_OPTIONS=detect_leaks=0 + + build:msan --strip=never build:msan --copt=-fsanitize=memory build:msan --copt=-O0 diff --git a/tools/internal_ci/macos/grpc_cfstream_asan.cfg b/tools/internal_ci/macos/grpc_cfstream_asan.cfg index ceff78a4399..ac8a8b63ff6 100644 --- a/tools/internal_ci/macos/grpc_cfstream_asan.cfg +++ b/tools/internal_ci/macos/grpc_cfstream_asan.cfg @@ -18,6 +18,6 @@ build_file: "grpc/tools/internal_ci/macos/grpc_run_bazel_tests.sh" env_vars { key: "RUN_TESTS_FLAGS" - value: "--config=asan" + value: "--config=asan_macos" }