Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 13 additions & 4 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,25 @@ common:windows --host_platform=//:local_windows_platform
common --incompatible_enable_cc_toolchain_resolution
common --incompatible_strict_action_env

common --@toolchains_llvm_bootstrapped//config:experimental_stub_libgcc_s
common --@llvm//config:experimental_stub_libgcc_s
common:linux --repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
common:macos --repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
common:linux --extra_toolchains=@toolchains_llvm_bootstrapped//toolchain:all
common:macos --extra_toolchains=@toolchains_llvm_bootstrapped//toolchain:all
common:linux --extra_toolchains=@llvm//toolchain:all
common:macos --extra_toolchains=@llvm//toolchain:all

common -c opt
common --@rules_rust//:extra_rustc_flags=-Clto=fat
common --@rules_rust//:extra_rustc_flags=-Cstrip=symbols
common --@rules_rust//:extra_rustc_flags=-Ccodegen-units=1
common --@rules_rust//:extra_rustc_flags=-Cpanic=abort


common --bes_results_url=https://app.buildbuddy.io/invocation/
common --bes_backend=grpcs://remote.buildbuddy.io
common --remote_cache=grpcs://remote.buildbuddy.io
common --remote_cache_compression
common --remote_download_toplevel
common --nobuild_runfile_links
common --remote_timeout=120
common --noexperimental_throttle_remote_action_building
common --experimental_remote_execution_keepalive
common --grpc_keepalive_time=30s
2 changes: 1 addition & 1 deletion .github/workflows/build_release_windows_amd64.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
call bazel build //:for_x86_64-pc-windows-msvc
call bazel --output_user_root=C:/b build //:for_x86_64-pc-windows-msvc

move bazel-out\x86_64-pc-windows-msvc-opt\bin\toml2json.exe toml2json_windows_amd64.exe
certutil -hashfile toml2json_windows_amd64.exe SHA256 > SHA256_windows_amd64.txt
2 changes: 1 addition & 1 deletion .github/workflows/build_release_windows_arm64.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
call bazel build //:for_aarch64-pc-windows-msvc
call bazel --output_user_root=C:/b build //:for_aarch64-pc-windows-msvc

move bazel-out\aarch64-pc-windows-msvc-opt\bin\toml2json.exe toml2json_windows_arm64.exe
certutil -hashfile toml2json_windows_arm64.exe SHA256 > SHA256_windows_arm64.txt
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ on:
branches:
- master
pull_request:

name: Build
branches:
- master

jobs:
build:
Expand Down
63 changes: 63 additions & 0 deletions 5f496fb97114adc59b7f4d69290c345493ee84be.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
From 5f496fb97114adc59b7f4d69290c345493ee84be Mon Sep 17 00:00:00 2001
From: David Zbarsky <dzbarsky@gmail.com>
Date: Mon, 23 Feb 2026 00:32:39 -0500
Subject: [PATCH] Bump toml2json

---
MODULE.bazel | 14 +++++++-------
test/.bazelrc | 2 +-
test/MODULE.bazel | 1 -
3 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/MODULE.bazel b/MODULE.bazel
index f0fd769..cf18e77 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -34,15 +34,15 @@ use_repo(
name = "toml2json_" + name,
executable = True,
sha256 = sha256,
- url = "https://github.com/dzbarsky/toml2json/releases/download/v0.0.7/toml2json_" + name + ext,
+ url = "https://github.com/dzbarsky/toml2json/releases/download/v0.0.11/toml2json_" + name + ext,
)
for name, sha256, ext in [
- ("darwin_amd64", "e2240483b28d95c7ae9ded7fb0e921142a644d6847c1da9b44ae3557117ed54f", ""),
- ("darwin_arm64", "20dd55c9d926a00b51c643a3c5677678eb5ddb8984ae2ad9cf3f701ccbb06d92", ""),
- ("linux_amd64", "f074ff54589ca601a491d3f8e33b9618d861d19d8e2359a0addf02d378f36c7c", ""),
- ("linux_arm64", "3f35040836858b5c1703be421ea1c06f83c68b6c14da37d0ee0655db891f125f", ""),
- ("windows_amd64", "7e5561170e088c717f87ba4c05ec6d3a0406b62133959530c2f4646158c27a97", ".exe"),
- ("windows_arm64", "bc6fbf776798a7beb7cb2b3feb898fcbc829b4106f0505cd08f251e7c1b2518e", ".exe"),
+ ("darwin_amd64", "3fad1d4314fec5074b635ba3e5b31d578e2539137a017092bf364672a3c9676a", ""),
+ ("darwin_arm64", "6d9ac7a19c738771233192db058f74af1e6963e78147adef68d3463b6736fdd1", ""),
+ ("linux_amd64", "06847d7e1319623cce0b5d5170d5e5302358966124308bd031a9e906dbf88ff4", ""),
+ ("linux_arm64", "e545383759bfb9ac535e43fbee372d390dff654e7e222f452ac12f921fb0b928", ""),
+ ("windows_amd64", "8c8f133188c0225ada9ce0febd907396d0bdc28c9a5efa7abb27420079c02ead", ".exe"),
+ ("windows_arm64", "2fd541cac2fef4ce836947de34eb815de64f457888969e845321937d3b980269", ".exe"),
]
]

