From d0f97fc03902ade979ede7cd9b51aff30e7822b9 Mon Sep 17 00:00:00 2001
From: bjorn3 <bjorn3@users.noreply.github.com>
Date: Thu, 16 Dec 2021 14:10:51 +0100
Subject: [PATCH] Rustup to rustc 1.59.0-nightly (c5ecc1570 2021-12-15)

---
 build_sysroot/Cargo.lock   |  6 +++---
 build_system/prepare.rs    |  2 +-
 rust-toolchain             |  2 +-
 scripts/setup_rust_fork.sh |  2 +-
 src/inline_asm.rs          | 12 ++++++++----
 5 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/build_sysroot/Cargo.lock b/build_sysroot/Cargo.lock
index 5c7168e62f2..dd096562480 100644
--- a/build_sysroot/Cargo.lock
+++ b/build_sysroot/Cargo.lock
@@ -56,7 +56,7 @@ dependencies = [
 
 [[package]]
 name = "compiler_builtins"
-version = "0.1.55"
+version = "0.1.66"
 dependencies = [
  "rustc-std-workspace-core",
 ]
@@ -132,9 +132,9 @@ dependencies = [
 
 [[package]]
 name = "libc"
-version = "0.2.109"
+version = "0.2.112"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f98a04dce437184842841303488f70d0188c5f51437d2a834dc097eafa909a01"
+checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125"
 dependencies = [
  "rustc-std-workspace-core",
 ]
diff --git a/build_system/prepare.rs b/build_system/prepare.rs
index 0e39320a93c..561e2ed7b00 100644
--- a/build_system/prepare.rs
+++ b/build_system/prepare.rs
@@ -92,7 +92,7 @@ fn prepare_sysroot() {
     clone_repo(
         "build_sysroot/compiler-builtins",
         "https://github.com/rust-lang/compiler-builtins.git",
-        "0.1.55",
+        "0.1.66",
     );
     apply_patches("compiler-builtins", Path::new("build_sysroot/compiler-builtins"));
 }
diff --git a/rust-toolchain b/rust-toolchain
index d396e526e38..c1d856702a9 100644
--- a/rust-toolchain
+++ b/rust-toolchain
@@ -1,3 +1,3 @@
 [toolchain]
-channel = "nightly-2021-12-09"
+channel = "nightly-2021-12-16"
 components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
diff --git a/scripts/setup_rust_fork.sh b/scripts/setup_rust_fork.sh
index 80bf40dd874..46c3b5b7f11 100644
--- a/scripts/setup_rust_fork.sh
+++ b/scripts/setup_rust_fork.sh
@@ -33,7 +33,7 @@ index d95b5b7f17f..00b6f0e3635 100644
  [dependencies]
  core = { path = "../core" }
 -compiler_builtins = { version = "0.1.40", features = ['rustc-dep-of-std'] }
-+compiler_builtins = { version = "0.1.53", features = ['rustc-dep-of-std', 'no-asm'] }
++compiler_builtins = { version = "0.1.66", features = ['rustc-dep-of-std', 'no-asm'] }
 
  [dev-dependencies]
  rand = "0.7"
diff --git a/src/inline_asm.rs b/src/inline_asm.rs
index 30ab7bc4980..93384bc5511 100644
--- a/src/inline_asm.rs
+++ b/src/inline_asm.rs
@@ -317,10 +317,14 @@ impl<'tcx> InlineAssemblyGenerator<'_, 'tcx> {
         let mut new_slot = |x| new_slot_fn(&mut slot_size, x);
 
         // Allocate stack slots for saving clobbered registers
-        let abi_clobber =
-            InlineAsmClobberAbi::parse(self.arch, &self.tcx.sess.target, Symbol::intern("C"))
-                .unwrap()
-                .clobbered_regs();
+        let abi_clobber = InlineAsmClobberAbi::parse(
+            self.arch,
+            |feature| self.tcx.sess.target_features.contains(&Symbol::intern(feature)),
+            &self.tcx.sess.target,
+            Symbol::intern("C"),
+        )
+        .unwrap()
+        .clobbered_regs();
         for (i, reg) in self.registers.iter().enumerate().filter_map(|(i, r)| r.map(|r| (i, r))) {
             let mut need_save = true;
             // If the register overlaps with a register clobbered by function call, then