-
Notifications
You must be signed in to change notification settings - Fork 207
Expand file tree
/
Copy pathBLADE_ROOT
More file actions
220 lines (214 loc) · 9.9 KB
/
Copy pathBLADE_ROOT
File metadata and controls
220 lines (214 loc) · 9.9 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
global_config(
duplicated_source_action='error',
# Per-test wall timeout for normal hardware. Slower runners scale up via
# the `--test-timeout-multiplier` CLI flag (see .github/workflows/...).
# Profiled on M2 (release/-O2): the slowest tests today are CPU-heavy
# ones around 30-40s, all already exclusive=True so they don't fight
# for cores. 60s gives ~50% headroom over the slowest legit test;
# anything blowing past that is almost certainly hung.
test_timeout=60, # In seconds
glob_error_severity='error',
legacy_public_targets=load_value('build/blade/legacy_public_targets.conf'),
)
cc_test_config(
# `initial-exec` TLS does not work quite well on ppc64le if dynamic linking
# is used.
dynamic_link=lambda blade: not blade.build_type_is_debug()
and blade.cc_toolchain.target_arch != 'ppc64le',
# Doesn't work quite right on AArch64. (It does work on ppc64le, though.)
#
# Stacktrace suggests that it's related to global initialization order
# fiasco.
heap_check=lambda blade: (
'strict' if blade.cc_toolchain.target_arch != 'aarch64' else ''
),
gperftools_libs='thirdparty/gperftools:tcmalloc',
# On macOS pthread is part of libSystem and auto-linked; '#pthread' here
# would produce "ld: warning: ignoring duplicate libraries: '-lpthread'"
# on every cc_test. Restrict to Linux.
gtest_libs=lambda blade: ['thirdparty/googletest:gtest'] + (
['#pthread'] if blade.cc_toolchain.target_os == 'linux' else []),
gtest_main_libs=['thirdparty/googletest:gtest_main'],
pprof_path='thirdparty/gperftools/bin/pprof',
)
cc_config(
cppflags=lambda blade: [
'-gdwarf-2',
'-mcx16' if blade.cc_toolchain.target_arch == 'x86_64' else '',
'-fno-var-tracking',
'-gno-column-info',
# vcpkg's glog 0.7 headers require consumers to opt into the export
# macros (CMake config does this automatically; we consume headers
# directly). Defining it pulls in <glog/export.h> so the header's
# "included correctly" guard passes. Harmless for non-glog TUs.
'-DGLOG_USE_GLOG_EXPORT',
],
cflags='-std=gnu11',
cxxflags=lambda blade: [
'-std=gnu++2a',
# This option must be applied here. Options applied in `warnings` are
# not applied to generated source files (e.g., those generated by
# `protoc`.). In practice, `-Wpsabi` produces some diagnostics when
# compiling `.pb.cc` on ppc64le, this option suppress those diagnostics.
'-Wno-psabi' if blade.cc_toolchain.target_arch == 'ppc64le' else '',
],
# NOTE: Please keep all warnings in order in one same group.
warnings=[
'-Werror',
'-Wall',
'-Wextra',
# other useful warnings
'-Warray-bounds',
'-Wchar-subscripts',
'-Wcomment',
'-Wendif-labels',
'-Wformat',
# '-Wframe-larger-than=69632', # A 64k buffer and other small vars
'-Wmissing-include-dirs',
'-Wmultichar',
'-Wparentheses',
'-Wpointer-arith',
'-Wreturn-type',
'-Wsequence-point',
'-Wswitch',
'-Wunused-function',
'-Wunused-label',
'-Wunused-result',
'-Wunused-value',
'-Wwrite-strings',
# Suppress all warnings which we can't handle or are misreported.
# Even if some them are sure useful, too many warnings also overwhelm
# the true problems.
'-Wno-format-truncation',
'-Wno-float-equal',
# '-Wno-incompatible-pointer-types',
# Causes too many 'note's when it is disabled due to the size of the code
'-Wno-misleading-indentation',
'-Wno-missing-field-initializers',
'-Wno-sign-compare',
'-Wno-strict-aliasing',
'-Wno-unused-but-set-variable',
'-Wno-unused-local-typedefs',
'-Wno-unused-parameter',
],
# C++ only warning flags
cxx_warnings=[
'-Wnon-virtual-dtor',
'-Woverloaded-virtual',
# Suppress all warnings which we can't handle or are misreported.
'-Wno-deprecated',
'-Wno-invalid-offsetof',
],
extra_incs=lambda blade: [
# for all thirdparty packages
'thirdparty/',
'%s/thirdparty/' % blade.workspace.build_dir,
],
linkflags=(
lambda blade: [
# We need this in some platforms for `link_all_symbols=True` to work.
'-Wl,--no-as-needed',
'-lpthread',
]
if blade.cc_toolchain.target_os == 'linux'
else []
),
benchmark_libs=['//thirdparty/benchmark:benchmark'],
benchmark_main_libs=['//thirdparty/benchmark:benchmark_main'],
allowed_undeclared_hdrs=load_value('build/blade/allowed_undeclared_hdrs.conf'),
# header_inclusion_dependencies = True,
# TODO: (chen3feng): Upgrade to error in the future.
# I have to suppress these checks in the mac port changes due to the blade
# improvement triggered too much new reports.
hdr_dep_missing_severity='notice',
unused_deps_severity='notice',
)
cc_binary_config(
run_lib_paths=['//thirdparty/jdk/lib'],
)
cc_library_config(
generate_dynamic=True,
deterministic=True,
thin=lambda blade: blade.cc_toolchain.target_os == 'linux',
prebuilt_libpath_pattern='lib${bits}',
hdrs_missing_severity='error',
hdrs_missing_suppress=load_value('build/blade/hdrs_missing_suppress.conf'),
)
proto_library_config(
# protoc + libprotobuf from vcpkg (pinned to 3.21.12, the last abseil-free
# protobuf). vcpkg#protobuf resolves to the protoc blade installs, so the
# generated code matches the linked runtime.
protoc='vcpkg#protobuf',
protobuf_libs=['vcpkg#protobuf:protobuf'],
protobuf_path='',
protobuf_incs=[],
protoc_direct_dependencies=True,
# well_known_protos left empty: blade auto-discovers the google/protobuf/*
# protos from the vcpkg#protobuf include tree (blade-build#1339), so the list
# stays correct across protobuf versions without hand-maintenance here.
well_known_protos=[],
)
# vcpkg-provided third-party libraries (issue blade-build#1236). Hands-on
# migration of thirdparty/ libs to vcpkg; consumers keep using //thirdparty/X:Y
# (those BUILD files are thin wrappers over vcpkg#port:lib). Versions are pinned
# to match the previously vendored sources.
vcpkg_config(
baseline = '06a7fdd564234908731c59ac46a624f808e87b1c',
# root is intentionally unset: blade reads $VCPKG_ROOT, else finds `vcpkg` on
# PATH (CI relies on the runner's preinstalled vcpkg). Don't hardcode a path.
# linkage defaults to 'auto' (static for static-link consumers, shared on
# demand for dynamic-link ones), so process-global singletons -- protobuf's
# descriptor pool, the gflags/glog/gtest registries -- resolve to one shared
# instance across all dylibs with no annotation. Only non-default choices are
# called out below; see doc/*/build_rules/vcpkg.md for the linkage rules.
packages = {
# 3.21.12: the last protobuf before v22 made Abseil a hard dependency;
# flare predates the descriptor name()->string_view change (v23+).
'protobuf': {'version': '3.21.12'},
'fmt': '7.1.3',
# link_all_symbols: the static-link protoc plugins (dynamic_link=False)
# whole-archive the .a so gflags/glog's flag-registration static
# initializers run even when unreferenced.
'gflags': {'version': '2.2.2', 'link_all_symbols': True},
# GFLAGS_NOTHREADS=OFF dodges gflags-config.cmake's static-target template
# bug (glog's find_package(gflags) would ask for gflags_nothreads_static).
'glog': {'version': '0.7.1', 'link_all_symbols': True,
'cmake_options': ['-DGFLAGS_NOTHREADS=OFF']},
# include_prefix: flare includes these as "<lib>/<header>", but vcpkg
# ships their headers at the include/ top level.
'zlib': {'include_prefix': 'zlib'},
'lz4': {'include_prefix': 'lz4'},
'zstd': {'include_prefix': 'zstd'},
# snappy also needs RTTI on -- vcpkg forces -fno-rtti, but flare uses RTTI
# on snappy::Sink/Source.
'snappy': {'include_prefix': 'snappy',
'cmake_options': ['-DSNAPPY_WITH_RTTI=ON']},
'xxhash': {'include_prefix': 'xxhash'},
# link_all_symbols: consumers need yaml-cpp's symbols whole-archived in.
'yaml-cpp': {'link_all_symbols': True},
# 1.7.1: 1.8.0 deprecated DoNotOptimize(const&), which flare's
# *_benchmark.cc use under gcc -Werror=deprecated-declarations.
# linkage='static': google/benchmark has no shared build and needs none
# (each *_benchmark exe links it once); the default 'auto' would fail
# trying to build it shared.
'benchmark': {'version': '1.7.1', 'linkage': 'static'},
# vcpkg port name is `gtest`; 1.17.0 matches the previously vendored source.
'gtest': {'version': '1.17.0'},
# The curl cluster (#179). vcpkg has no openssl 1.1.1, so this upgrades to
# 3.x; flare's crypto/init code is adapted (io/util/openssl.cc drops the
# obsolete 1.0.x init/threading/ENGINE ceremony -- auto-init + thread-safe
# since 1.1; base/crypto's low-level MD5/SHA/HMAC compile with
# -Wno-deprecated-declarations, still valid until OpenSSL 4.0). All three
# use vcpkg's native include/<lib>/ layout (no include_prefix).
'openssl': {},
'nghttp2': {},
# curl: openssl TLS + nghttp2 http2 (zlib auto-detected from the install).
'curl': {'features': ['openssl', 'http2']},
# opentelemetry-cpp API for distributed tracing (replaces the vendored
# opentracing-cpp). Default features only -> no exporters, so no
# protobuf/grpc pulled in (keeps the abseil-free protobuf 3.21.12 pin
# intact). It pulls abseil + nlohmann-json, which coexist fine. flare
# consumes only the header-only `opentelemetry_api` target.
'opentelemetry-cpp': {},
},
)