Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support native ARM64 MSVC toolchain #732

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions src/windows_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,30 +454,34 @@ mod impl_ {
) -> Option<(PathBuf, PathBuf, PathBuf, PathBuf, PathBuf)> {
let version = vs15plus_vc_read_version(instance_path)?;

let host = match host_arch() {
X86 => "X86",
X86_64 => "X64",
// There is no natively hosted compiler on ARM64.
// Instead, use the x86 toolchain under emulation (there is no x64 emulation).
AARCH64 => "X86",
let hosts = match host_arch() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you annotate hosts with a type (i.e. &[&str]) you should be able to avoid creating Vecs.

X86 => vec!["X86"],
X86_64 => vec!["X64"],
// Starting with VS 17.3, there is a natively hosted compiler on ARM64.
// On older versions of VS, we use the x86 toolchain under emulation.
// We don't want to overcomplicate compatibility checks, so we ignore x64 emulation.
AARCH64 => vec!["ARM64", "X86"],
_ => return None,
};
let target = lib_subdir(target)?;
// The directory layout here is MSVC/bin/Host$host/$target/
let path = instance_path.join(r"VC\Tools\MSVC").join(version);
// We use the first available host architecture that can build for the target
let (host_path, host) = hosts.iter().find_map(|&x| {
let candidate = path.join("bin").join(&format!("Host{}", x));
if candidate.join(&target).exists() {
Some((candidate, x))
} else {
None
}
})?;
// This is the path to the toolchain for a particular target, running
// on a given host
let bin_path = path
.join("bin")
.join(&format!("Host{}", host))
.join(&target);
let bin_path = host_path.join(&target);
// But! we also need PATH to contain the target directory for the host
// architecture, because it contains dlls like mspdb140.dll compiled for
// the host architecture.
let host_dylib_path = path
.join("bin")
.join(&format!("Host{}", host))
.join(&host.to_lowercase());
let host_dylib_path = host_path.join(&host.to_lowercase());
let lib_path = path.join("lib").join(&target);
let include_path = path.join("include");
Some((path, bin_path, host_dylib_path, lib_path, include_path))
Expand Down