Bug 1776680 [wpt PR 34603] - [@container] Test invalidation of font-relative units...
[gecko.git] / third_party / highway / BUILD
blob080c16bd9db8747e3109bd8b5ac5e46f443f2f2a
1 load("@bazel_skylib//lib:selects.bzl", "selects")
3 load("@rules_cc//cc:defs.bzl", "cc_test")
4 package(default_visibility = ["//visibility:public"])
6 licenses(["notice"])
8 exports_files(["LICENSE"])
10 # Detect compiler:
11 config_setting(
12     name = "compiler_clang",
13     flag_values = {"@bazel_tools//tools/cpp:compiler": "clang"},
16 config_setting(
17     name = "compiler_msvc",
18     flag_values = {"@bazel_tools//tools/cpp:compiler": "msvc"},
21 config_setting(
22     name = "compiler_emscripten",
23     values = {"cpu": "wasm32"},
26 # See https://github.com/bazelbuild/bazel/issues/12707
27 config_setting(
28     name = "compiler_gcc_bug",
29     flag_values = {
30         "@bazel_tools//tools/cpp:compiler": "compiler",
31     },
34 config_setting(
35     name = "compiler_gcc_actual",
36     flag_values = {
37         "@bazel_tools//tools/cpp:compiler": "gcc",
38     },
41 selects.config_setting_group(
42     name = "compiler_gcc",
43     match_any = [
44         ":compiler_gcc_bug",
45         ":compiler_gcc_actual",
46     ],
49 # Additional warnings for Clang OR GCC (skip for MSVC)
50 CLANG_GCC_COPTS = [
51     "-Wunused-parameter",
52     "-Wunused-variable",
53     "-Wextra-semi",
54     "-Wunreachable-code",
57 # Additional warnings only supported by Clang
58 CLANG_ONLY_COPTS = [
59     "-Wfloat-overflow-conversion",
60     "-Wfloat-zero-conversion",
61     "-Wfor-loop-analysis",
62     "-Wgnu-redeclared-enum",
63     "-Winfinite-recursion",
64     "-Wliteral-conversion",
65     "-Wno-c++98-compat",
66     "-Wno-unused-command-line-argument",
67     "-Wprivate-header",
68     "-Wself-assign",
69     "-Wstring-conversion",
70     "-Wtautological-overlap-compare",
71     "-Wthread-safety-analysis",
72     "-Wundefined-func-template",
73     "-Wunused-comparison",
76 COPTS = select({
77     ":compiler_msvc": [],
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,
81 }) + select({
82     "@platforms//cpu:riscv64": [
83         "-march=rv64gcv1p0",
84         "-menable-experimental-extensions",
85     ],
86     "//conditions:default": [
87     ],
90 # Unused on Bazel builds, where this is not defined/known; Copybara replaces
91 # usages with an empty list.
92 COMPAT = [
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.
101 cc_library(
102     name = "hwy",
103     srcs = [
104         "hwy/aligned_allocator.cc",
105         "hwy/targets.cc",
106     ],
107     # Normal headers with include guards
108     hdrs = [
109         "hwy/aligned_allocator.h",
110         "hwy/base.h",
111         "hwy/cache_control.h",
112         "hwy/detect_compiler_arch.h",  # private
113         "hwy/highway_export.h",
114     ],
115     compatible_with = [],
116     copts = COPTS,
117     textual_hdrs = [
118         # These are textual because config macros influence them:
119         "hwy/detect_targets.h",  # private
120         "hwy/targets.h",
121         # End of list
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
134     ] + select({
135         ":compiler_emscripten": ["hwy/ops/wasm_128-inl.h"],
136         "//conditions:default": [],
137     }) + select({
138         "@platforms//cpu:riscv64": ["hwy/ops/rvv-inl.h"],
139         "//conditions:default": [],
140     }),
143 cc_library(
144     name = "dot",
145     compatible_with = [],
146     textual_hdrs = [
147         "hwy/contrib/dot/dot-inl.h",
148     ],
149     deps = [
150         ":hwy",
151     ],
154 cc_library(
155     name = "image",
156     srcs = [
157         "hwy/contrib/image/image.cc",
158     ],
159     hdrs = [
160         "hwy/contrib/image/image.h",
161     ],
162     compatible_with = [],
163     deps = [
164         ":hwy",
165     ],
168 cc_library(
169     name = "math",
170     compatible_with = [],
171     textual_hdrs = [
172         "hwy/contrib/math/math-inl.h",
173     ],
174     deps = [
175         ":hwy",
176     ],
179 # Everything required for tests that use Highway.
180 cc_library(
181     name = "hwy_test_util",
182     srcs = ["hwy/tests/test_util.cc"],
183     hdrs = ["hwy/tests/test_util.h"],
184     textual_hdrs = [
185         "hwy/tests/test_util-inl.h",
186         "hwy/tests/hwy_gtest.h",
187     ],
188     # Must not depend on a gtest variant, which can conflict with the
189     # GUNIT_INTERNAL_BUILD_MODE defined by the test.
190     deps = [
191         ":hwy",
192     ],
195 cc_library(
196     name = "nanobenchmark",
197     srcs = ["hwy/nanobenchmark.cc"],
198     hdrs = ["hwy/nanobenchmark.h"],
199     deps = [":hwy"],
202 cc_binary(
203     name = "benchmark",
204     srcs = ["hwy/examples/benchmark.cc"],
205     deps = [
206         ":hwy",
207         ":nanobenchmark",
208     ],
211 cc_library(
212     name = "skeleton",
213     srcs = ["hwy/examples/skeleton.cc"],
214     hdrs = ["hwy/examples/skeleton.h"],
215     textual_hdrs = ["hwy/examples/skeleton-inl.h"],
216     deps = [
217         ":hwy",
218     ],
221 cc_binary(
222     name = "list_targets",
223     srcs = ["hwy/tests/list_targets.cc"],
224     deps = [":hwy"],
227 # path, name
228 HWY_TESTS = [
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"),
254 HWY_TEST_DEPS = [
255     ":dot",
256     ":hwy",
257     ":hwy_test_util",
258     ":image",
259     ":math",
260     ":nanobenchmark",
261     ":skeleton",
262     "//hwy/contrib/sort:vqsort",
263     "@com_google_googletest//:gtest_main",
267     [
268         cc_test(
269             name = test,
270             size = "medium",
271             timeout = "long",  # default moderate is not enough for math_test
272             srcs = [
273                 subdir + test + ".cc",
274             ],
275             copts = COPTS + [
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",
280             ],
281             features = select({
282                 "@platforms//cpu:riscv64": ["fully_static_link"],
283                 "//conditions:default": [],
284             }),
285             linkopts = select({
286                 ":compiler_emscripten": [
287                     "-s ASSERTIONS=2",
288                     "-s ENVIRONMENT=node,shell,web",
289                     "-s ERROR_ON_UNDEFINED_SYMBOLS=1",
290                     "-s DEMANGLE_SUPPORT=1",
291                     "-s EXIT_RUNTIME=1",
292                     "-s ALLOW_MEMORY_GROWTH=1",
293                     "--pre-js $(location :preamble.js.lds)",
294                 ],
295                 "//conditions:default": [],
296             }),
297             linkstatic = select({
298                 "@platforms//cpu:riscv64": True,
299                 "//conditions:default": False,
300             }),
301             local_defines = ["HWY_IS_TEST"],
302             # for test_suite.
303             tags = ["hwy_ops_test"],
304             deps = HWY_TEST_DEPS + select({
305                 ":compiler_emscripten": [":preamble.js.lds"],
306                 "//conditions:default": [],
307             }),
308         ),
309     ]
310     for subdir, test in HWY_TESTS
313 # For manually building the tests we define here (:all does not work in --config=msvc)
314 test_suite(
315     name = "hwy_ops_tests",
316     tags = ["hwy_ops_test"],
319 # Placeholder for integration test, do not remove