1 load("@bazel_skylib//lib:selects.bzl", "selects")
3 load("@rules_cc//cc:defs.bzl", "cc_test")
4 package(default_visibility = ["//visibility:public"])
8 exports_files(["LICENSE"])
12 name = "compiler_clang",
13 flag_values = {"@bazel_tools//tools/cpp:compiler": "clang"},
17 name = "compiler_msvc",
18 flag_values = {"@bazel_tools//tools/cpp:compiler": "msvc"},
22 name = "compiler_emscripten",
23 values = {"cpu": "wasm32"},
26 # See https://github.com/bazelbuild/bazel/issues/12707
28 name = "compiler_gcc_bug",
30 "@bazel_tools//tools/cpp:compiler": "compiler",
35 name = "compiler_gcc_actual",
37 "@bazel_tools//tools/cpp:compiler": "gcc",
41 selects.config_setting_group(
42 name = "compiler_gcc",
45 ":compiler_gcc_actual",
49 # Additional warnings for Clang OR GCC (skip for MSVC)
57 # Additional warnings only supported by Clang
59 "-Wfloat-overflow-conversion",
60 "-Wfloat-zero-conversion",
61 "-Wfor-loop-analysis",
62 "-Wgnu-redeclared-enum",
63 "-Winfinite-recursion",
64 "-Wliteral-conversion",
66 "-Wno-unused-command-line-argument",
69 "-Wstring-conversion",
70 "-Wtautological-overlap-compare",
71 "-Wthread-safety-analysis",
72 "-Wundefined-func-template",
73 "-Wunused-comparison",
78 ":compiler_gcc": CLANG_GCC_COPTS,
79 # Default to clang because compiler detection only works in Bazel
80 "//conditions:default": CLANG_GCC_COPTS + CLANG_ONLY_COPTS,
82 "@platforms//cpu:riscv64": [
84 "-menable-experimental-extensions",
86 "//conditions:default": [
90 # Unused on Bazel builds, where this is not defined/known; Copybara replaces
91 # usages with an empty list.
93 "//buildenv/target:non_prod", # includes mobile/vendor.
96 # WARNING: changing flags such as HWY_DISABLED_TARGETS may break users without
97 # failing integration tests, if the machine running tests does not support the
98 # newly enabled instruction set, or the failure is only caught by sanitizers
99 # which do not run in CI.
104 "hwy/aligned_allocator.cc",
107 # Normal headers with include guards
109 "hwy/aligned_allocator.h",
111 "hwy/cache_control.h",
112 "hwy/detect_compiler_arch.h", # private
113 "hwy/highway_export.h",
115 compatible_with = [],
118 # These are textual because config macros influence them:
119 "hwy/detect_targets.h", # private
122 "hwy/highway.h", # public
123 "hwy/foreach_target.h", # public
124 "hwy/ops/arm_neon-inl.h",
125 "hwy/ops/arm_sve-inl.h",
126 "hwy/ops/generic_ops-inl.h",
127 "hwy/ops/scalar-inl.h",
128 "hwy/ops/set_macros-inl.h",
129 "hwy/ops/shared-inl.h",
130 "hwy/ops/x86_128-inl.h",
131 "hwy/ops/x86_256-inl.h",
132 "hwy/ops/x86_512-inl.h",
133 # Select avoids recompiling native arch if only non-native changed
135 ":compiler_emscripten": ["hwy/ops/wasm_128-inl.h"],
136 "//conditions:default": [],
138 "@platforms//cpu:riscv64": ["hwy/ops/rvv-inl.h"],
139 "//conditions:default": [],
145 compatible_with = [],
147 "hwy/contrib/dot/dot-inl.h",
157 "hwy/contrib/image/image.cc",
160 "hwy/contrib/image/image.h",
162 compatible_with = [],
170 compatible_with = [],
172 "hwy/contrib/math/math-inl.h",
179 # Everything required for tests that use Highway.
181 name = "hwy_test_util",
182 srcs = ["hwy/tests/test_util.cc"],
183 hdrs = ["hwy/tests/test_util.h"],
185 "hwy/tests/test_util-inl.h",
186 "hwy/tests/hwy_gtest.h",
188 # Must not depend on a gtest variant, which can conflict with the
189 # GUNIT_INTERNAL_BUILD_MODE defined by the test.
196 name = "nanobenchmark",
197 srcs = ["hwy/nanobenchmark.cc"],
198 hdrs = ["hwy/nanobenchmark.h"],
204 srcs = ["hwy/examples/benchmark.cc"],
213 srcs = ["hwy/examples/skeleton.cc"],
214 hdrs = ["hwy/examples/skeleton.h"],
215 textual_hdrs = ["hwy/examples/skeleton-inl.h"],
222 name = "list_targets",
223 srcs = ["hwy/tests/list_targets.cc"],
229 ("hwy/contrib/dot/", "dot_test"),
230 ("hwy/contrib/image/", "image_test"),
231 ("hwy/contrib/math/", "math_test"),
232 # contrib/sort has its own BUILD, we add it to GUITAR_TESTS.
233 ("hwy/examples/", "skeleton_test"),
234 ("hwy/", "nanobenchmark_test"),
235 ("hwy/", "aligned_allocator_test"),
236 ("hwy/", "base_test"),
237 ("hwy/", "highway_test"),
238 ("hwy/", "targets_test"),
239 ("hwy/tests/", "arithmetic_test"),
240 ("hwy/tests/", "blockwise_test"),
241 ("hwy/tests/", "combine_test"),
242 ("hwy/tests/", "compare_test"),
243 ("hwy/tests/", "convert_test"),
244 ("hwy/tests/", "crypto_test"),
245 ("hwy/tests/", "demote_test"),
246 ("hwy/tests/", "logical_test"),
247 ("hwy/tests/", "mask_test"),
248 ("hwy/tests/", "memory_test"),
249 ("hwy/tests/", "shift_test"),
250 ("hwy/tests/", "swizzle_test"),
251 ("hwy/tests/", "test_util_test"),
262 "//hwy/contrib/sort:vqsort",
263 "@com_google_googletest//:gtest_main",
271 timeout = "long", # default moderate is not enough for math_test
273 subdir + test + ".cc",
276 # gTest triggers this warning (which is enabled by the
277 # extra-semi in COPTS), so we need to disable it here,
278 # but it's still enabled for :hwy.
279 "-Wno-c++98-compat-extra-semi",
282 "@platforms//cpu:riscv64": ["fully_static_link"],
283 "//conditions:default": [],
286 ":compiler_emscripten": [
288 "-s ENVIRONMENT=node,shell,web",
289 "-s ERROR_ON_UNDEFINED_SYMBOLS=1",
290 "-s DEMANGLE_SUPPORT=1",
292 "-s ALLOW_MEMORY_GROWTH=1",
293 "--pre-js $(location :preamble.js.lds)",
295 "//conditions:default": [],
297 linkstatic = select({
298 "@platforms//cpu:riscv64": True,
299 "//conditions:default": False,
301 local_defines = ["HWY_IS_TEST"],
303 tags = ["hwy_ops_test"],
304 deps = HWY_TEST_DEPS + select({
305 ":compiler_emscripten": [":preamble.js.lds"],
306 "//conditions:default": [],
310 for subdir, test in HWY_TESTS
313 # For manually building the tests we define here (:all does not work in --config=msvc)
315 name = "hwy_ops_tests",
316 tags = ["hwy_ops_test"],
319 # Placeholder for integration test, do not remove