common --action_env=BAZEL_CXXOPTS=-std=c++20
common --cxxopt='-std=c++20'
common --copt=-fdiagnostics-color=always
common --test_output=errors
common --test_summary=terse
common --enable_platform_specific_config

# compilation_mode options below are `dbg` (debug symbols) `fastbuild`
# (build as quickly as possible), and `opt` (turn on all optimizations)
common -c dbg
common --enable_bzlmod

# prevents changes to PATH from causing a full rebuild
common --incompatible_strict_action_env

# extra flags for hermetic LLVM toolchain
common --repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
common --repo_env=BAZEL_DO_NOT_DETECT_SWIFT_TOOLCHAIN=1
common --repo_env=BAZEL_NO_APPLE_CPP_TOOLCHAIN=1
common --@rules_python//python/config_settings:bootstrap_impl=script
# Needed to silence hermetic LLVM build warnings, until this is enabled by
# default in bazel 9
startup --host_jvm_args=-DBAZEL_TRACK_SOURCE_DIRECTORIES=1

# BuildBuddy
build --bes_results_url=https://heir.buildbuddy.io/invocation/
build --bes_backend=grpcs://heir.buildbuddy.io
common --noremote_upload_local_results # Uploads logs & artifacts without writing to cache
common --remote_cache=grpcs://heir.buildbuddy.io
common --remote_cache_compression
common --remote_header=x-buildbuddy-api-key=IqGGzfrvMgDJh927qtrw
common --remote_timeout=10m

# This enables remote build execution and writing to the remote cache, which
# dramatically speeds up builds. Add a .bazelrc.user file with:
#
#     common --remote_header=x-buildbuddy-api-key=<YOUR_API_KEY>
#     common --config=remote
#
# Note this requires a buildbuddy.io account and API key. The default
# API key used above is read-only.
common:remote --extra_execution_platforms=@llvm//:rbe_platform
common:remote --jobs=500
common:remote --remote_executor=grpcs://remote.buildbuddy.io

# CI executions are always remote, and have extra build metadata
common:ci --build_metadata=ROLE=CI
common:ci --build_metadata=VISIBILITY=PUBLIC

# Only show warnings for targets defined in HEIR code.
# Warnings for external repos and generated code is (mostly) hidden; see #2616
build --output_filter="^//(benchmark|frontend|lib|tests|tools)/"

# use lld for faster linking
build:linux --linkopt="-fuse-ld=lld"

# This is needed for golang targets with the hermetic build, when a golang
# target links with a C++ lib.
build:linux --linkopt="-Wl,-no-pie"

# macos specific options
# openmp is not supported in apple clang
build:macos --@openfhe//:enable_openmp=False
build:macos --no@fuzztest//fuzztest:use_riegeli

# MacOS arm64 config
build:macos_arm64 --cpu=darwin_arm64
build:macos_arm64 --macos_minimum_os=11.0
# openmp is not supported in apple clang
build:macos_arm64 --@openfhe//:enable_openmp=False

# run with --config=asan to enable
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

try-import %workspace%/fuzztest.bazelrc

# Load any settings specific to the current user.
# .bazelrc.user should appear in .gitignore so that settings are not shared with team members
# This needs to be last statement in this
# config, as the user configuration should be able to overwrite flags from this file.
# See https://docs.bazel.build/versions/master/best-practices.html#bazelrc
try-import %workspace%/.bazelrc.user
