Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
abf10fd
Remove WORKSPACE support (#4005)
UebelAndre May 1, 2026
39efdc4
feat: Add BPF triple constraint mapping (#3696)
tamird May 1, 2026
52c68af
Rearrange link paths on Windows to reduce size overruns and fix errors
dzbarsky Jan 20, 2026
09804e8
Revert "Fix stamping for rules that don't have a stamp attribute (#38…
dzbarsky Feb 7, 2026
8ce8b24
Revert "Switch stamping detection to ctx.configuration.stamp_binaries…
dzbarsky Feb 7, 2026
2c5c1dc
Fix process-wrapper link lib handling when using argfiles
dzbarsky Feb 16, 2026
8594a6b
Rewrite process_wrapper_bootstrap to cc
dzbarsky Feb 18, 2026
c1d2ea9
Attempt to fix CopyFile for windows
dzbarsky Feb 18, 2026
320cb33
Apply lint config in exec configuration (#2)
isaacparker0 Feb 20, 2026
5ed548f
Fix up rules_rust bzl_library targets
dzbarsky Feb 20, 2026
08a7b7d
rust-analyzer: include Bazel package dir in crate source include_dirs…
isaacparker0 Feb 20, 2026
dec54f7
Improve proc_macro_deps ergonomics
dzbarsky Sep 9, 2025
4d74eef
Always use param file for process wrapper
dzbarsky Feb 25, 2026
a37d122
Avoid hashing RustAnalyzerInfo in rust_analyzer alias mapping
dzbarsky Feb 26, 2026
be96cef
Convert wrappers to symbolic macros
dzbarsky Feb 26, 2026
431830a
Handle toolchain registration when not registered as a bazel_dep
dzbarsky Feb 28, 2026
189ca8c
Replace the --rustc-quit-on-rmeta / .rmeta approach with Buck2-style …
walter-zeromatter Feb 26, 2026
5529bac
Cleanup some process_wrapper code
dzbarsky Mar 2, 2026
10b6860
Fix prost to be compatible with multiplatform
dzbarsky Mar 13, 2026
b430aa6
Improve toolchain make var env expansion
dzbarsky Apr 5, 2026
a5ffc2b
Improve rust compilation messages
dzbarsky Apr 9, 2026
59278d6
Add rust_test sharding support (#13)
bolinfest Apr 15, 2026
2e8ce73
Add per-crate rustc flag trimming
dzbarsky Apr 26, 2026
65a2ba7
Fix Windows GNU staticlib output naming
dzbarsky Apr 26, 2026
57ff613
Move processwrapper to rust toolchain
dzbarsky Dec 19, 2025
e8cbbe5
Capture process wrapper exit codes
dzbarsky Apr 26, 2026
a8ef2b7
Provision hermetic SDKROOT
dzbarsky Apr 27, 2026
42d7dcb
Internalize macos SDK dep
dzbarsky Apr 30, 2026
242b2f8
rustdoc_test should not do compilation at test time
dzbarsky May 2, 2026
720725b
Fix CcInfo collection through CrateGroupInfo
dzbarsky May 3, 2026
032a92b
Expose macOS SDK from llvm module
dzbarsky May 3, 2026
70e433b
Loongarch64 and sparc support
dzbarsky May 3, 2026
cb08919
Avoid vendored crates for rust-analyzer binary
dzbarsky Apr 1, 2026
b9f8112
Don't force passing proc_macro_deps via macro
dzbarsky May 4, 2026
01ad0e9
Remove cargo build script rundir support
dzbarsky May 5, 2026
41f1f7e
Shorten cargo build script manifest runfiles paths
dzbarsky May 5, 2026
29488a8
Simplify prost/pyo3 setup
dzbarsky May 5, 2026
5e5da6f
Fix dynamic_runtime_libs support in dylibs
dzbarsky May 5, 2026
977a661
Separate build script data from compile_data (#21)
michaelm-openai May 8, 2026
57a5a70
Add RUSTC_BOOTSTRAP guardrail for -Zno-codegen pipelining (#19)
walter-zeromatter May 8, 2026
ee07b30
Add direct_pyi_files and transitive_pyi_files to py_pyo3_library PyIn…
dillydill123 May 9, 2026
e9213a9
Fix tests
dzbarsky May 9, 2026
90ae586
Add CI configs
dzbarsky May 9, 2026
a2e452f
More CI sanitization
dzbarsky May 10, 2026
c286c5c
Windows runtime lib linkage test expectation fixes
dzbarsky May 11, 2026
77bc22e
Cleanup tool_path arg to construct_arguments
dzbarsky May 11, 2026
1c00622
Include tool runfiles in Rust toolchains
dzbarsky May 11, 2026
ad25433
Generalize captured-output-test-runner
dzbarsky May 12, 2026
9da4630
Expose injectable rustc compile helper
dzbarsky May 12, 2026
000e7bb
Windows build fixes for Bazel ≥ 9.0.1
walter-zeromatter May 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .bazelignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,10 @@ crate_universe/private/bootstrap
crate_universe/tests/integration
docs
examples
extensions
extensions/bindgen
extensions/mdbook
extensions/prost/private/tests
extensions/pyo3/test
extensions/pyo3/tools
extensions/wasm_bindgen
test/integration
16 changes: 16 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@ build:unpretty --output_groups=+rust_unpretty
# https://github.com/rust-lang/rust/issues/43364
build:unpretty --config=nightly

# Use a shared repository cache location. GitHub Actions persists this path
# between runs, and it is also a reasonable local default.
common --repository_cache=~/.cache/bazel-repo
common --repo_contents_cache=~/.cache/bazel-repo/contents

# BuildBuddy remote cache / BES settings used by CI via `--config=remote`.
common:remote --bes_backend=grpcs://remote.buildbuddy.io
common:remote --bes_results_url=https://app.buildbuddy.io/invocation/
common:remote --remote_cache=grpcs://remote.buildbuddy.io
common:remote --remote_cache_compression
common:remote --experimental_remote_downloader=grpcs://remote.buildbuddy.io
common:remote --remote_download_outputs=minimal

# Allows tests that shell out to Bazel/Bazelisk to find their cache directory.
test --test_env=XDG_CACHE_HOME

# Disable cc toolchains to test rust targets can be built without one.
build:no_cc_toolchain --repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
build:no_cc_toolchain --repo_env=BAZEL_NO_APPLE_CPP_TOOLCHAIN=1
Expand Down
79 changes: 79 additions & 0 deletions .github/workflows/bazel_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Bazel Test

on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
- reopened
merge_group:
workflow_dispatch:
workflow_call:
secrets:
BUILDBUDDY_API_KEY:
required: false

permissions:
contents: read

concurrency:
group: bazel-test-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
test:
name: bazel test //... (${{ matrix.platform }})
runs-on: ${{ matrix.os }}
timeout-minutes: 120
strategy:
fail-fast: false
matrix:
include:
- platform: linux
os: ubuntu-latest
- platform: macos
os: macos-latest
- platform: windows
os: windows-latest

steps:
- uses: actions/checkout@v6

- name: Mount Bazel repository cache
uses: actions/cache@v4
with:
path: |
~/.cache/bazel-repo
key: bazel-repo-${{ matrix.platform }}-${{ hashFiles('MODULE.bazel', 'MODULE.bazel.lock', '.bazelrc', '**/*.bzl', '**/BUILD', '**/BUILD.bazel') }}
restore-keys: |
bazel-repo-${{ matrix.platform }}-

- name: Configure Windows Bazel
if: runner.os == 'Windows'
shell: pwsh
run: |
'startup --output_user_root=C:/tmp/bazel' | Out-File -FilePath user.bazelrc -Encoding utf8
'startup --windows_enable_symlinks' | Out-File -FilePath user.bazelrc -Append -Encoding utf8

- name: bazel test //...
shell: bash
env:
USE_BAZEL_VERSION: 9.1.0
BUILDBUDDY_API_KEY: ${{ secrets.BUILDBUDDY_API_KEY }}
run: |
REMOTE_ARGS=()
if [[ -n "${BUILDBUDDY_API_KEY:-}" ]]; then
REMOTE_ARGS+=(--remote_header="x-buildbuddy-api-key=${BUILDBUDDY_API_KEY}")
else
echo "BUILDBUDDY_API_KEY is not set; using BuildBuddy remote cache without an auth header."
fi

bazel \
--bazelrc="$GITHUB_WORKSPACE/.github/github.bazelrc" \
test \
--config=remote \
"${REMOTE_ARGS[@]}" \
//...
21 changes: 0 additions & 21 deletions .github/workflows/docs.yaml

This file was deleted.

18 changes: 0 additions & 18 deletions .github/workflows/formatting.yaml

This file was deleted.

15 changes: 14 additions & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,27 @@ module(
## Core
###############################################################################

bazel_dep(name = "bazel_lib", version = "3.0.0")
bazel_dep(name = "bazel_features", version = "1.32.0")
bazel_dep(name = "bazel_skylib", version = "1.8.2")
bazel_dep(name = "platforms", version = "1.1.0")
bazel_dep(name = "protobuf", version = "28.3", repo_name = "com_google_protobuf")
bazel_dep(name = "rules_cc", version = "0.2.4")
bazel_dep(name = "rules_license", version = "1.0.0")
bazel_dep(name = "rules_proto", version = "7.1.0")
bazel_dep(name = "rules_python", version = "1.6.3")
bazel_dep(name = "rules_shell", version = "0.6.1")
bazel_dep(name = "apple_support", version = "1.24.1")
bazel_dep(name = "llvm", version = "0.7.7")

###############################################################################
## Compatibility
###############################################################################

bazel_dep(name = "rules_rs", version = "0.0.76")

osx = use_extension("@llvm//extensions:osx.bzl", "osx")
use_repo(osx, "macos_sdk")

internal_deps = use_extension("//rust/private:internal_extensions.bzl", "i")
use_repo(
Expand Down Expand Up @@ -86,7 +100,6 @@ use_repo(
"rules_rust_toolchain_test_target_json",
)

bazel_dep(name = "rules_python", version = "1.5.1", dev_dependency = True)
bazel_dep(name = "rules_testing", version = "0.7.0", dev_dependency = True)
bazel_dep(name = "bazel_ci_rules", version = "1.0.0", dev_dependency = True)

Expand Down
7 changes: 5 additions & 2 deletions cargo/private/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@bazel_lib//lib:copy_file.bzl", "copy_file")
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
load("//rust:defs.bzl", "rust_binary")

rust_binary(
Expand Down Expand Up @@ -39,6 +39,9 @@ copy_file(

bzl_library(
name = "bzl_lib",
deps = [
"//rust:bzl_lib",
],
srcs = glob(["**/*.bzl"]),
visibility = ["//:__subpackages__"],
visibility = ["//visibility:public"],
)
71 changes: 47 additions & 24 deletions cargo/private/cargo_build_script.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ load(
# Reexport for cargo_build_script_wrapper.bzl
name_to_crate_name = _name_to_crate_name

# Keep this short: it is part of CARGO_MANIFEST_DIR on Windows.
_CARGO_MANIFEST_DIR = "m"

CargoBuildScriptRunfilesInfo = provider(
doc = "Info about a `cargo_build_script.script` target.",
fields = {
Expand Down Expand Up @@ -293,13 +296,33 @@ def _feature_enabled(ctx, feature_name, default = False):

return default

def _manifest_rlocation_prefix(workspace_name, package):
if package:
return "{}/{}".format(workspace_name, package)

return workspace_name

def _rlocationpath(file, workspace_name):
if file.short_path.startswith("../"):
return file.short_path[len("../"):]

return "{}/{}".format(workspace_name, file.short_path)

def _create_runfiles_dir(ctx, script, retain_list):
def _manifest_dir_rlocationpath(rlocationpath, manifest_rlocation_prefix):
prefix = manifest_rlocation_prefix + "/"
if rlocationpath == manifest_rlocation_prefix:
return _CARGO_MANIFEST_DIR
if rlocationpath.startswith(prefix):
return paths.join(_CARGO_MANIFEST_DIR, rlocationpath[len(prefix):])

return None

def _create_runfiles_dir(
ctx,
script,
retain_list,
workspace_name,
manifest_rlocation_prefix):
"""Create a runfiles directory to represent `CARGO_MANIFEST_DIR`.

Due to the inability to forcibly generate runfiles directories for use as inputs
Expand All @@ -314,20 +337,24 @@ def _create_runfiles_dir(ctx, script, retain_list):
ctx (ctx): The rule's context object
script (Target): The `cargo_build_script.script` target.
retain_list (list): A list of strings to keep in generated runfiles directories.
workspace_name (str): The runfiles workspace name for the current repository.
manifest_rlocation_prefix (str): The current package's runfiles path prefix.

Returns:
Tuple[File, Depset[File], Args]:
- The output directory to be created.
- Runfile inputs needed by the action.
- The args required to create the directory.
"""
runfiles_dir = ctx.actions.declare_directory("{}.cargo_runfiles".format(ctx.label.name))

# External repos always fall into the `../` branch of `_rlocationpath`.
workspace_name = ctx.workspace_name
runfiles_dir = ctx.actions.declare_directory(ctx.label.name + ".crf")

def _runfiles_map(file):
return "{}={}".format(file.path, _rlocationpath(file, workspace_name))
rlocationpath = _rlocationpath(file, workspace_name)
manifest_path = _manifest_dir_rlocationpath(rlocationpath, manifest_rlocation_prefix)
if not manifest_path:
return "{}={}".format(file.path, rlocationpath)

return "{}={}".format(file.path, manifest_path)

runfiles = script[DefaultInfo].default_runfiles

Expand Down Expand Up @@ -382,8 +409,10 @@ def _cargo_build_script_impl(ctx):
ctx = ctx,
script = ctx.attr.script,
retain_list = ctx.attr._cargo_manifest_dir_filename_suffixes_to_retain[BuildSettingInfo].value,
workspace_name = workspace_name,
manifest_rlocation_prefix = _manifest_rlocation_prefix(workspace_name, ctx.label.package),
)
manifest_dir = "{}/{}/{}".format(runfiles_dir.path, workspace_name, ctx.label.package)
manifest_dir = paths.join(runfiles_dir.path, _CARGO_MANIFEST_DIR)

pkg_name = ctx.attr.pkg_name
if pkg_name == "":
Expand Down Expand Up @@ -538,6 +567,7 @@ def _cargo_build_script_impl(ctx):
known_variables.update(variables)

if ctx.attr.build_script_env:
_fail_on_rlocationpath_env(ctx.attr.build_script_env)
_merge_env_dict(env, expand_dict_value_locations(
ctx,
ctx.attr.build_script_env,
Expand Down Expand Up @@ -573,8 +603,6 @@ def _cargo_build_script_impl(ctx):
args.add(link_flags, format = "--link_flags=%s")
args.add(link_search_paths, format = "--link_search_paths=%s")
args.add(dep_env_out, format = "--dep_env_out=%s")
args.add(ctx.attr.rundir, format = "--rundir=%s")

output_groups = {
"out_dir": depset([out_dir]),
}
Expand Down Expand Up @@ -642,7 +670,7 @@ def _cargo_build_script_impl(ctx):
tools = tools,
inputs = depset(build_script_inputs, transitive = [runfiles_inputs]),
mnemonic = "CargoBuildScriptRun",
progress_message = "Running Cargo build script {}".format(pkg_name),
progress_message = "Running Cargo build script %{label}",
env = env,
toolchain = None,
use_default_shell_env = use_default_shell_env,
Expand All @@ -660,7 +688,8 @@ def _cargo_build_script_impl(ctx):
flags = flags_out,
linker_flags = link_flags,
link_search_paths = link_search_paths,
compile_data = depset([runfiles_dir] + extra_output, transitive = script_data),
build_script_data = depset(transitive = script_data),
compile_data = depset([runfiles_dir] + extra_output),
),
OutputGroupInfo(
**output_groups
Expand Down Expand Up @@ -717,19 +746,6 @@ cargo_build_script = rule(
"pkg_name": attr.string(
doc = "The name of package being compiled, if not derived from `name`.",
),
"rundir": attr.string(
default = "",
doc = dedent("""\
A directory to cd to before the cargo_build_script is run.

This should be a pathrelative to the exec root. The default behaviour (and the
behaviour if rundir is set to the empty string) is to change to the relative
path corresponding to the cargo manifest directory, which replicates the
normal behaviour of cargo so it is easy to write compatible build scripts.

If set to `.`, the cargo build script will run in the exec root.
"""),
),
"rustc_flags": attr.string_list(
doc = dedent("""\
List of compiler flags passed to `rustc`.
Expand Down Expand Up @@ -818,6 +834,13 @@ def _merge_env_dict(prefix_dict, suffix_dict):
prefix_dict[key] += " " + suffix_dict.pop(key)
prefix_dict.update(suffix_dict)

def _fail_on_rlocationpath_env(env):
for key, value in env.items():
if "$(rlocationpath" in value:
fail(
"cargo_build_script build_script_env does not support $(rlocationpath ...) in '{}'; use $(execpath ...) or $(location ...) for files needed while running the build script".format(key),
)

def name_to_pkg_name(name):
"""Sanitize the name of cargo_build_script targets.

Expand Down
Loading
Loading