From 5e7c14d5209a2e2011a627ffc33eb0d033b26cb8 Mon Sep 17 00:00:00 2001 From: Justin Horvitz Date: Wed, 21 Jan 2026 15:09:12 -0500 Subject: [PATCH 1/5] Update rust.bzl --- rust/private/rust.bzl | 4 ---- 1 file changed, 4 deletions(-) diff --git a/rust/private/rust.bzl b/rust/private/rust.bzl index 6ba4c361e1..55d1fbb746 100644 --- a/rust/private/rust.bzl +++ b/rust/private/rust.bzl @@ -826,10 +826,6 @@ _common_attrs = { doc = "Enable collection of cfg flags with results stored in CrateInfo.cfgs.", default = Label("//rust/settings:collect_cfgs"), ), - "_stamp_flag": attr.label( - doc = "A setting used to determine whether or not the `--stamp` flag is enabled", - default = Label("//rust/private:stamp"), - ), } | RUSTC_ATTRS | RUSTC_ALLOCATOR_LIBRARIES_ATTRS _coverage_attrs = { From 4d34348a9b00df2a2da2266e570c27d5facbe1a1 Mon Sep 17 00:00:00 2001 From: Justin Horvitz Date: Wed, 21 Jan 2026 15:09:46 -0500 Subject: [PATCH 2/5] Update rust.bzl --- rust/private/rustc.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/private/rustc.bzl b/rust/private/rustc.bzl index 933516c1f7..14b02dcfe3 100644 --- a/rust/private/rustc.bzl +++ b/rust/private/rustc.bzl @@ -1349,7 +1349,7 @@ def rustc_compile_action( linkstamps = depset([]) # Determine if the build is currently running with --stamp - stamp = is_stamping_enabled(attr) + stamp = is_stamping_enabled(ctx, attr) # Add flags for any 'rustc' lints that are specified. # From 2a7d8d2cdbef2222a14cefef41e1fc538fbf0ec9 Mon Sep 17 00:00:00 2001 From: Justin Horvitz Date: Wed, 21 Jan 2026 15:10:47 -0500 Subject: [PATCH 3/5] Update rust.bzl --- rust/private/stamp.bzl | 60 +++--------------------------------------- 1 file changed, 3 insertions(+), 57 deletions(-) diff --git a/rust/private/stamp.bzl b/rust/private/stamp.bzl index 1a7cab65cc..81fb80e464 100644 --- a/rust/private/stamp.bzl +++ b/rust/private/stamp.bzl @@ -1,63 +1,10 @@ -"""A small utility module dedicated to detecting whether or not the `--stamp` flag is enabled - -This module can be removed likely after the following PRs ar addressed: -- https://github.com/bazelbuild/bazel/issues/11164 -""" - -load("//rust/private:utils.bzl", "dedent") - -StampSettingInfo = provider( - doc = "Information about the `--stamp` command line flag", - fields = { - "value": "bool: Whether or not the `--stamp` flag was enabled", - }, -) - -def _stamp_build_setting_impl(ctx): - return StampSettingInfo(value = ctx.attr.value) - -_stamp_build_setting = rule( - doc = dedent("""\ - Whether to encode build information into the binary. Possible values: - - - stamp = 1: Always stamp the build information into the binary, even in [--nostamp][stamp] builds. \ - This setting should be avoided, since it potentially kills remote caching for the binary and \ - any downstream actions that depend on it. - - stamp = 0: Always replace build information by constant values. This gives good build result caching. - - stamp = -1: Embedding of build information is controlled by the [--[no]stamp][stamp] flag. - - Stamped binaries are not rebuilt unless their dependencies change. - [stamp]: https://docs.bazel.build/versions/main/user-manual.html#flag--stamp - """), - implementation = _stamp_build_setting_impl, - attrs = { - "value": attr.bool( - doc = "The default value of the stamp build flag", - mandatory = True, - ), - }, -) - -def stamp_build_setting(name, visibility = ["//visibility:public"]): - native.config_setting( - name = "stamp_detect", - values = {"stamp": "1"}, - visibility = visibility, - ) - - _stamp_build_setting( - name = name, - value = select({ - ":stamp_detect": True, - "//conditions:default": False, - }), - visibility = visibility, - ) +"""A small utility module dedicated to detecting whether or not the `--stamp` flag is enabled""" def is_stamping_enabled(attr): """Determine whether or not build stamping is enabled Args: + ctx (ctx): The rule's context object attr (struct): A rule's struct of attributes (`ctx.attr`) Returns: @@ -69,7 +16,6 @@ def is_stamping_enabled(attr): elif stamp_num == 0: return False elif stamp_num == -1: - stamp_flag = getattr(attr, "_stamp_flag", None) - return stamp_flag[StampSettingInfo].value if stamp_flag else False + return ctx.configuration.stamp_binaries() else: fail("Unexpected `stamp` value: {}".format(stamp_num)) From 30e8c6d136c7d3ecb77fe7586def5ed6dc286014 Mon Sep 17 00:00:00 2001 From: Justin Horvitz Date: Wed, 21 Jan 2026 15:11:14 -0500 Subject: [PATCH 4/5] Update rust.bzl --- rust/private/BUILD.bazel | 3 --- 1 file changed, 3 deletions(-) diff --git a/rust/private/BUILD.bazel b/rust/private/BUILD.bazel index d18e895493..89444bb9bc 100644 --- a/rust/private/BUILD.bazel +++ b/rust/private/BUILD.bazel @@ -1,7 +1,6 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") load("//rust/private:rust_analyzer.bzl", "rust_analyzer_detect_sysroot") load("//rust/private:rustc.bzl", "is_proc_macro_dep", "is_proc_macro_dep_enabled") -load("//rust/private:stamp.bzl", "stamp_build_setting") # Exported for docs exports_files(["providers.bzl"]) @@ -33,8 +32,6 @@ bzl_library( ], ) -stamp_build_setting(name = "stamp") - # This setting may be used to identify dependencies of proc-macro-s. # This feature is only enabled if `is_proc_macro_dep_enabled` is true. # Its value controls the BAZEL_RULES_RUST_IS_PROC_MACRO_DEP environment variable From a80220e0121df8263dab118c80fd96f153d15f8c Mon Sep 17 00:00:00 2001 From: Justin Horvitz Date: Wed, 21 Jan 2026 15:24:31 -0500 Subject: [PATCH 5/5] Fix params --- rust/private/stamp.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/private/stamp.bzl b/rust/private/stamp.bzl index 81fb80e464..a05c255c9a 100644 --- a/rust/private/stamp.bzl +++ b/rust/private/stamp.bzl @@ -1,6 +1,6 @@ """A small utility module dedicated to detecting whether or not the `--stamp` flag is enabled""" -def is_stamping_enabled(attr): +def is_stamping_enabled(ctx, attr): """Determine whether or not build stamping is enabled Args: