Skip to content

bazel: Fix some DEBUG warnings#30364

Open
StephanDollberg wants to merge 3 commits into
devfrom
stephan/fix-bazel-warning
Open

bazel: Fix some DEBUG warnings#30364
StephanDollberg wants to merge 3 commits into
devfrom
stephan/fix-bazel-warning

Conversation

@StephanDollberg
Copy link
Copy Markdown
Member

Fixes:

DEBUG: /home/stephan/.cache/bazel/_bazel_stephan/3b3b4dc7de34ad57d2c1628a343bd876/external/toolchains_llvm+/toolchain/internal/system_module_map.bzl:88:18: WARNING: Sysroot @@toolchains_llvm++llvm+current_llvm_toolchain//:sysroot-components-x86_64-linux resolved to 1689 files. Consider using the `sysroot` repository rule in @toolchains_llvm//toolchain:sysroot.bzl which provides a single-file (directory) sysroot for more efficient builds.

which appeared after some changes in bazel 9.

Stop exposing every single file in the sysroot. Instead expose a sysroot rule which supposedly is better for caching performance etc.

Backports Required

  • none - not a bug fix
  • none - this is a backport
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v26.1.x
  • v25.3.x
  • v25.2.x

Release Notes

  • none

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates Redpanda’s Bazel toolchain sysroot wiring to avoid Bazel 9 DEBUG warnings and reduce the number of individual sysroot files exposed to the build graph (improving caching/performance characteristics).

Changes:

  • Removes per-file sysroot exposure via http_archive + filegroup(glob(["*/**"])) from the non-module dependency repository setup.
  • Adds @toolchains_llvm//toolchain:sysroot.bzl sysroot repository rule instances for x86_64 and aarch64 (with exclude_patterns workarounds).
  • Updates llvm.sysroot(...) labels to reference the sysroot rule’s exported target.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.

File Description
bazel/repositories.bzl Removes the previous http_archive-based sysroot repos that exposed all sysroot files individually.
MODULE.bazel Defines sysroot repos via toolchains_llvm’s sysroot repo rule and updates toolchain sysroot labels accordingly.
MODULE.bazel.lock Updates extension digest and removes generated repo specs for the old sysroot repos.

@StephanDollberg StephanDollberg force-pushed the stephan/fix-bazel-warning branch from 3c66189 to 2f12ed9 Compare May 1, 2026 18:06
@StephanDollberg StephanDollberg changed the title bazel: Fix some DEBUG warnings [WIP] bazel: Fix some DEBUG warnings May 4, 2026
@StephanDollberg StephanDollberg force-pushed the stephan/fix-bazel-warning branch 2 times, most recently from 0990f57 to 9649920 Compare May 4, 2026 12:22
@StephanDollberg StephanDollberg changed the title [WIP] bazel: Fix some DEBUG warnings bazel: Fix some DEBUG warnings May 4, 2026
@vbotbuildovich
Copy link
Copy Markdown
Collaborator

CI test results

test results on build#83986
test_status test_class test_method test_arguments test_kind job_url passed reason test_history
FAIL src/v/cloud_topics/level_one/domain/tests/db_domain_manager_test src/v/cloud_topics/level_one/domain/tests/db_domain_manager_test unit https://buildkite.com/redpanda/redpanda/builds/83986#019df2f0-e6c2-43e4-9df0-15bd923470f8 0/1

dotnwat
dotnwat previously approved these changes May 4, 2026
Copy link
Copy Markdown
Member

@dotnwat dotnwat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no red flags from me

bazel: Strip symlinks from sysroot

on the first commit i'm confused why the broken symlinks aren't causing havoc in everyone's build since presumably we all would be accessing the same files when building?

Consider using the sysroot repository rule in @toolchains_llvm//toolchain:sysroot.bzl which provides a single-file (directory) sysroot for more efficient builds.

to clarify, the second commit is effectively duplicating that referenced repository rule with our own flavor?

