blob: 301b564986748f91a9fe9898529a3b56d60e07f9 [file]
# bazel < 7 needs explicit enabling of bzlmod dependencies.
build --enable_bzlmod
# Enable support for absl types like string_view in gtest.
build --define="absl=1"
build --enable_platform_specific_config
# Gather build version information
build --workspace_status_command="bash bazel/build-version.sh"
# Systems with gcc or clang
common:unix --cxxopt=-xc++ --host_cxxopt=-xc++
common:unix --cxxopt=-std=c++20 --host_cxxopt=-std=c++20
common:linux --config=unix
common:freebsd --config=unix --linkopt=-lm --host_linkopt=-lm
common:openbsd --config=unix --linkopt=-lm --host_linkopt=-lm
common:macos --config=unix
# Applies to both clang-cl and native MSVC builds.
common:windows --cxxopt=/std:c++20 --host_cxxopt=/std:c++20 --client_env=BAZEL_CXXOPTS=/std:c++20
# Actions (e.g. the genrules invoking win_flex.exe/win_bison.exe) need the
# invoking shell's PATH to find tools installed.
common:windows --action_env=PATH --host_action_env=PATH
# Protobuf 31 has [MSVC deprecated](https://github.com/protocolbuffers/protobuf/issues/20085) and need this option to compile
# The deprecation was later reverted thanks to improvements in bazel 8 and will not be necessary with newer protobuf.
common:msvc --define=protobuf_allow_msvc=true
# Opt-in: build with clang-cl instead of the natively autoconfigured MSVC
# with bazel --config=clang-cl
common:clang-cl --extra_toolchains=@local_config_cc//:cc-toolchain-x64_windows-clang-cl --extra_execution_platforms=//:x64_windows-clang-cl
common:clang-cl --compiler=clang-cl
common:unix --cxxopt="-Wno-unknown-warning-option" --host_cxxopt="-Wno-unknown-warning-option"
common:clang-cl --cxxopt="-Wno-unknown-warning-option" --host_cxxopt="-Wno-unknown-warning-option"
# TODO: this looks like benign where it happens but to be explored further.
common:unix --cxxopt="-Wno-dangling-reference" --host_cxxopt="-Wno-dangling-reference"
common:clang-cl --cxxopt="-Wno-dangling-reference" --host_cxxopt="-Wno-dangling-reference"
# Newer bisons create an unused label.
common:unix --cxxopt="-Wno-unused-label" --host_cxxopt="-Wno-unused-label"
common:clang-cl --cxxopt="-Wno-unused-label" --host_cxxopt="-Wno-unused-label"
# c++20 warning on protobuf 28.1
common:unix --cxxopt="-Wno-missing-requires" --host_cxxopt="-Wno-missing-requires"
common:clang-cl --cxxopt="-Wno-missing-requires" --host_cxxopt="-Wno-missing-requires"
# For 3rd party code: Disable warnings entirely.
# They are not actionable and just create noise.
build --per_file_copt=external/.*@-w
build --host_per_file_copt=external/.*@-w
# Address sanitizer settings.
build:asan --strip=never
build:asan --copt -fsanitize=address
build:asan --copt -DADDRESS_SANITIZER
build:asan --copt -O1
build:asan --copt -g
build:asan --copt -fno-omit-frame-pointer
build:asan --linkopt -fsanitize=address
build:create_static_linked_executables --linkopt=-fuse-ld=bfd --features=-supports_start_end_lib --//bazel:create_static_linked_executables
try-import %workspace%/user.bazelrc