bazel: upgrade liburing to 2.14#29955
Conversation
There was a problem hiding this comment.
Pull request overview
This PR upgrades the Bazel BCR liburing dependency from 2.5 to 2.14 and applies a temporary patch to the upstream BCR build definition to avoid in-source build assumptions (to work around known out-of-source build issues).
Changes:
- Bump
liburingBazel module version to2.14and apply a local patch viasingle_version_override. - Add a
liburingBUILD patch to runconfigurewithout changing CWD (symlink-based out-of-source workaround) and to avoid relying onrealpath. - Refresh
MODULE.bazel.lockto reflect the new module versions/resolution.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| bazel/thirdparty/liburing.patch | Adjusts upstream module’s BUILD.bazel to work around out-of-source build issues and propagate Bazel C/C++ flags into configure. |
| MODULE.bazel | Upgrades liburing to 2.14 and applies the patch using single_version_override. |
| MODULE.bazel.lock | Updates resolved module metadata/hashes for the new dependency graph. |
travisdowns
left a comment
There was a problem hiding this comment.
Some notes for reviewers on the test.bzl changes.
| return select({ | ||
| "//bazel:io_uring_enabled": ["--reactor-backend=io_uring"], | ||
| "//conditions:default": [], | ||
| }) |
There was a problem hiding this comment.
This is extracted into its own function because it's used in two places: _redpanda_cc_test (unit tests) and redpanda_cc_bench (benchmark smoke tests). Both are Seastar-based and accept --reactor-backend.
|
|
||
| test_data, test_env = _test_options() | ||
| cc_test( | ||
| name = name, |
There was a problem hiding this comment.
This must go here (after line 155) and not earlier because select() returns a Starlark select type that is not iterable or mutable. The code above iterates args in _has_flags() (line 140-142), calls args.append() (lines 145-146), and checks if args truthiness (line 154) — all of which require a plain list. Once we concatenate the select(), the result can only be passed to a rule attribute.
| ) | ||
|
|
||
| args = ["$(rootpath :{})".format(binary_name)] + args | ||
| args = ["$(rootpath :{})".format(binary_name)] + args + _reactor_args() |
There was a problem hiding this comment.
For benchmarks, the reactor arg is concatenated into args here so it flows through to both the py_binary (the actual benchmark runner, line 496) and the py_test smoke test (line 509, via test_args which is derived from args on line 505). The select() + list concatenation chains work fine in Starlark as long as the final value lands in a rule attribute.
|
Why don't we enable it unconditionally? Isn't that what we do in cmake land? That's why we have the seastar patch to change order. |
travisdowns
left a comment
There was a problem hiding this comment.
Reviewer notes for the liburing patch.
| "src/include/liburing/io_uring_version.h", | ||
| ], | ||
| cmd = """ | ||
| - export CC=$(CC) CXX=$(CC)++ |
There was a problem hiding this comment.
We now pass CFLAGS="$(CC_FLAGS)" so that the configure step picks up the sysroot and target flags from the Bazel toolchain. Without this, configure's feature-detection probes compile against the host system headers instead of the hermetic toolchain, which can produce wrong results (e.g. detecting __kernel_timespec or open_how incorrectly).
| + # We do an out-of-source build of liburing here, so that | ||
| + # CWD does not change and CC and other relative paths work | ||
| + # (e.g. those embedded in sysroot). Currently, liburing | ||
| + # doesn't support out of source builds, so we fake it |
There was a problem hiding this comment.
This is the core of the patch. The upstream BCR BUILD.bazel does pushd into the package directory to run configure, which changes CWD away from the execroot. That breaks CC because Bazel's CC wrapper path is relative to the execroot, not the package dir.
Instead we do an out-of-source build: stay in the execroot (so CC works) and symlink the two files that configure expects to find in CWD (Makefile.common and liburing.spec). This is a workaround until upstream liburing supports out-of-source builds properly (axboe/liburing#1558).
| + mkdir -p src/include/liburing | ||
| + $$pkg_dir/configure --use-libc | ||
|
|
||
| # collect the outputs |
There was a problem hiding this comment.
The upstream patch used realpath --relative-to=$(BINDIR) to copy generated headers from the package dir back to the output locations. That doesn't work with our out-of-source layout since the generated files are now in the execroot, not the package dir. ${out#$(RULEDIR)/} strips the output-dir prefix to get the relative path of each generated file, which is already correct relative to CWD.
| done | ||
| """, | ||
| - toolchains = ["@bazel_tools//tools/cpp:current_cc_toolchain"], | ||
| + toolchains = [ |
There was a problem hiding this comment.
Adding @bazel_tools//tools/cpp:cc_flags makes $(CC_FLAGS) available in the genrule cmd. This is the standard Bazel mechanism for propagating toolchain flags (like --sysroot) into genrules.
Support is built-in to seastar by default (I think that's what you are asking). See the .bazelrc for comments, LMK if that is unclear. |
Oh yes I didn't read the comment to the end. |
Upgrade from 2.5 to 2.14 with a patch to work around out-of-source build issues (bazelbuild/bazel-central-registry#8079) which itself is hard to fix until BCR picks up axboe/liburing#1558.
Add a bool_flag //bazel:io_uring (default false) that passes --reactor-backend=io_uring to all unit tests and benchmarks when enabled. Usage: bazel test //... --config=io_uring
14fce50 to
70738a2
Compare
|
70738a2 is rebase to fix build conflict |
CI test resultstest results on build#82342
|
https://redpandadata.slack.com/archives/C07HD9U0EHL/p1775011039916519 |
Upgrade liburing from 2.5 to 2.14. Includes a patch to work around
out-of-source build issues (bazelbuild/bazel-central-registry#8079)
until we can pick up the upstream fix (axboe/liburing#1558).
We don't currently use liburing, so this is a no-op upgrade to stay
current.
I ran all unit tests with uring (see other commit) and had no new failures (one test failed even w/o io_uring, I think disk cache corruption).
Backports Required
Release Notes