Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ build:asan --copt -D__SANITIZE_ADDRESS__
build:asan --test_env=ASAN_OPTIONS=handle_abort=1:allow_addr2line=true:check_initialization_order=true:strict_init_order=true
build:asan --test_env=UBSAN_OPTIONS=halt_on_error=true:print_stacktrace=1
build:asan --test_env=ASAN_SYMBOLIZER_PATH
# TODO(htuch): these are temporary workarounds, remove when
# https://github.com/bazelbuild/rules_foreign_cc/issues/154#issuecomment-466504751 is resolved.
build:asan --action_env=CC
build:asan --action_env=CXX
build:asan --action_env=CFLAGS="-fsanitize=address,undefined -fno-sanitize=vptr"
build:asan --action_env=CXXFLAGS="-fsanitize=address,undefined -fno-sanitize=vptr"
# This is needed for host protoc. TODO(htuch): Figure out why..
build:asan --action_env=LSAN_OPTIONS=verbosity=1:log_threads=1
build:asan --test_env=LSAN_OPTIONS=verbosity=1:log_threads=1

# Clang ASAN/UBSAN
build:clang-asan --config=asan
Expand All @@ -37,8 +46,16 @@ build:macos-asan --copt -D_FORTIFY_SOURCE=0
# Clang TSAN
build:clang-tsan --define ENVOY_CONFIG_TSAN=1
build:clang-tsan --copt -fsanitize=thread
# This is needed because of https://github.com/libevent/libevent/issues/777
build:clang-tsan --copt -DEVENT__DISABLE_DEBUG_MODE
build:clang-tsan --linkopt -fsanitize=thread
build:clang-tsan --define tcmalloc=disabled
# TODO(htuch): these are temporary workarounds, remove when
# https://github.com/bazelbuild/rules_foreign_cc/issues/154#issuecomment-466504751 is resolved.
build:clang-tsan --action_env=CC
build:clang-tsan --action_env=CXX
build:clang-tsan --action_env=CFLAGS="-fsanitize=thread -DEVENT__DISABLE_DEBUG_MODE"
build:clang-tsan --action_env=CXXFLAGS="-fsanitize=thread"

# Clang MSAN - broken today since we need to rebuild lib[std]c++ and external deps with MSAN
# support (see https://github.com/envoyproxy/envoy/issues/443).
Expand Down
5 changes: 5 additions & 0 deletions bazel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ config_setting(
values = {"compilation_mode": "dbg"},
)

config_setting(
name = "asan_build",
values = {"define": "ENVOY_CONFIG_ASAN=1"},
)

config_setting(
name = "coverage_build",
values = {"define": "ENVOY_CONFIG_COVERAGE=1"},
Expand Down
7 changes: 7 additions & 0 deletions bazel/foreign_cc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ cc_library(
configure_make(
name = "luajit",
configure_command = "build.py",
configure_env_vars = select({
# This shouldn't be needed! See
# https://github.com/bazelbuild/rules_foreign_cc/issues/154#issuecomment-470704365
# TODO(htuch): Remove when the rules_foreign_cc issue is fixed
"//bazel:asan_build": {"ENVOY_CONFIG_ASAN": "1"},
"//conditions:default": {},
}),
lib_source = "@com_github_luajit_luajit//:all",
make_commands = [],
static_libraries = [
Expand Down
11 changes: 9 additions & 2 deletions bazel/foreign_cc/luajit.patch
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ new file mode 100755
index 0000000..9c71271
--- /dev/null
+++ b/build.py
@@ -0,0 +1,28 @@
@@ -0,0 +1,35 @@
+#!/usr/bin/env python
+
+import argparse
Expand All @@ -73,7 +73,14 @@ index 0000000..9c71271
+ # fail on it.
+ os.environ["LSAN_OPTIONS"] = "exitcode=0"
+
+ os.system('make V=1 PREFIX="{}" install'.format(args.prefix))
+ # Blacklist LuaJIT from ASAN for now.
+ # TODO(htuch): Remove this when https://github.com/envoyproxy/envoy/issues/6084 is resolved.
+ if "ENVOY_CONFIG_ASAN" in os.environ:
+ os.environ["TARGET_CFLAGS"] += " -fsanitize-blacklist=%s/com_github_luajit_luajit/clang-asan-blacklist.txt" % os.environ["PWD"]
+ with open("clang-asan-blacklist.txt", "w") as f:
+ f.write("fun:lj_*\nfun:bcread_*\n")
+
+ os.system('make V=1 PREFIX="{}" XCFLAGS=-DLUAJIT_ENABLE_GC64 install'.format(args.prefix))
+
+main()
+