-
Notifications
You must be signed in to change notification settings - Fork 7
/
.bazelrc
91 lines (74 loc) · 4.47 KB
/
.bazelrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
try-import %workspace%/ci.bazelrc
# Import Aspect bazelrc presets
import %workspace%/.aspect/bazelrc/bazel6.bazelrc
import %workspace%/.aspect/bazelrc/convenience.bazelrc
import %workspace%/.aspect/bazelrc/correctness.bazelrc
import %workspace%/.aspect/bazelrc/debug.bazelrc
import %workspace%/.aspect/bazelrc/javascript.bazelrc
import %workspace%/.aspect/bazelrc/performance.bazelrc
common --enable_platform_specific_config
# LLD is technically good enough on macOS
# (Chromium is using it: https://github.com/chromium/chromium/blob/main/docs/mac_lld.md)
# but grailbio/bazel-toolchain doesn't support it.
# https://sourcegraph.com/github.com/grailbio/bazel-toolchain@d52ce5d96915428a5ee6f7079078df706c5fddab/-/blob/toolchain/cc_toolchain_config.bzl?L154:11
build:linux --linkopt="-fuse-ld=lld"
# Based on release notes from since we're on Bazel < 7
# https://github.com/bazel-contrib/toolchains_llvm/releases/tag/0.10.3
build --features=-supports_dynamic_linker
build --features=-libtool
# Not sure why setting all of these is necessary, but just setting cxxopt
# Leads to usage of old C++ version when compiling LLVM, which needs C++14 or newer.
build --cxxopt="-std=c++20" --host_cxxopt="-std=c++20" --client_env=BAZEL_CXXOPTS="-std=c++20"
# We're using C++20 to access new methods on string_view
# and operator<=> which simplifies comparisons
# Per grailbio/bazel-toolchain docs
build --incompatible_enable_cc_toolchain_resolution
build --repo_env BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
build --@llvm_zstd//:llvm_enable_zstd=false
build --copt="-Wall" --copt="-Wextra" --copt="-Wwrite-strings" --copt="-Wcast-qual" --copt="-Wmissing-field-initializers" --copt="-Wimplicit-fallthrough" --copt="-Wcovered-switch-default" --copt="-Wsuggest-override" --copt="-Wstring-concatenation" --copt="-Wstring-conversion" --copt="-Wmisleading-indentation"
# For dependencies with .BUILD files in third_party, prefer adding flags there
# instead of here to avoid rebuilding lots of stuff on flag changes.
build --per_file_copt="external/.*@-Wno-cast-qual" # boost and protobuf
build --per_file_copt="external/.*@-Wno-covered-switch-default" # boost and protobuf
build --per_file_copt="external/.*@-Wno-unused-parameter" # LLVM and protobuf
build --per_file_copt="external/.*@-Wno-deprecated-pragma" # ATOMIC_VAR_INIT in LLVM and protobuf
build --per_file_copt="external/llvm-project/.*@-Wno-deprecated-anon-enum-enum-conversion"
build --per_file_copt="external/llvm-project/.*@-Wno-ambiguous-reversed-operator" # C++20 warning
build --per_file_copt="external/com_google_protobuf/.*@-Wno-deprecated-declarations" # sprintf on macOS
build --per_file_copt="external/com_google_protobuf/.*@-Wno-unused-function"
build:asserts --copt="-DFORCE_DEBUG=1"
build:asserts --copt="-DLLVM_ENABLE_ASSERTIONS=1"
build:stacktraces --strip=never
build:stacktraces --copt="-gline-tables-only" --copt="-fno-omit-frame-pointer"
build:asan --define="asan=true"
build:asan --copt="-fsanitize=address" --linkopt="-fsanitize=address"
# Forcibly set -fno-sanitize-ignorelist because trying to
# build Abseil with ASan and Clang/LLVM 15.0.6 leads to a
# build failure.
#
# this rule is missing dependency declarations for the following files included by 'absl/types/bad_variant_access.cc':
# 'external/llvm_toolchain_llvm/lib/clang/15.0.6/share/asan_ignorelist.txt'
build:asan --copt="-fno-sanitize-ignorelist"
build:asan --copt="-DADDRESS_SANITIZER" # for Abseil, per Sorbet
# ASan uses #define _FORTIFY_SOURCE 0 but Bazel passes
# -D_FORTIFY_SOURCE=1 by default. This is fixed by
# https://github.com/bazelbuild/bazel/pull/12772
# but I can't figure out how to use that, so hack it in for now.
build:asan --copt="-Wno-macro-redefined"
build:asan --//:link_asan_runtime=1
# The --no-sanitizer=vptr,function is in line with LLVM"s default UBSan flags.
# https://sourcegraph.com/github.com/llvm/llvm-project@abf399737ea8bf6a6af4d66fc21a250a5dc76b6d/-/blob/llvm/CMakeLists.txt?L640&subtree=true
build:ubsan --copt="-fsanitize=undefined" --copt="-fno-sanitize=vptr,function" --copt="-fno-sanitize-recover=all"
build:ci --config=asserts
build:ci --config=stacktraces
build:ci --config=asan
build:ci --config=ubsan
build:dev --config=ci
build:dev --copt="-Og" # For testing against large projects locally
build:release -c opt
# Temporarily to smoke out issues on large codebases...
build:release --copt="-DFORCE_DEBUG=1"
build:release --copt="-O2"
build:release --config=stacktraces
build:release-linux --config=release --config=linux
build:release-linux --cxxopt="-flto=thin" --linkopt="-flto=thin"