From f8d4b2a150eca2797feaf863618886ac8e9cc8db Mon Sep 17 00:00:00 2001
From: Amanieu d'Antras <amanieu@gmail.com>
Date: Sun, 29 Oct 2023 23:08:49 +0000
Subject: [PATCH 1/6] Update stdarch submodule

---
 library/std/src/lib.rs | 5 +++++
 library/stdarch        | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs
index 2e458562744bf..b5c32e18f87cc 100644
--- a/library/std/src/lib.rs
+++ b/library/std/src/lib.rs
@@ -365,6 +365,11 @@
 #![feature(panic_unwind)]
 // tidy-alphabetical-end
 //
+// Library features (std_detect):
+// tidy-alphabetical-start
+#![feature(stdarch_internal)]
+// tidy-alphabetical-end
+//
 // Only for re-exporting:
 // tidy-alphabetical-start
 #![feature(assert_matches)]
diff --git a/library/stdarch b/library/stdarch
index f4528dd6e85d9..5ef6eb42bdcfe 160000
--- a/library/stdarch
+++ b/library/stdarch
@@ -1 +1 @@
-Subproject commit f4528dd6e85d97bb802240d7cd048b6e1bf72540
+Subproject commit 5ef6eb42bdcfef6891517a6e4c77a89c18722f18

From 9a39e41637ec102cad6e2a6282129b834c267f4a Mon Sep 17 00:00:00 2001
From: Amanieu d'Antras <amanieu@gmail.com>
Date: Tue, 31 Oct 2023 23:06:00 +0000
Subject: [PATCH 2/6] Update feature names for new stdarch

---
 library/core/src/lib.rs                          |  4 ----
 library/std/src/lib.rs                           | 14 ++++++++------
 library/std/tests/run-time-detect.rs             | 16 ++++++++++------
 .../miri/tests/pass/intrinsics-x86-aes-vaes.rs   |  2 +-
 .../miri/tests/pass/intrinsics-x86-avx512.rs     |  2 +-
 tests/ui/asm/aarch64/type-check-3.rs             |  2 +-
 tests/ui/asm/aarch64/type-check-4.rs             |  2 +-
 7 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs
index 2af242d4b5071..62da0cae785cd 100644
--- a/library/core/src/lib.rs
+++ b/library/core/src/lib.rs
@@ -429,10 +429,6 @@ pub mod primitive;
     deprecated_in_future
 )]
 #[allow(rustdoc::bare_urls)]
-// FIXME: This annotation should be moved into rust-lang/stdarch after clashing_extern_declarations is
-// merged. It currently cannot because bootstrap fails as the lint hasn't been defined yet.
-#[allow(clashing_extern_declarations)]
-#[unstable(feature = "stdsimd", issue = "48556")]
 mod core_arch;
 
 #[stable(feature = "simd_arch", since = "1.27.0")]
diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs
index b5c32e18f87cc..91dd7eaf4e777 100644
--- a/library/std/src/lib.rs
+++ b/library/std/src/lib.rs
@@ -385,7 +385,6 @@
 #![feature(get_many_mut)]
 #![feature(lazy_cell)]
 #![feature(log_syntax)]
-#![feature(stdsimd)]
 #![feature(test)]
 #![feature(trace_macros)]
 // tidy-alphabetical-end
@@ -624,13 +623,16 @@ pub mod arch {
 
     #[stable(feature = "simd_aarch64", since = "1.60.0")]
     pub use std_detect::is_aarch64_feature_detected;
+    #[unstable(feature = "stdarch_arm_feature_detection", issue = "111190")]
+    pub use std_detect::is_arm_feature_detected;
+    #[unstable(feature = "is_riscv_feature_detected", issue = "111192")]
+    pub use std_detect::is_riscv_feature_detected;
     #[stable(feature = "simd_x86", since = "1.27.0")]
     pub use std_detect::is_x86_feature_detected;
-    #[unstable(feature = "stdsimd", issue = "48556")]
-    pub use std_detect::{
-        is_arm_feature_detected, is_mips64_feature_detected, is_mips_feature_detected,
-        is_powerpc64_feature_detected, is_powerpc_feature_detected, is_riscv_feature_detected,
-    };
+    #[unstable(feature = "stdarch_mips_feature_detection", issue = "111188")]
+    pub use std_detect::{is_mips64_feature_detected, is_mips_feature_detected};
+    #[unstable(feature = "stdarch_powerpc_feature_detection", issue = "111191")]
+    pub use std_detect::{is_powerpc64_feature_detected, is_powerpc_feature_detected};
 }
 
 // This was stabilized in the crate root so we have to keep it there.
diff --git a/library/std/tests/run-time-detect.rs b/library/std/tests/run-time-detect.rs
index 9ce29a33df6e6..c9b9c54e3d49c 100644
--- a/library/std/tests/run-time-detect.rs
+++ b/library/std/tests/run-time-detect.rs
@@ -1,12 +1,16 @@
 //! These tests just check that the macros are available in std.
 
 #![cfg_attr(
-    any(
-        all(target_arch = "arm", any(target_os = "linux", target_os = "android")),
-        all(target_arch = "powerpc", target_os = "linux"),
-        all(target_arch = "powerpc64", target_os = "linux"),
-    ),
-    feature(stdsimd)
+    all(target_arch = "arm", any(target_os = "linux", target_os = "android")),
+    feature(stdarch_arm_feature_detection)
+)]
+#![cfg_attr(
+    all(target_arch = "powerpc", target_os = "linux"),
+    feature(stdarch_powerpc_feature_detection)
+)]
+#![cfg_attr(
+    all(target_arch = "powerpc64", target_os = "linux"),
+    feature(stdarch_powerpc_feature_detection)
 )]
 
 #[test]
diff --git a/src/tools/miri/tests/pass/intrinsics-x86-aes-vaes.rs b/src/tools/miri/tests/pass/intrinsics-x86-aes-vaes.rs
index 55d1bacdf4578..7363c75361779 100644
--- a/src/tools/miri/tests/pass/intrinsics-x86-aes-vaes.rs
+++ b/src/tools/miri/tests/pass/intrinsics-x86-aes-vaes.rs
@@ -9,7 +9,7 @@
 //@ignore-target-wasm32
 //@compile-flags: -C target-feature=+aes,+vaes,+avx512f
 
-#![feature(avx512_target_feature, stdsimd)]
+#![feature(avx512_target_feature, stdarch_x86_avx512)]
 
 use core::mem::transmute;
 #[cfg(target_arch = "x86")]
diff --git a/src/tools/miri/tests/pass/intrinsics-x86-avx512.rs b/src/tools/miri/tests/pass/intrinsics-x86-avx512.rs
index 394412a235432..66bfcb20f1c99 100644
--- a/src/tools/miri/tests/pass/intrinsics-x86-avx512.rs
+++ b/src/tools/miri/tests/pass/intrinsics-x86-avx512.rs
@@ -10,7 +10,7 @@
 //@compile-flags: -C target-feature=+avx512f,+avx512vl,+avx512bitalg,+avx512vpopcntdq
 
 #![feature(avx512_target_feature)]
-#![feature(stdsimd)]
+#![feature(stdarch_x86_avx512)]
 
 #[cfg(target_arch = "x86")]
 use std::arch::x86::*;
diff --git a/tests/ui/asm/aarch64/type-check-3.rs b/tests/ui/asm/aarch64/type-check-3.rs
index 623f6593d79ba..77524ba7aa5e4 100644
--- a/tests/ui/asm/aarch64/type-check-3.rs
+++ b/tests/ui/asm/aarch64/type-check-3.rs
@@ -1,7 +1,7 @@
 // only-aarch64
 // compile-flags: -C target-feature=+neon
 
-#![feature(repr_simd, stdsimd, asm_const)]
+#![feature(repr_simd, asm_const)]
 
 use std::arch::aarch64::float64x2_t;
 use std::arch::{asm, global_asm};
diff --git a/tests/ui/asm/aarch64/type-check-4.rs b/tests/ui/asm/aarch64/type-check-4.rs
index bd23755c02316..5dec60a2138d9 100644
--- a/tests/ui/asm/aarch64/type-check-4.rs
+++ b/tests/ui/asm/aarch64/type-check-4.rs
@@ -1,7 +1,7 @@
 // only-aarch64
 // compile-flags: -C target-feature=+neon
 
-#![feature(repr_simd, stdsimd, asm_const)]
+#![feature(repr_simd, asm_const)]
 
 use std::arch::aarch64::float64x2_t;
 use std::arch::{asm, global_asm};

From a00ec2d93bdaad574e339b0306e7bd7d01e3bc44 Mon Sep 17 00:00:00 2001
From: Amanieu d'Antras <amanieu@gmail.com>
Date: Tue, 2 Jan 2024 19:42:47 +0100
Subject: [PATCH 3/6] Update ahash dependency to 0.8.7

---
 Cargo.lock                                  | 12 ++---
 compiler/rustc_codegen_cranelift/Cargo.lock | 60 ++++++++++++++++++++-
 2 files changed, 64 insertions(+), 8 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock
index cab14a7a202b2..e201aed28fe41 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -37,9 +37,9 @@ dependencies = [
 
 [[package]]
 name = "ahash"
-version = "0.8.6"
+version = "0.8.7"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a"
+checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01"
 dependencies = [
  "cfg-if",
  "once_cell",
@@ -6406,18 +6406,18 @@ dependencies = [
 
 [[package]]
 name = "zerocopy"
-version = "0.7.28"
+version = "0.7.32"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7d6f15f7ade05d2a4935e34a457b936c23dc70a05cc1d97133dc99e7a3fe0f0e"
+checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be"
 dependencies = [
  "zerocopy-derive",
 ]
 
 [[package]]
 name = "zerocopy-derive"
-version = "0.7.28"
+version = "0.7.32"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dbbad221e3f78500350ecbd7dfa4e63ef945c05f4c61cb7f4d3f84cd0bba649b"
+checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6"
 dependencies = [
  "proc-macro2",
  "quote",
diff --git a/compiler/rustc_codegen_cranelift/Cargo.lock b/compiler/rustc_codegen_cranelift/Cargo.lock
index 86bc7d0f067cb..b70a1234af398 100644
--- a/compiler/rustc_codegen_cranelift/Cargo.lock
+++ b/compiler/rustc_codegen_cranelift/Cargo.lock
@@ -4,13 +4,14 @@ version = 3
 
 [[package]]
 name = "ahash"
-version = "0.8.3"
+version = "0.8.7"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f"
+checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01"
 dependencies = [
  "cfg-if",
  "once_cell",
  "version_check",
+ "zerocopy",
 ]
 
 [[package]]
@@ -293,6 +294,24 @@ version = "1.18.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
 
+[[package]]
+name = "proc-macro2"
+version = "1.0.75"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "907a61bd0f64c2f29cd1cf1dc34d05176426a3f504a78010f08416ddb7b13708"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.35"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
+dependencies = [
+ "proc-macro2",
+]
+
 [[package]]
 name = "regalloc2"
 version = "0.9.3"
@@ -360,12 +379,29 @@ version = "1.2.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
 
+[[package]]
+name = "syn"
+version = "2.0.47"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1726efe18f42ae774cc644f330953a5e7b3c3003d3edcecf18850fe9d4dd9afb"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
 [[package]]
 name = "target-lexicon"
 version = "0.12.12"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "14c39fd04924ca3a864207c66fc2cd7d22d7c016007f9ce846cbb9326331930a"
 
+[[package]]
+name = "unicode-ident"
+version = "1.0.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
+
 [[package]]
 name = "version_check"
 version = "0.9.4"
@@ -536,3 +572,23 @@ name = "windows_x86_64_msvc"
 version = "0.52.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"
+
+[[package]]
+name = "zerocopy"
+version = "0.7.32"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be"
+dependencies = [
+ "zerocopy-derive",
+]
+
+[[package]]
+name = "zerocopy-derive"
+version = "0.7.32"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]

From bfe6421d0b4ccf0353990e16801043e2a8847cc7 Mon Sep 17 00:00:00 2001
From: Amanieu d'Antras <amanieu@gmail.com>
Date: Thu, 4 Jan 2024 08:34:02 +0000
Subject: [PATCH 4/6] Update allowed depdendencies for cranelift

---
 src/tools/tidy/src/deps.rs | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs
index b06c072a2b0fd..48406d81af532 100644
--- a/src/tools/tidy/src/deps.rs
+++ b/src/tools/tidy/src/deps.rs
@@ -458,13 +458,17 @@ const PERMITTED_CRANELIFT_DEPENDENCIES: &[&str] = &[
     "mach",
     "memchr",
     "object",
+    "proc-macro2",
+    "quote",
     "regalloc2",
     "region",
     "rustc-hash",
     "slice-group-by",
     "smallvec",
     "stable_deref_trait",
+    "syn",
     "target-lexicon",
+    "unicode-ident",
     "version_check",
     "wasmtime-jit-icache-coherence",
     "winapi",
@@ -479,6 +483,8 @@ const PERMITTED_CRANELIFT_DEPENDENCIES: &[&str] = &[
     "windows_x86_64_gnu",
     "windows_x86_64_gnullvm",
     "windows_x86_64_msvc",
+    "zerocopy",
+    "zerocopy-derive",
     // tidy-alphabetical-end
 ];
 

From 31007f51edfd9faf9793046145cfc5986f788b19 Mon Sep 17 00:00:00 2001
From: Amanieu d'Antras <amanieu@gmail.com>
Date: Mon, 8 Jan 2024 13:36:05 +0000
Subject: [PATCH 5/6] Add stdarch_wasm_atomic_wait feature in std

---
 library/std/src/lib.rs | 1 +
 1 file changed, 1 insertion(+)

diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs
index 91dd7eaf4e777..78ce7c74a6936 100644
--- a/library/std/src/lib.rs
+++ b/library/std/src/lib.rs
@@ -262,6 +262,7 @@
 )]
 #![cfg_attr(any(windows, target_os = "uefi"), feature(round_char_boundary))]
 #![cfg_attr(target_os = "xous", feature(slice_ptr_len))]
+#![cfg_attr(target_family = "wasm", feature(stdarch_wasm_atomic_wait))]
 //
 // Language features:
 // tidy-alphabetical-start

From ab8b66166775362dbeb25c8f8898f8760baaf123 Mon Sep 17 00:00:00 2001
From: Amanieu d'Antras <amanieu@gmail.com>
Date: Tue, 30 Jan 2024 03:40:53 +0000
Subject: [PATCH 6/6] Disable conversions between portable_simd and stdarch on
 big-endian ARM

stdarch no longer provide SIMD on big-endian ARM due to
https://github.com/rust-lang/stdarch/issues/1484
---
 library/portable-simd/crates/core_simd/src/vendor/arm.rs | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/library/portable-simd/crates/core_simd/src/vendor/arm.rs b/library/portable-simd/crates/core_simd/src/vendor/arm.rs
index ff3b69ccf9592..ee5c642137367 100644
--- a/library/portable-simd/crates/core_simd/src/vendor/arm.rs
+++ b/library/portable-simd/crates/core_simd/src/vendor/arm.rs
@@ -7,9 +7,12 @@ use core::arch::arm::*;
 #[cfg(target_arch = "aarch64")]
 use core::arch::aarch64::*;
 
-#[cfg(any(
-    target_arch = "aarch64",
-    all(target_arch = "arm", target_feature = "v7"),
+#[cfg(all(
+    any(
+        target_arch = "aarch64",
+        all(target_arch = "arm", target_feature = "v7"),
+    ),
+    target_endian = "little"
 ))]
 mod neon {
     use super::*;