diff --git a/test/.bazelrc b/test/.bazelrc
index 5fb6874..2324fdc 100644
--- a/test/.bazelrc
+++ b/test/.bazelrc
@@ -5,7 +5,7 @@ common --disk_cache=~/bazel_cache
common --incompatible_disallow_empty_glob=False

common --@rules_cc//cc/toolchains/args/archiver_flags:use_libtool_on_macos=False
-common --@toolchains_llvm_bootstrapped//config:experimental_stub_libgcc_s
+common --@llvm//config:experimental_stub_libgcc_s

# For some BCR -sys deps
common --@rules_python//python/config_settings:bootstrap_impl=script
diff --git a/test/MODULE.bazel b/test/MODULE.bazel
index 56200f3..7429bde 100644
--- a/test/MODULE.bazel
+++ b/test/MODULE.bazel
@@ -264,7 +264,6 @@ include("//:3rd_party/libz-sys/include.MODULE.bazel")
include("//:3rd_party/libgit2-sys/include.MODULE.bazel")
include("//:3rd_party/windows_x86_64_gnullvm/include.MODULE.bazel")
include("//:3rd_party/windows_aarch64_gnullvm/include.MODULE.bazel")
-
include("//:3rd_party/coreaudio-sys/include.MODULE.bazel")

# TODO(zbarsky): fix this for realz
2 changes: 1 addition & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ platform(
name = "local_linux_platform",
parents = ["@platforms//host"],
constraint_values = [
"@toolchains_llvm_bootstrapped//constraints/libc:gnu.2.28",
"@llvm//constraints/libc:gnu.2.28",
],
)

Expand Down
14 changes: 12 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
bazel_dep(name = "bazel_lib", version = "3.2.0")
bazel_dep(name = "platforms", version = "1.0.0")
bazel_dep(name = "toolchains_llvm_bootstrapped", version = "0.5.9")
bazel_dep(name = "rules_rs", version = "0.0.33")
bazel_dep(name = "llvm", version = "0.6.0")
bazel_dep(name = "rules_rs", version = "0.0.36")

single_version_override(
module_name = "rules_rs",
version = "0.0.36",
patches = [
"//:ffa8821744e94eb17d2c4c3edec5e3b01b7caaa1.patch",
"//:revert_toml2json_to_v0.0.7.patch",
],
patch_strip = 1,
)

rules_rust = use_extension("@rules_rs//rs/experimental:rules_rust.bzl", "rules_rust")
use_repo(rules_rust, "rules_rust")
Expand Down
15 changes: 7 additions & 8 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

155 changes: 155 additions & 0 deletions ffa8821744e94eb17d2c4c3edec5e3b01b7caaa1.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
From ffa8821744e94eb17d2c4c3edec5e3b01b7caaa1 Mon Sep 17 00:00:00 2001
From: David Zbarsky <dzbarsky@gmail.com>
Date: Wed, 25 Feb 2026 05:03:24 -0500
Subject: [PATCH] Add crate_features_select and rustc_flags_select

---
rs/extensions.bzl | 17 ++++++++++++++---
rs/private/annotations.bzl | 2 ++
rs/private/repository_utils.bzl | 8 +++++---
rs/rust_crate.bzl | 2 +-
test/MODULE.bazel | 6 ++++++
5 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/rs/extensions.bzl b/rs/extensions.bzl
index d7cbc32..866721f 100644
--- a/rs/extensions.bzl
+++ b/rs/extensions.bzl
@@ -542,12 +542,16 @@ def _generate_hub_and_spokes(
if version_key not in target_versions:
continue
target_versions = [version_key]
- if not annotation.crate_features:
+ if not annotation.crate_features and not annotation.crate_features_select:
continue
for version in target_versions:
features_enabled = feature_resolutions_by_fq_crate[_fq_crate(crate, version)].features_enabled
- for triple in platform_triples:
- features_enabled[triple].update(annotation.crate_features)
+ if annotation.crate_features:
+ for triple in platform_triples:
+ features_enabled[triple].update(annotation.crate_features)
+ for triple, features in annotation.crate_features_select.items():
+ if triple in features_enabled:
+ features_enabled[triple].update(features)

_date(mctx, "set up initial deps!")

@@ -622,6 +626,7 @@ crate.annotation(
build_script_tools_select = annotation.build_script_tools_select,
build_script_env_select = annotation.build_script_env_select,
rustc_flags = annotation.rustc_flags,
+ rustc_flags_select = annotation.rustc_flags_select,
data = annotation.data,
deps = annotation.deps,
crate_tags = annotation.tags,
@@ -1154,6 +1159,9 @@ _annotation = tag_class(
"crate_features": attr.string_list(
doc = "A list of strings to add to a crate's `rust_library::crate_features` attribute.",
),
+ "crate_features_select": attr.string_list_dict(
+ doc = "A list of strings to add to a crate's `rust_library::crate_features` attribute. Keys should be the platform triplet. Value should be a list of features.",
+ ),
"data": _relative_label_list(
doc = "A list of labels to add to a crate's `rust_library::data` attribute.",
),
@@ -1213,6 +1221,9 @@ _annotation = tag_class(
"rustc_flags": attr.string_list(
doc = "A list of strings to set on a crate's `rust_library::rustc_flags` attribute.",
),
+ "rustc_flags_select": attr.string_list_dict(
+ doc = "A list of strings to set on a crate's `rust_library::rustc_flags` attribute. Keys should be the platform triplet. Value should be a list of flags.",
+ ),
# "shallow_since": attr.string(
# doc = "An optional timestamp used for crates originating from a git repository instead of a crate registry. This flag optimizes fetching the source code.",
# ),
diff --git a/rs/private/annotations.bzl b/rs/private/annotations.bzl
index 58eb26a..980c725 100644
--- a/rs/private/annotations.bzl
+++ b/rs/private/annotations.bzl
@@ -14,8 +14,10 @@ _DEFAULT_CRATE_ANNOTATION = struct(
deps = [],
tags = [],
crate_features = [],
+ crate_features_select = {},
gen_binaries = [],
rustc_flags = [],
+ rustc_flags_select = {},
patch_args = [],
patch_tool = None,
patches = [],
diff --git a/rs/private/repository_utils.bzl b/rs/private/repository_utils.bzl
index e78f472..3b9d956 100644
--- a/rs/private/repository_utils.bzl
+++ b/rs/private/repository_utils.bzl
@@ -1,4 +1,3 @@
-
load(":semver.bzl", "parse_full_version")

def _platform(triple, use_experimental_platforms):
@@ -141,7 +140,7 @@ rust_crate(
conditional_crate_features = {conditional_crate_features},
crate_root = {crate_root},
edition = {edition},
- rustc_flags = {rustc_flags},
+ rustc_flags = {rustc_flags}{conditional_rustc_flags},
tags = {tags},
target_compatible_with = RESOLVED_PLATFORMS,
links = {links},
@@ -175,6 +174,7 @@ rust_crate(
build_deps, conditional_build_deps = render_select(attr.build_script_deps, attr.build_script_deps_select, use_experimental_platforms)
build_script_data, conditional_build_script_data = render_select(attr.build_script_data, attr.build_script_data_select, use_experimental_platforms)
build_script_tools, conditional_build_script_tools = render_select(attr.build_script_tools, attr.build_script_tools_select, use_experimental_platforms)
+ rustc_flags, conditional_rustc_flags = render_select(attr.rustc_flags, attr.rustc_flags_select, use_experimental_platforms)
deps, conditional_deps = render_select(attr.deps + bazel_metadata.get("deps", []), attr.deps_select, use_experimental_platforms)

conditional_build_script_env = render_select_build_script_env(attr.build_script_env_select, use_experimental_platforms)
@@ -195,7 +195,8 @@ rust_crate(
conditional_crate_features = repr(conditional_crate_features),
crate_root = repr(crate_root),
edition = repr(edition),
- rustc_flags = repr(attr.rustc_flags or []),
+ rustc_flags = repr(rustc_flags),
+ conditional_rustc_flags = " + " + conditional_rustc_flags if conditional_rustc_flags else "",
tags = repr(attr.crate_tags),
links = repr(links),
build_script = repr(build_script),
@@ -230,6 +231,7 @@ common_attrs = {
"build_script_tools_select": attr.string_list_dict(),
"build_script_tags": attr.string_list(),
"rustc_flags": attr.string_list(),
+ "rustc_flags_select": attr.string_list_dict(),
"crate_tags": attr.string_list(),
"data": attr.label_list(default = []),
"deps": attr.string_list(default = []),
diff --git a/rs/rust_crate.bzl b/rs/rust_crate.bzl
index 4923ce2..37a440f 100644
--- a/rs/rust_crate.bzl
+++ b/rs/rust_crate.bzl
@@ -73,7 +73,7 @@ def rust_crate(

if build_script:
build_script_kwargs = dict(
- build_deps = build_deps,
+ deps = build_deps,
aliases = aliases,
compile_data = compile_data,
crate_name = "build_script_build",
diff --git a/test/MODULE.bazel b/test/MODULE.bazel
index 7429bde..2451f9f 100644
--- a/test/MODULE.bazel
+++ b/test/MODULE.bazel
@@ -114,7 +114,13 @@ crate.annotation(
crate = "rustls",
# Test for https://github.com/bazelbuild/rules_rust/issues/3626
crate_features = ["fips"],
+ crate_features_select = {
+ "x86_64-unknown-linux-gnu": ["fips"],
+ },
repositories = ["annotation_crate_features"],
+ rustc_flags_select = {
+ "x86_64-unknown-linux-gnu": ["--cfg=rules_rs_annotation_smoke"],
+ },
)
crate.annotation(
# Smoketest that we do something reasonable with this attribute
Loading