Skip to content

Commit ad3f5d9

Browse files
committed
Make Rust install guidance arch-aware and fail fast on missing target
Infer CARGO_TARGET before the toolchain checks so the install instructions can name the correct target for the architecture, and verify the target stdlib is present via rustc --print target-libdir before starting the lengthy vendor extraction and build.
1 parent 214d602 commit ad3f5d9

1 file changed

Lines changed: 22 additions & 11 deletions

File tree

configure.win

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@ if [ ${AUTOMERGE_FOUND} -eq 0 ]; then
5151
# Minimum Rust version required (MSRV)
5252
RUST_MSRV="1.85"
5353

54+
# Infer the Rust target from the C toolchain
55+
case `${CC} -dumpmachine 2>/dev/null` in
56+
aarch64*)
57+
CARGO_TARGET="aarch64-pc-windows-gnullvm"
58+
;;
59+
*)
60+
CARGO_TARGET="x86_64-pc-windows-gnu"
61+
;;
62+
esac
63+
echo "Using Rust target: ${CARGO_TARGET}"
64+
5465
# Check for Rust toolchain (cargo and rustc)
5566
# CRAN policy: check both system PATH and ~/.cargo/bin
5667
CARGO_CMD=""
@@ -82,7 +93,7 @@ if [ ${AUTOMERGE_FOUND} -eq 0 ]; then
8293
echo ""
8394
echo "Install Rust from https://rustup.rs/:"
8495
echo " 1. Download and run rustup-init.exe"
85-
echo " 2. Select: x86_64-pc-windows-gnu toolchain"
96+
echo " 2. After installation run: rustup target add ${CARGO_TARGET}"
8697
echo ""
8798
echo "Or via winget: winget install Rustlang.Rustup"
8899
echo "Or via scoop: scoop install rustup"
@@ -110,16 +121,16 @@ if [ ${AUTOMERGE_FOUND} -eq 0 ]; then
110121
exit 1
111122
fi
112123

113-
# Infer the Rust target from the C toolchain
114-
case `${CC} -dumpmachine 2>/dev/null` in
115-
aarch64*)
116-
CARGO_TARGET="aarch64-pc-windows-gnullvm"
117-
;;
118-
*)
119-
CARGO_TARGET="x86_64-pc-windows-gnu"
120-
;;
121-
esac
122-
echo "Using Rust target: ${CARGO_TARGET}"
124+
# Fail before the lengthy build if the target stdlib is absent
125+
TARGET_LIBDIR=$($RUSTC_CMD --print target-libdir --target "${CARGO_TARGET}" 2>/dev/null)
126+
if [ ! -d "$TARGET_LIBDIR" ]; then
127+
echo "-------------------- RUST TARGET NOT INSTALLED --------------------"
128+
echo "The Rust standard library for ${CARGO_TARGET} is not installed."
129+
echo ""
130+
echo "Install it with: rustup target add ${CARGO_TARGET}"
131+
echo "--------------------------------------------------------------------"
132+
exit 1
133+
fi
123134

124135
echo "Building automerge-c from bundled source..."
125136
echo "using Rust package manager: '$($CARGO_CMD --version)'"

0 commit comments

Comments
 (0)