Comment thread MODULE.bazel
llvm.sysroot(
name = "{version}_llvm_toolchain".format(version = major_version),
label = "@x86_64_sysroot//:sysroot",
label = "@x86_64_sysroot//sysroot:sysroot",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh, i thought this was strictly an short hand / alias thing

Comment thread bazel/toolchain/Dockerfile.sysroot Outdated
Comment thread bazel/sysroot.bzl
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error says:

system_module_map.bzl:88:18: WARNING: Sysroot @@toolchains_llvm++llvm+current_llvm_toolchain//:sysroot-components-x86_64-linux resolved to 1689 files. Consider using the `sysroot` repository rule in @toolchains_llvm//toolchain:sysroot.bzl which provides a single-file (directory) sysroot for more efficient builds.

which suggests using that existing @toolchains_llvm//toolchain:sysroot.bzl rule, but we created our own here?

That rule does exist and also seems to do that "expose a single dir" thing (for the same reason):

https://github.com/bazel-contrib/toolchains_llvm/blob/master/toolchain/sysroot.bzl

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that's what an earlier version of this PR uses. That works fine to resolve the warning and works at build time but it's not enough for the "patching the loader" step which needs access to all the files by label again.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still looking.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's an alternative to making our own sysroot rule:

#30449

The upside is:

  • We still use the upstream sysroot rule for the "sysroot" part, it's more complicated than our rule, may change in the future. Unsure how important this is. Less code on our end.

One downside is:

  • The sysroot exists 2x on disk (but we only download it once) on machines that build.

WDYT?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I also pursued fixing the packaging itself to just do the per-file stuff that we are doing in .bzl now, but it doesn't work as the ["."] approach doesn't even materialize the files, I guess cc_rules has special logic to make this work for them)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sysroot exists 2x on disk (but we only download it once) on machines that build.

Yeah I had something like this as well. I don't care/mind. Both solutions are equally convoluted.

Copy link
Copy Markdown
Member

@travisdowns travisdowns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some questions

Be explicit about zstd compression level.

Turns out previously we were using -19 for the amd64 tar but default
(-3) for the aarch tar.
Transform absolute symlinks into relative symlinks in our sysroot.
Absolute paths break when not putting the sysroot at / which is what
bazel does. They would point outside the sandbox and hence break the
build.

Bump links to the regenerated sysroot.
Fixes:

```
DEBUG: /home/stephan/.cache/bazel/_bazel_stephan/3b3b4dc7de34ad57d2c1628a343bd876/external/toolchains_llvm+/toolchain/internal/system_module_map.bzl:88:18: WARNING: Sysroot @@toolchains_llvm++llvm+current_llvm_toolchain//:sysroot-components-x86_64-linux resolved to 1689 files. Consider using the `sysroot` repository rule in @toolchains_llvm//toolchain:sysroot.bzl which provides a single-file (directory) sysroot for more efficient builds.
```

which appeared after some changes in bazel 9.

Stop exposing every single file in the sysroot. Instead expose a sysroot
rule which supposedly is better for caching performance etc.

We need separate runtime target which used by the packaging process to
find and replace the loader in the RP binary.
@StephanDollberg StephanDollberg force-pushed the stephan/fix-bazel-warning branch from 9649920 to 72a757d Compare May 5, 2026 09:14
travisdowns added a commit to travisdowns/redpanda that referenced this pull request May 12, 2026
Bazel 9 logs a warning while configuring the cc_toolchain:

    WARNING: Sysroot @@toolchains_llvm++llvm+current_llvm_toolchain//:sysroot-components-x86_64-linux
    resolved to 1689 files. Consider using the `sysroot` repository rule
    in @toolchains_llvm//toolchain:sysroot.bzl which provides a
    single-file (directory) sysroot for more efficient builds.

The current setup downloads each sysroot tarball with `http_archive` and
exposes every file in a `glob(["*/**"])` filegroup. The cc_toolchain
ingests the whole list — 1689 individual files — which is what the
warning is about.

The cc_toolchain only really wants the sysroot as a single
source-directory artifact, which is exactly what
@toolchains_llvm//toolchain:sysroot.bzl produces. But the packaging
rules in //bazel/packaging still need individual file labels for the
glibc dynamic loader (set as the binaries' PT_INTERP via patchelf) and
the versioned shared libraries to ship in install_path/lib. Bazel only
materializes the contents of a `srcs = ["."]` source-directory in the
cc_toolchain's special path, not for arbitrary actions, so a single
filegroup can't serve both consumers.

Use the upstream `sysroot` rule for the cc_toolchain side and pull the
same tarball a second time via `http_archive` with a glob-based BUILD
that exposes the loader and shared libraries as a `:runtime` filegroup
for packaging. The download is sha256-deduped between the two repos,
so the only added cost is one extra extraction per arch on a clean
cache.

The packaging rules now consume `:runtime` via a new `sysroot_runtime`
attribute instead of walking `cc_toolchain.all_files`, since the latter
would only see the single source-directory entry under the upstream
rule. Bump the URLs/sha256 to regenerated tarballs whose absolute
symlinks have been rewritten to relative basename links — bazel rejects
absolute symlinks in directory artifacts and the upstream `sysroot`
rule doesn't rewrite them itself. The Dockerfile change that produces
those regenerated tarballs lives in redpanda-data#30364.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants