build/bazel: make Rust EFI builds reproducible
The abloader build was not reproducible because of this issue:
https://github.com/rust-lang/rust/issues/112587
We don't need the PDB file, so this disables it.
Co-authored-by: Tim Windelschmidt <tim@monogon.tech>
Change-Id: I8791d5c43ce23c3d1de1e0a3eeedc4d47f8eb4e7
Reviewed-on: https://review.monogon.dev/c/monogon/+/4386
Tested-by: Jenkins CI
Reviewed-by: Tim Windelschmidt <tim@monogon.tech>
diff --git a/build/bazel/rust.MODULE.bazel b/build/bazel/rust.MODULE.bazel
index e258e10..7aefbe1 100644
--- a/build/bazel/rust.MODULE.bazel
+++ b/build/bazel/rust.MODULE.bazel
@@ -1,7 +1,18 @@
+RUSTC_EFI_FLAGS = [
+ # Disable generation of PDB file to make build reproducible. Otherwise,
+ # the PDB file contains a non-deterministic path like
+ # /tmp/rustc0VgeF3/symbols.o, and the binary contains a hash of the PDB
+ # file. See https://github.com/rust-lang/rust/issues/112587
+ "-Clink-arg=/DEBUG:none",
+]
+
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
rust.toolchain(
edition = "2021",
- extra_rustc_flags = ["-Clinker=rust-lld"],
+ extra_rustc_flags_triples = {
+ "x86_64-unknown-uefi": RUSTC_EFI_FLAGS,
+ "aarch64-unknown-uefi": RUSTC_EFI_FLAGS,
+ },
extra_target_triples = [
"x86_64-unknown-uefi",
"aarch64-unknown-uefi",