From efad8d66fd2d83b425fff9c1d6deef2cb9df2338 Mon Sep 17 00:00:00 2001 From: Matthew Maurer Date: Tue, 7 May 2024 19:26:59 +0000 Subject: [PATCH 1/4] sanitizer: Fix scs-attr check test This test was not actually being run before - it only runs on targets with SCS enabled, which is limited to `aarch64-linux-android` at the moment. This means that the test has been sitting broken and needs to be fixed before we can enable `aarch64-linux-android` in testing. * Rename CHECK function names to match current crate name * Disable optimization to prevent the functions from being made MIR-only --- tests/codegen/sanitizer/scs-attr-check.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/codegen/sanitizer/scs-attr-check.rs b/tests/codegen/sanitizer/scs-attr-check.rs index 6f4cbc2c0a6bc..614b7bf556df5 100644 --- a/tests/codegen/sanitizer/scs-attr-check.rs +++ b/tests/codegen/sanitizer/scs-attr-check.rs @@ -3,15 +3,17 @@ // //@ needs-sanitizer-shadow-call-stack //@ compile-flags: -Zsanitizer=shadow-call-stack +// With optimization, Rust may decide to make these functions MIR-only. +//@ compile-flags: -C opt-level=0 #![crate_type = "lib"] #![feature(no_sanitize)] -// CHECK: ; sanitizer_scs_attr_check::scs +// CHECK: ; scs_attr_check::scs // CHECK-NEXT: ; Function Attrs:{{.*}}shadowcallstack pub fn scs() {} -// CHECK: ; sanitizer_scs_attr_check::no_scs +// CHECK: ; scs_attr_check::no_scs // CHECK-NOT: ; Function Attrs:{{.*}}shadowcallstack #[no_sanitize(shadow_call_stack)] pub fn no_scs() {} From 04b2dd6dd24bbb0e507b62b17c1c3eef8a63aaa3 Mon Sep 17 00:00:00 2001 From: Matthew Maurer Date: Tue, 7 May 2024 20:52:22 +0000 Subject: [PATCH 2/4] aarch64-android: Temporarily disable stack probes test Stack probes are working correctly, but the SIGSEGV handler is not registered, so the expected message doesn't appear after running the test. Disable these to enable an aarch64-android runner. Re-enablement is tracked at #124823 --- tests/ui/abi/stack-probes-lto.rs | 1 + tests/ui/abi/stack-probes.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/ui/abi/stack-probes-lto.rs b/tests/ui/abi/stack-probes-lto.rs index 70343b0599ac3..75dddee3b5e95 100644 --- a/tests/ui/abi/stack-probes-lto.rs +++ b/tests/ui/abi/stack-probes-lto.rs @@ -6,6 +6,7 @@ //@[x64] only-x86_64 //@ ignore-sgx no processes //@ ignore-musl FIXME #31506 +//@ ignore-android handler not yet registered #124823 //@ ignore-fuchsia no exception handler registered for segfault //@ compile-flags: -C lto //@ no-prefer-dynamic diff --git a/tests/ui/abi/stack-probes.rs b/tests/ui/abi/stack-probes.rs index 22304257593fe..f02792ed2afcc 100644 --- a/tests/ui/abi/stack-probes.rs +++ b/tests/ui/abi/stack-probes.rs @@ -6,6 +6,7 @@ //@[x64] only-x86_64 //@ ignore-emscripten no processes //@ ignore-sgx no processes +//@ ignore-android handler not yet registered #124823 //@ ignore-fuchsia no exception handler registered for segfault //@ ignore-nto Crash analysis impossible at SIGSEGV in QNX Neutrino //@ ignore-ios Stack probes are enabled, but the SIGSEGV handler isn't From a1e538c9740d44b5c7e1a1fac38e080e6413e9c9 Mon Sep 17 00:00:00 2001 From: Matthew Maurer Date: Fri, 2 Feb 2024 23:13:05 +0000 Subject: [PATCH 3/4] Update Android testing to API 21, matching NDK 26 We were running testing on API 18, which was already out of support for NDK 25, and some of the ancient behavior in that image was causing trouble when developing `rustc` features (#120326). Update to the current LTS NDK 26, and to its minimum supported API 21. Fixes: #120567 --- config.example.toml | 2 +- src/bootstrap/src/utils/cc_detect.rs | 8 +++----- src/bootstrap/src/utils/change_tracker.rs | 4 ++++ src/ci/docker/host-x86_64/arm-android/Dockerfile | 2 +- src/ci/docker/host-x86_64/arm-android/android-sdk.lock | 6 +++--- src/ci/docker/host-x86_64/dist-android/Dockerfile | 2 +- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/config.example.toml b/config.example.toml index a2c2fa1c2bd58..aefe077895d88 100644 --- a/config.example.toml +++ b/config.example.toml @@ -394,7 +394,7 @@ #metrics = false # Specify the location of the Android NDK. Used when targeting Android. -#android-ndk = "/path/to/android-ndk-r25b" +#android-ndk = "/path/to/android-ndk-r26d" # ============================================================================= # General install configuration options diff --git a/src/bootstrap/src/utils/cc_detect.rs b/src/bootstrap/src/utils/cc_detect.rs index d6fa7fc0bbebd..07675dda2017b 100644 --- a/src/bootstrap/src/utils/cc_detect.rs +++ b/src/bootstrap/src/utils/cc_detect.rs @@ -247,10 +247,8 @@ pub(crate) fn ndk_compiler(compiler: Language, triple: &str, ndk: &Path) -> Path triple.to_string() }; - // API 19 is the earliest API level supported by NDK r25b but AArch64 and x86_64 support - // begins at API level 21. - let api_level = - if triple.contains("aarch64") || triple.contains("x86_64") { "21" } else { "19" }; + // The earliest API supported by NDK r26d is 21. + let api_level = "21"; let compiler = format!("{}{}-{}", triple_translated, api_level, compiler.clang()); let host_tag = if cfg!(target_os = "macos") { // The NDK uses universal binaries, so this is correct even on ARM. @@ -258,7 +256,7 @@ pub(crate) fn ndk_compiler(compiler: Language, triple: &str, ndk: &Path) -> Path } else if cfg!(target_os = "windows") { "windows-x86_64" } else { - // NDK r25b only has official releases for macOS, Windows and Linux. + // NDK r26d only has official releases for macOS, Windows and Linux. // Try the Linux directory everywhere else, on the assumption that the OS has an // emulation layer that can cope (e.g. BSDs). "linux-x86_64" diff --git a/src/bootstrap/src/utils/change_tracker.rs b/src/bootstrap/src/utils/change_tracker.rs index 6a7c5c0f9b779..c49a334d562e8 100644 --- a/src/bootstrap/src/utils/change_tracker.rs +++ b/src/bootstrap/src/utils/change_tracker.rs @@ -199,6 +199,10 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[ change_id: 126701, severity: ChangeSeverity::Warning, summary: "`llvm.lld` is enabled by default for the dist profile. If set to false, `lld` will not be included in the dist build.", + ChangeInfo { + change_id: 120593, + severity: ChangeSeverity::Info, + summary: "Removed android-ndk r25b support in favor of android-ndk r26d.", }, ChangeInfo { change_id: 127913, diff --git a/src/ci/docker/host-x86_64/arm-android/Dockerfile b/src/ci/docker/host-x86_64/arm-android/Dockerfile index abca06fb9fb4c..222fa8a7355c8 100644 --- a/src/ci/docker/host-x86_64/arm-android/Dockerfile +++ b/src/ci/docker/host-x86_64/arm-android/Dockerfile @@ -6,7 +6,7 @@ RUN sh /scripts/android-base-apt-get.sh COPY scripts/android-ndk.sh /scripts/ RUN . /scripts/android-ndk.sh && \ - download_ndk android-ndk-r25b-linux.zip + download_ndk android-ndk-r26d-linux.zip RUN dpkg --add-architecture i386 && \ apt-get update && \ diff --git a/src/ci/docker/host-x86_64/arm-android/android-sdk.lock b/src/ci/docker/host-x86_64/arm-android/android-sdk.lock index a1be8a4346b6d..33b0c66ae095a 100644 --- a/src/ci/docker/host-x86_64/arm-android/android-sdk.lock +++ b/src/ci/docker/host-x86_64/arm-android/android-sdk.lock @@ -1,6 +1,6 @@ emulator emulator-linux-5264690.zip 48c1cda2bdf3095d9d9d5c010fbfb3d6d673e3ea patcher;v4 3534162-studio.sdk-patcher.zip 046699c5e2716ae11d77e0bad814f7f33fab261e -platform-tools platform-tools_r28.0.2-linux.zip 46a4c02a9b8e4e2121eddf6025da3c979bf02e28 -platforms;android-18 android-18_r03.zip e6b09b3505754cbbeb4a5622008b907262ee91cb -system-images;android-18;default;armeabi-v7a sys-img/android/armeabi-v7a-18_r05.zip 580b583720f7de671040d5917c8c9db0c7aa03fd +platform-tools platform-tools_r34.0.5-linux.zip 96097475cf7b279fdd8f218f5d043ffe94104ec3 +platforms;android-21 android-21_r02.zip 53536556059bb29ae82f414fd2e14bc335a4eb4c +system-images;android-21;default;armeabi-v7a sys-img/android/armeabi-v7a-21_r04.zip 8c606f81306564b65e41303d2603e4c42ded0d10 tools sdk-tools-linux-4333796.zip 8c7c28554a32318461802c1291d76fccfafde054 diff --git a/src/ci/docker/host-x86_64/dist-android/Dockerfile b/src/ci/docker/host-x86_64/dist-android/Dockerfile index 20b72b377cad2..54649e0d22b92 100644 --- a/src/ci/docker/host-x86_64/dist-android/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-android/Dockerfile @@ -6,7 +6,7 @@ RUN sh /scripts/android-base-apt-get.sh # ndk COPY scripts/android-ndk.sh /scripts/ RUN . /scripts/android-ndk.sh && \ - download_ndk android-ndk-r25b-linux.zip + download_ndk android-ndk-r26d-linux.zip # env ENV TARGETS=arm-linux-androideabi From 005ab822d903f76342fe55de2a867d8b1486574e Mon Sep 17 00:00:00 2001 From: Matthew Maurer Date: Fri, 2 Feb 2024 23:15:01 +0000 Subject: [PATCH 4/4] Add aarch64-android testing Updating to NDK 26d and API 21 revealed that the most recent emulator no longer runs 32-bit devices at all. Indeed, Google stopped shipping 32-bit emulator images as of API level 31. Since this architecture is more used, and current images no longer have backcompat code for 32-bit code, testing aarch64 is both important for enabling developers to ship apps that run on modern devices and to future-proof us. --- src/bootstrap/src/utils/change_tracker.rs | 1 + .../host-x86_64/aarch64-android/Dockerfile | 41 +++++++++++++++++++ .../aarch64-android/android-sdk.lock | 6 +++ .../docker/host-x86_64/arm-android/Dockerfile | 2 +- .../docker/scripts/android-start-emulator.sh | 10 ++--- src/ci/github-actions/jobs.yml | 3 ++ 6 files changed, 56 insertions(+), 7 deletions(-) create mode 100644 src/ci/docker/host-x86_64/aarch64-android/Dockerfile create mode 100644 src/ci/docker/host-x86_64/aarch64-android/android-sdk.lock diff --git a/src/bootstrap/src/utils/change_tracker.rs b/src/bootstrap/src/utils/change_tracker.rs index c49a334d562e8..1f090e835915b 100644 --- a/src/bootstrap/src/utils/change_tracker.rs +++ b/src/bootstrap/src/utils/change_tracker.rs @@ -199,6 +199,7 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[ change_id: 126701, severity: ChangeSeverity::Warning, summary: "`llvm.lld` is enabled by default for the dist profile. If set to false, `lld` will not be included in the dist build.", + }, ChangeInfo { change_id: 120593, severity: ChangeSeverity::Info, diff --git a/src/ci/docker/host-x86_64/aarch64-android/Dockerfile b/src/ci/docker/host-x86_64/aarch64-android/Dockerfile new file mode 100644 index 0000000000000..497cfff04b2ff --- /dev/null +++ b/src/ci/docker/host-x86_64/aarch64-android/Dockerfile @@ -0,0 +1,41 @@ +FROM ubuntu:23.04 + +ARG DEBIAN_FRONTEND=noninteractive +COPY scripts/android-base-apt-get.sh /scripts/ +RUN sh /scripts/android-base-apt-get.sh + +COPY scripts/android-ndk.sh /scripts/ +RUN . /scripts/android-ndk.sh && \ + download_ndk android-ndk-r26d-linux.zip + +RUN dpkg --add-architecture i386 && \ + apt-get update && \ + apt-get install -y --no-install-recommends \ + libgl1-mesa-glx \ + libpulse0 \ + libstdc++6:i386 \ + openjdk-8-jre-headless \ + tzdata \ + wget \ + python3 + +COPY scripts/android-sdk.sh /scripts/ +COPY scripts/android-sdk-manager.py /scripts/ +COPY host-x86_64/aarch64-android/android-sdk.lock /android/sdk/android-sdk.lock +RUN /scripts/android-sdk.sh + +ENV PATH=$PATH:/android/sdk/emulator +ENV PATH=$PATH:/android/sdk/tools +ENV PATH=$PATH:/android/sdk/platform-tools + +ENV TARGETS=aarch64-linux-android + +ENV RUST_CONFIGURE_ARGS --android-ndk=/android/ndk/ + +ENV SCRIPT python3 ../x.py --stage 2 test --host='' --target $TARGETS + +COPY scripts/sccache.sh /scripts/ +RUN sh /scripts/sccache.sh + +COPY scripts/android-start-emulator.sh /scripts/ +ENTRYPOINT ["/scripts/android-start-emulator.sh", "arm64-v8a", "auto"] diff --git a/src/ci/docker/host-x86_64/aarch64-android/android-sdk.lock b/src/ci/docker/host-x86_64/aarch64-android/android-sdk.lock new file mode 100644 index 0000000000000..56940c1d98f33 --- /dev/null +++ b/src/ci/docker/host-x86_64/aarch64-android/android-sdk.lock @@ -0,0 +1,6 @@ +emulator emulator-linux_x64-12038310.zip fe7a96bf6fbe7b026555dd7f76b713f22a07ec8b +patcher;v4 3534162-studio.sdk-patcher.zip 046699c5e2716ae11d77e0bad814f7f33fab261e +platform-tools platform-tools_r34.0.5-linux.zip 96097475cf7b279fdd8f218f5d043ffe94104ec3 +platforms;android-21 android-21_r02.zip 53536556059bb29ae82f414fd2e14bc335a4eb4c +system-images;android-21;default;arm64-v8a sys-img/android/arm64-v8a-21_r04.zip c4375f1b4b4cd21a8617660e25f621cedcbd8332 +tools sdk-tools-linux-4333796.zip 8c7c28554a32318461802c1291d76fccfafde054 diff --git a/src/ci/docker/host-x86_64/arm-android/Dockerfile b/src/ci/docker/host-x86_64/arm-android/Dockerfile index 222fa8a7355c8..a15e517a764ff 100644 --- a/src/ci/docker/host-x86_64/arm-android/Dockerfile +++ b/src/ci/docker/host-x86_64/arm-android/Dockerfile @@ -38,4 +38,4 @@ COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh COPY scripts/android-start-emulator.sh /scripts/ -ENTRYPOINT ["/scripts/android-start-emulator.sh"] +ENTRYPOINT ["/scripts/android-start-emulator.sh", "armeabi-v7a", "classic"] diff --git a/src/ci/docker/scripts/android-start-emulator.sh b/src/ci/docker/scripts/android-start-emulator.sh index 09f0d13759c79..fac1421585c52 100755 --- a/src/ci/docker/scripts/android-start-emulator.sh +++ b/src/ci/docker/scripts/android-start-emulator.sh @@ -6,11 +6,9 @@ set -ex # emulator identify the system export SHELL=/bin/bash -# Using the default qemu2 engine makes time::tests::since_epoch fails because -# the emulator date is set to unix epoch (in armeabi-v7a-18 image). Using -# classic engine the emulator starts with the current date and the tests run -# fine. If another image is used, this need to be evaluated again. -nohup nohup emulator @armeabi-v7a-18 \ - -engine classic -no-window -partition-size 2047 0<&- &>/dev/null & +nohup nohup emulator @$1-21 \ + -engine $2 -no-window -no-audio -partition-size 2047 0<&- &>/dev/null & + +shift 2 exec "$@" diff --git a/src/ci/github-actions/jobs.yml b/src/ci/github-actions/jobs.yml index a6e12c6ff954d..e56154e7523e9 100644 --- a/src/ci/github-actions/jobs.yml +++ b/src/ci/github-actions/jobs.yml @@ -115,6 +115,9 @@ auto: - image: arm-android <<: *job-linux-4c + - image: aarch64-android + <<: *job-linux-8c + - image: armhf-gnu <<: *job-linux-4c