Skip to content

Commit b9e00bb

Browse files
Fix Windows cross-build LLVM preflight
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 3539339 commit b9e00bb

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ cargo install cargo-xwin --version 0.23.0
7777
rustup target add x86_64-pc-windows-msvc aarch64-pc-windows-msvc
7878
```
7979

80-
If Homebrew's LLVM and LLD are not on `PATH`, add them before running the helper:
80+
If Homebrew's `clang-cl` and LLD are not on `PATH`, add them before running the helper:
8181

8282
```bash
8383
export PATH="$(brew --prefix llvm)/bin:$(brew --prefix lld)/bin:$PATH"

xtask/src/windows_local.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,14 +267,18 @@ fn missing_targets_message(missing: &[&str]) -> String {
267267
}
268268

269269
fn ensure_llvm_tools() -> Result<(), String> {
270-
let has_clang = which_exists("clang") || which_exists("clang-cl");
270+
let has_clang_cl = which_exists("clang-cl");
271271
let has_lld = which_exists("lld-link") || which_exists("ld.lld") || which_exists("lld");
272272

273-
if has_clang && has_lld {
273+
if has_clang_cl && has_lld {
274274
return Ok(());
275275
}
276276

277-
Err("clang/LLVM tools are required for cargo-xwin. On macOS: brew install llvm lld, then ensure both Homebrew bin directories are on PATH".to_string())
277+
Err(llvm_tools_help().to_string())
278+
}
279+
280+
fn llvm_tools_help() -> &'static str {
281+
"clang-cl and LLD are required for cargo-xwin. On macOS: brew install llvm lld, then ensure both Homebrew bin directories are on PATH"
278282
}
279283

280284
fn build_target(root: &Path, target: &WindowsTarget, cache_dir: &Path) -> Result<(), String> {
@@ -448,6 +452,14 @@ mod tests {
448452
);
449453
}
450454

455+
#[test]
456+
fn llvm_tools_help_mentions_clang_cl() {
457+
let message = llvm_tools_help();
458+
459+
assert!(message.contains("clang-cl"));
460+
assert!(message.contains("brew install llvm lld"));
461+
}
462+
451463
#[test]
452464
fn cargo_xwin_build_args_include_native_packages() {
453465
let target = match find_target("x64") {

0 commit comments

Comments
 (0)