Skip to content

Commit 3824de7

Browse files
benvanikclaude
andauthored
iree-bazel-* improvements for handling multiple targets + options. (#23330)
iree-bazel-try: - supports --features, useful for --features=thin_lto - workaround for thin_lto + Wno-unused-command-line-argument - --copt and --linkopt in a way that ensures the entire build is configured with the options (prior only the try target was, which was useful in isolated testing but not when benchmarking/etc) - uses a new output base (so features/copt/linkopt don't pollute the normal build, good for concurrent try + build/test) - fixed caching of files passed in by path - fixed files passed in by path to have original source locations iree-bazel-test/build/fuzz: - support multiple targets (`iree-bazel-test //:a //:b`) - this allows multiple fuzzers to run in batched mode iree-bazel-cquery: - added to match iree-bazel-query so we have the pair misc: - `target_compatible_with`/platform `select` support in bazel-to-cmake - fixing benchmark warnings about missing unit - fixed a bug in cc_benchmark dropping extra args on benchmark tests --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent c6ac63e commit 3824de7

17 files changed

Lines changed: 764 additions & 122 deletions

build_tools/bazel/BUILD.bazel

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,20 @@ config_setting(
2828
"iree_is_android": "true",
2929
},
3030
)
31+
32+
# OS platform constraints. Used in select() for platform-specific backend
33+
# selection. bazel_to_cmake maps these to CMAKE_SYSTEM_NAME checks.
34+
config_setting(
35+
name = "iree_is_linux",
36+
constraint_values = ["@platforms//os:linux"],
37+
)
38+
39+
config_setting(
40+
name = "iree_is_macos",
41+
constraint_values = ["@platforms//os:macos"],
42+
)
43+
44+
config_setting(
45+
name = "iree_is_windows",
46+
constraint_values = ["@platforms//os:windows"],
47+
)

build_tools/bazel/cc_binary_benchmark.bzl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
99
It's good to test that benchmarks run, but it's really annoying to run a billion
1010
iterations of them every time you try to run tests. So we create these as
11-
binaries and then invoke them as tests with `--benchmark_min_time=0`.
11+
binaries and then invoke them as tests with `--benchmark_min_time=0s`.
1212
"""
1313

1414
load(":native_binary.bzl", "native_test")
@@ -25,13 +25,14 @@ def cc_binary_benchmark(
2525
testonly = True,
2626
size = "small",
2727
timeout = None,
28+
args = None,
2829
**kwargs):
2930
"""Creates a binary and a test for a cc benchmark target.
3031
3132
Arguments passed to the binary target:
3233
name, srcs, data, deps, copts, defines, linkopts, tags, testonly, **kwargs
3334
Arguments passed to the test target:
34-
{name}_test, tags, size, timeout, **kwargs
35+
{name}_test, tags, size, timeout, args (merged with --benchmark_min_time=0s), **kwargs
3536
"""
3637
native.cc_binary(
3738
name = name,
@@ -46,12 +47,17 @@ def cc_binary_benchmark(
4647
**kwargs
4748
)
4849

50+
# Merge args: enforced flag first, then user args.
51+
test_args = ["--benchmark_min_time=0s"]
52+
if args:
53+
test_args = test_args + args
54+
4955
native_test(
5056
name = "{}_test".format(name),
5157
src = name,
5258
size = size,
5359
tags = tags,
5460
timeout = timeout,
55-
args = ["--benchmark_min_time=0"],
61+
args = test_args,
5662
**kwargs
5763
)

build_tools/bazel/iree.bazelrc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,15 @@ build --flag_alias=iree_enable_runtime_tracing=//runtime/src/iree/base/tracing:t
5757
#
5858
# Combines several optimizations for faster local iteration:
5959
# - Skymeld (merged analysis/execution for faster multi-target builds)
60-
# - Ramdisk sandbox on Linux (reduces I/O bottleneck with many cores)
6160
#
62-
# Note: Disk cache is configured in user.bazelrc (created by iree-bazel-configure).
61+
# Note: Disk cache and platform-specific settings (e.g., Linux ramdisk sandbox)
62+
# are configured in user.bazelrc (created by iree-bazel-configure).
6363
###############################################################################
6464

65-
build:localdev --experimental_merged_skyframe_analysis_execution
65+
# Default (allows --config=localdev for consistency).
66+
query:localdev --output=label
6667

67-
# Linux: use ramdisk for sandbox to reduce I/O with many cores.
68-
# This is a no-op on other platforms.
69-
build:localdev --sandbox_base=/dev/shm
68+
build:localdev --experimental_merged_skyframe_analysis_execution
7069

7170
###############################################################################
7271
# Options for "generic_gcc" builds

0 commit comments

Comments
 (0)