From 0d8065db2f62410c9b75d5cad69a15ca8e40e700 Mon Sep 17 00:00:00 2001 From: Daniel Paoliello Date: Mon, 28 Apr 2025 12:07:30 -0700 Subject: [PATCH] DRAFT: Add an aarch64-msvc build running on ARM64 Windows --- .github/workflows/ci.yml | 3 +++ .../spec/targets/aarch64_pc_windows_msvc.rs | 7 ++++++- library/std/src/fs/tests.rs | 16 ++++++++++++++ src/ci/github-actions/jobs.yml | 21 +++++++++++++++++-- src/ci/scripts/install-clang.sh | 18 ++++++++++++---- src/ci/scripts/install-mingw.sh | 2 +- src/ci/scripts/install-ninja.sh | 2 +- src/ci/scripts/install-rust.sh | 15 +++++++++++++ src/ci/scripts/install-sccache.sh | 2 +- src/tools/compiletest/src/directive-list.rs | 1 + tests/debuginfo/step-into-match.rs | 4 ++++ tests/debuginfo/type-names.rs | 2 ++ .../run-make/pointer-auth-link-with-c/test.rs | 2 +- tests/ui/runtime/backtrace-debuginfo.rs | 4 ++++ 14 files changed, 88 insertions(+), 11 deletions(-) create mode 100755 src/ci/scripts/install-rust.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 93316b9cff7b1..6303aa4b54b30 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -145,6 +145,9 @@ jobs: - name: show the current environment run: src/ci/scripts/dump-environment.sh + - name: install rust + run: src/ci/scripts/install-rust.sh + - name: install awscli run: src/ci/scripts/install-awscli.sh diff --git a/compiler/rustc_target/src/spec/targets/aarch64_pc_windows_msvc.rs b/compiler/rustc_target/src/spec/targets/aarch64_pc_windows_msvc.rs index 98d78520c9838..1c7e44d00963f 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_pc_windows_msvc.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_pc_windows_msvc.rs @@ -1,10 +1,15 @@ -use crate::spec::{Target, TargetMetadata, base}; +use crate::spec::{LinkerFlavor, Lld, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::windows_msvc::opts(); base.max_atomic_width = Some(128); base.features = "+v8a,+neon,+fp-armv8".into(); + // MSVC emits a warning about code that may trip "Cortex-A53 MPCore processor bug #843419" which + // is sometimes emitted by LLVM. Since Arm64 Windows 10+ isn't supported on that processor, it's + // safe to disable the warning. + base.add_pre_link_args(LinkerFlavor::Msvc(Lld::No), &["/arm64hazardfree"]); + Target { llvm_target: "aarch64-pc-windows-msvc".into(), metadata: TargetMetadata { diff --git a/library/std/src/fs/tests.rs b/library/std/src/fs/tests.rs index 46b0d832fec45..c81a5ff4d96e6 100644 --- a/library/std/src/fs/tests.rs +++ b/library/std/src/fs/tests.rs @@ -730,6 +730,10 @@ fn recursive_mkdir_empty() { } #[test] +#[cfg_attr( + all(windows, target_arch = "aarch64"), + ignore = "SymLinks not enabled on Arm64 Windows runners https://github.com/actions/partner-runner-images/issues/94" +)] fn recursive_rmdir() { let tmpdir = tmpdir(); let d1 = tmpdir.join("d1"); @@ -749,6 +753,10 @@ fn recursive_rmdir() { } #[test] +#[cfg_attr( + all(windows, target_arch = "aarch64"), + ignore = "SymLinks not enabled on Arm64 Windows runners https://github.com/actions/partner-runner-images/issues/94" +)] fn recursive_rmdir_of_symlink() { // test we do not recursively delete a symlink but only dirs. let tmpdir = tmpdir(); @@ -1533,6 +1541,10 @@ fn file_open_not_found() { } #[test] +#[cfg_attr( + all(windows, target_arch = "aarch64"), + ignore = "SymLinks not enabled on Arm64 Windows runners https://github.com/actions/partner-runner-images/issues/94" +)] fn create_dir_all_with_junctions() { let tmpdir = tmpdir(); let target = tmpdir.join("target"); @@ -2011,6 +2023,10 @@ fn test_rename_symlink() { #[test] #[cfg(windows)] +#[cfg_attr( + all(windows, target_arch = "aarch64"), + ignore = "SymLinks not enabled on Arm64 Windows runners https://github.com/actions/partner-runner-images/issues/94" +)] fn test_rename_junction() { let tmpdir = tmpdir(); let original = tmpdir.join("original"); diff --git a/src/ci/github-actions/jobs.yml b/src/ci/github-actions/jobs.yml index afcc092e78e8d..684c876c61d52 100644 --- a/src/ci/github-actions/jobs.yml +++ b/src/ci/github-actions/jobs.yml @@ -47,6 +47,10 @@ runners: os: windows-2025-8core-32gb <<: *base-job + - &job-windows-aarch64 + os: windows-11-arm + <<: *base-job + - &job-aarch64-linux # Free some disk space to avoid running out of space during the build. free_disk: true @@ -497,6 +501,19 @@ auto: SCRIPT: make ci-msvc-ps1 <<: *job-windows + # aarch64-msvc is split into two jobs to run tests in parallel. + - name: aarch64-msvc-1 + env: + RUST_CONFIGURE_ARGS: --build=aarch64-pc-windows-msvc + SCRIPT: make ci-msvc-py + <<: *job-windows-aarch64 + + - name: aarch64-msvc-2 + env: + RUST_CONFIGURE_ARGS: --build=aarch64-pc-windows-msvc + SCRIPT: make ci-msvc-ps1 + <<: *job-windows-aarch64 + # x86_64-msvc-ext is split into multiple jobs to run tests in parallel. - name: x86_64-msvc-ext1 env: @@ -590,14 +607,14 @@ auto: - name: dist-aarch64-msvc env: RUST_CONFIGURE_ARGS: >- - --build=x86_64-pc-windows-msvc + --build=aarch64-pc-windows-msvc --host=aarch64-pc-windows-msvc --target=aarch64-pc-windows-msvc,arm64ec-pc-windows-msvc --enable-full-tools --enable-profiler SCRIPT: python x.py dist bootstrap --include-default-paths DIST_REQUIRE_ALL_TOOLS: 1 - <<: *job-windows + <<: *job-windows-aarch64 - name: dist-i686-mingw env: diff --git a/src/ci/scripts/install-clang.sh b/src/ci/scripts/install-clang.sh index 5522095e3049b..228d14fc0138b 100755 --- a/src/ci/scripts/install-clang.sh +++ b/src/ci/scripts/install-clang.sh @@ -11,7 +11,7 @@ source "$(cd "$(dirname "$0")" && pwd)/../shared.sh" # Update both macOS's and Windows's tarballs when bumping the version here. # Try to keep this in sync with src/ci/docker/host-x86_64/dist-x86_64-linux/build-clang.sh -LLVM_VERSION="18.1.4" +LLVM_VERSION="20.1.3" if isMacOS; then # FIXME: This is the latest pre-built version of LLVM that's available for @@ -56,9 +56,19 @@ elif isWindows && ! isKnownToBeMingwBuild; then mkdir -p citools/clang-rust cd citools - retry curl -f "${MIRRORS_BASE}/LLVM-${LLVM_VERSION}-win64.exe" \ - -o "LLVM-${LLVM_VERSION}-win64.exe" - 7z x -oclang-rust/ "LLVM-${LLVM_VERSION}-win64.exe" + + if [[ "${CI_JOB_NAME}" = *aarch64* ]]; then + suffix=woa64 + + # On Arm64, the Ring crate requires that Clang be on the PATH. + # https://github.com/briansmith/ring/blob/main/BUILDING.md + ciCommandAddPath "$(cygpath -m "$(pwd)/clang-rust/bin")" + else + suffix=win64 + fi + retry curl -f "${MIRRORS_BASE}/LLVM-${LLVM_VERSION}-${suffix}.exe" \ + -o "LLVM-${LLVM_VERSION}-${suffix}.exe" + 7z x -oclang-rust/ "LLVM-${LLVM_VERSION}-${suffix}.exe" ciCommandSetEnv RUST_CONFIGURE_ARGS \ "${RUST_CONFIGURE_ARGS} --set llvm.clang-cl=$(pwd)/clang-rust/bin/clang-cl.exe" diff --git a/src/ci/scripts/install-mingw.sh b/src/ci/scripts/install-mingw.sh index c8c501e646a9d..ad852071f2950 100755 --- a/src/ci/scripts/install-mingw.sh +++ b/src/ci/scripts/install-mingw.sh @@ -42,5 +42,5 @@ if isWindows && isKnownToBeMingwBuild; then curl -o mingw.7z "${MIRRORS_BASE}/${mingw_archive}" 7z x -y mingw.7z > /dev/null - ciCommandAddPath "$(pwd)/${mingw_dir}/bin" + ciCommandAddPath "$(cygpath -m "$(pwd)/${mingw_dir}/bin")" fi diff --git a/src/ci/scripts/install-ninja.sh b/src/ci/scripts/install-ninja.sh index 23cbc2eb6d107..7ac19173923cf 100755 --- a/src/ci/scripts/install-ninja.sh +++ b/src/ci/scripts/install-ninja.sh @@ -12,7 +12,7 @@ if isWindows; then 7z x -oninja ninja.zip rm ninja.zip ciCommandSetEnv "RUST_CONFIGURE_ARGS" "${RUST_CONFIGURE_ARGS} --enable-ninja" - ciCommandAddPath "$(pwd)/ninja" + ciCommandAddPath "$(cygpath -m "$(pwd)/ninja")" elif isMacOS; then brew install ninja fi diff --git a/src/ci/scripts/install-rust.sh b/src/ci/scripts/install-rust.sh new file mode 100755 index 0000000000000..e4aee98c9fb2a --- /dev/null +++ b/src/ci/scripts/install-rust.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# The Arm64 Windows Runner does not have Rust already installed +# https://github.com/actions/partner-runner-images/issues/77 + +set -euo pipefail +IFS=$'\n\t' + +source "$(cd "$(dirname "$0")" && pwd)/../shared.sh" + +if [[ "${CI_JOB_NAME}" = *aarch64* ]] && isWindows; then + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \ + sh -s -- -y -q --default-host aarch64-pc-windows-msvc + ciCommandAddPath "${USERPROFILE}/.cargo/bin" +fi diff --git a/src/ci/scripts/install-sccache.sh b/src/ci/scripts/install-sccache.sh index b055e76a80504..fed06063fa0b3 100755 --- a/src/ci/scripts/install-sccache.sh +++ b/src/ci/scripts/install-sccache.sh @@ -15,7 +15,7 @@ elif isWindows; then mkdir -p sccache curl -fo sccache/sccache.exe \ "${MIRRORS_BASE}/2025-02-24-sccache-v0.10.0-x86_64-pc-windows-msvc.exe" - ciCommandAddPath "$(pwd)/sccache" + ciCommandAddPath "$(cygpath -m "$(pwd)/sccache")" fi # FIXME: we should probably install sccache outside the containers and then diff --git a/src/tools/compiletest/src/directive-list.rs b/src/tools/compiletest/src/directive-list.rs index 1449e9af19aa5..5757e422ae21e 100644 --- a/src/tools/compiletest/src/directive-list.rs +++ b/src/tools/compiletest/src/directive-list.rs @@ -35,6 +35,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[ "ignore-32bit", "ignore-64bit", "ignore-aarch64", + "ignore-aarch64-pc-windows-msvc", "ignore-aarch64-unknown-linux-gnu", "ignore-aix", "ignore-android", diff --git a/tests/debuginfo/step-into-match.rs b/tests/debuginfo/step-into-match.rs index 577e553c11985..a4abe9a29aae3 100644 --- a/tests/debuginfo/step-into-match.rs +++ b/tests/debuginfo/step-into-match.rs @@ -1,6 +1,10 @@ //@ compile-flags: -g //@ ignore-android: FIXME(#10381) +// On Arm64 Windows, stepping at the end of a funciton on goes to the callsite, not the instruction +// after it. +//@ ignore-aarch64-pc-windows-msvc: Stepping out of functions behaves differently. + // === GDB TESTS ============================================================== // gdb-command: r diff --git a/tests/debuginfo/type-names.rs b/tests/debuginfo/type-names.rs index 4df6daf7b6ef0..3c7eab7e8d718 100644 --- a/tests/debuginfo/type-names.rs +++ b/tests/debuginfo/type-names.rs @@ -1,5 +1,7 @@ //@ ignore-lldb +//@ ignore-aarch64-pc-windows-msvc: Arm64 Windows cdb doesn't support JavaScript extensions. + // GDB changed the way that it formatted Foreign types //@ min-gdb-version: 9.2 diff --git a/tests/run-make/pointer-auth-link-with-c/test.rs b/tests/run-make/pointer-auth-link-with-c/test.rs index 1a3be80e898ba..795c6a45f8e61 100644 --- a/tests/run-make/pointer-auth-link-with-c/test.rs +++ b/tests/run-make/pointer-auth-link-with-c/test.rs @@ -1,4 +1,4 @@ -#[link(name = "test")] +#[link(name = "test", kind = "static")] extern "C" { fn foo() -> i32; } diff --git a/tests/ui/runtime/backtrace-debuginfo.rs b/tests/ui/runtime/backtrace-debuginfo.rs index afc96d6bb5f54..37fce2788b7f0 100644 --- a/tests/ui/runtime/backtrace-debuginfo.rs +++ b/tests/ui/runtime/backtrace-debuginfo.rs @@ -42,9 +42,13 @@ macro_rules! dump_and_die { // there, even on i686-pc-windows-msvc. We do the best we can in // rust-lang/rust to test it as well, but sometimes we just gotta keep // landing PRs. + // + // aarch64-msvc is broken as its backtraces are truncated. + // See https://github.com/rust-lang/rust/issues/140489 if cfg!(any(target_os = "android", all(target_os = "linux", target_arch = "arm"), all(target_env = "msvc", target_arch = "x86"), + all(target_env = "msvc", target_arch = "aarch64"), target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd")) {