Skip to content

Commit

Permalink
Adopt protobuf's .bazelrc to simplify cross-compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
dibenede committed Jul 12, 2024
1 parent 8afb6eb commit c4fbfe3
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
build --cxxopt=-std=c++17 --host_cxxopt=-std=c++17

build:dbg --compilation_mode=dbg

build:opt --compilation_mode=opt

build:san-common --config=dbg --strip=never --copt=-O0 --copt=-fno-omit-frame-pointer

build:asan --config=san-common --copt=-fsanitize=address --linkopt=-fsanitize=address
# ASAN hits ODR violations with shared linkage due to rules_proto.
build:asan --dynamic_mode=off

build:msan --config=san-common --copt=-fsanitize=memory --linkopt=-fsanitize=memory
build:msan --copt=-fsanitize-memory-track-origins
build:msan --copt=-fsanitize-memory-use-after-dtor
build:msan --action_env=MSAN_OPTIONS=poison_in_dtor=1

build:tsan --config=san-common --copt=-fsanitize=thread --linkopt=-fsanitize=thread

build:ubsan --config=san-common --copt=-fsanitize=undefined --linkopt=-fsanitize=undefined
build:ubsan --action_env=UBSAN_OPTIONS=halt_on_error=1:print_stacktrace=1
# Workaround for the fact that Bazel links with $CC, not $CXX
# https://github.com/bazelbuild/bazel/issues/11122#issuecomment-613746748
build:ubsan --copt=-fno-sanitize=function --copt=-fno-sanitize=vptr

# TODO: migrate all dependencies from WORKSPACE to MODULE.bazel
# https://github.com/protocolbuffers/protobuf/issues/14313
common --noenable_bzlmod

# Important: this flag ensures that we remain compliant with the C++ layering
# check.
build --features=layering_check

common --repo_env=BAZEL_NO_APPLE_CPP_TOOLCHAIN=1

0 comments on commit c4fbfe3

Please sign in to comment.