build: run vendoring script from src/rust
What changed, and why it matters
This commit is a build-script maintenance change. It changes how a Rust dependency-vendoring script is invoked so that the correct Rust compiler version is automatically selected. There is no user-facing feature change and no indication of a security problem being fixed.
No security action needed. Treat as routine build maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch modifies the vendor-rust-deps Makefile target and external/vendor-rust.sh. Previously the script was invoked from external/ and required the caller to be in src/rust/ for rustup to load rust-toolchain.toml. The updated script computes its own repository root, changes into src/rust, and writes vendored dependencies to external/vendor. This is purely a tooling/CI convenience change.
Changed components
Makefileexternal/vendor-rust.shInspect captured patch +13 / −5
diff --git a/Makefile b/Makefile
index 3467d73..7a32c7c 100644
--- a/Makefile
+++ b/Makefile
@@ -191,4 +191,4 @@ clean:
# When you vendor rust libs avoid duplicates
vendor-rust-deps:
- (cd external; ./vendor-rust.sh)
+ ./external/vendor-rust.sh
diff --git a/external/vendor-rust.sh b/external/vendor-rust.sh
index 69756e5..0683f34 100755
--- a/external/vendor-rust.sh
+++ b/external/vendor-rust.sh
@@ -2,8 +2,9 @@
#
# Script for vendoring our dependencies, including the deps of core/alloc.
#
-# This script must be called from the <git-project-root>/src/rust directory. It will place the
-# dependencies in a directory called "vendor" in the current working directory.
+# This script can be called from any directory. It runs Cargo from the
+# <git-project-root>/src/rust directory so rustup loads rust-toolchain.toml, and places the
+# dependencies in <git-project-root>/external/vendor.
#
# For some reason Cargo needs to find the dependencies of all rust std libs. Since "test" depends
# on all the other ones, we take the toml-file from it. This means that we vendor libs that we
@@ -15,9 +16,16 @@
# Copying the Cargo.lock file in the rust sysroot image requires root permissions. Therefore it is
# done in the Dockerfile in our setup.
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
+RUST_WORKSPACE_DIR="$REPO_ROOT/src/rust"
+VENDOR_DIR="../../external/vendor"
+
+cd "$RUST_WORKSPACE_DIR"
+
RUST_SYSROOT="$(rustc --print=sysroot)"
RUSTC_BOOTSTRAP=1 cargo vendor \
- --manifest-path ../src/rust/Cargo.toml \
+ --manifest-path Cargo.toml \
--sync "$RUST_SYSROOT/lib/rustlib/src/rust/library/test/Cargo.toml" \
- vendor
+ "$VENDOR_DIR"
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.