Skip to content

Commit 2d99120

Browse files
authored
Add the host architecture Windows 10 SDK bin directory to the PATH, not the target. (#524)
Fixes failures during cross-compilation when the host cannot execute the target architecture Windows 10 SDK tools. Also adds the target tools bin to the PATH before the host_dylib_path is added. This ensures that if a target-specific version of a tool is available, it is preferred.
1 parent da806ad commit 2d99120

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

.github/workflows/main.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ jobs:
3434
rust: stable
3535
target: aarch64-apple-ios
3636
no_run: --no-run
37+
- build: windows-aarch64
38+
os: windows-latest
39+
rust: stable
40+
target: aarch64-pc-windows-msvc
41+
no_run: --no-run
3742
- build: win32
3843
os: windows-2016
3944
rust: stable-i686-msvc

cc-test/src/aarch64.asm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
AREA |.text|, CODE, READONLY
2+
GLOBAL |asm|
3+
ALIGN 4
4+
|asm| PROC
5+
mov w0, #7
6+
ret
7+
ENDP
8+
END

src/windows_registry.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ mod impl_ {
347347
};
348348

349349
let mut tool = MsvcTool::new(tool_path);
350+
tool.path.push(bin_path.clone());
350351
tool.path.push(host_dylib_path);
351352
tool.libs.push(lib_path);
352353
tool.include.push(include_path);
@@ -424,8 +425,15 @@ mod impl_ {
424425
let sub = lib_subdir(target)?;
425426
let (ucrt, ucrt_version) = get_ucrt_dir()?;
426427

428+
let host = match host_arch() {
429+
X86 => "x86",
430+
X86_64 => "x64",
431+
AARCH64 => "arm64",
432+
_ => return None,
433+
};
434+
427435
tool.path
428-
.push(ucrt.join("bin").join(&ucrt_version).join(sub));
436+
.push(ucrt.join("bin").join(&ucrt_version).join(host));
429437

430438
let ucrt_include = ucrt.join("include").join(&ucrt_version);
431439
tool.include.push(ucrt_include.join("ucrt"));
@@ -434,7 +442,7 @@ mod impl_ {
434442
tool.libs.push(ucrt_lib.join("ucrt").join(sub));
435443

436444
if let Some((sdk, version)) = get_sdk10_dir() {
437-
tool.path.push(sdk.join("bin").join(sub));
445+
tool.path.push(sdk.join("bin").join(host));
438446
let sdk_lib = sdk.join("lib").join(&version);
439447
tool.libs.push(sdk_lib.join("um").join(sub));
440448
let sdk_include = sdk.join("include").join(&version);
@@ -443,7 +451,7 @@ mod impl_ {
443451
tool.include.push(sdk_include.join("winrt"));
444452
tool.include.push(sdk_include.join("shared"));
445453
} else if let Some(sdk) = get_sdk81_dir() {
446-
tool.path.push(sdk.join("bin").join(sub));
454+
tool.path.push(sdk.join("bin").join(host));
447455
let sdk_lib = sdk.join("lib").join("winv6.3");
448456
tool.libs.push(sdk_lib.join("um").join(sub));
449457
let sdk_include = sdk.join("include");

0 commit comments

Comments
 (0)