From 88c3719c683b6a9ffe8f9d595e50b686651a7f70 Mon Sep 17 00:00:00 2001
From: bjorn3 <bjorn3@users.noreply.github.com>
Date: Tue, 15 Mar 2022 17:42:51 +0100
Subject: [PATCH] Avoid once_cell unstable feature in cg_clif.rs

---
 Cargo.toml         |  4 ++--
 src/bin/cg_clif.rs | 12 +++++++-----
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index dbe370d9f01..70c03da3f29 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -21,7 +21,7 @@ object = { version = "0.27.0", default-features = false, features = ["std", "rea
 ar = { git = "https://github.com/bjorn3/rust-ar.git", branch = "do_not_remove_cg_clif_ranlib" }
 indexmap = "1.8.0"
 libloading = { version = "0.6.0", optional = true }
-once_cell = { version = "1.10.0", optional = true }
+once_cell = "1.10.0"
 smallvec = "1.6.1"
 
 [patch.crates-io]
@@ -38,7 +38,7 @@ smallvec = "1.6.1"
 [features]
 # Enable features not ready to be enabled when compiling as part of rustc
 unstable-features = ["jit", "inline_asm"]
-jit = ["cranelift-jit", "libloading", "once_cell"]
+jit = ["cranelift-jit", "libloading"]
 inline_asm = []
 
 # Disable optimizations and debuginfo of build scripts and some of the heavy build deps, as the
diff --git a/src/bin/cg_clif.rs b/src/bin/cg_clif.rs
index b924f2085a0..a8fb09e69b7 100644
--- a/src/bin/cg_clif.rs
+++ b/src/bin/cg_clif.rs
@@ -1,4 +1,4 @@
-#![feature(rustc_private, once_cell)]
+#![feature(rustc_private)]
 #![warn(rust_2018_idioms)]
 #![warn(unused_lifetimes)]
 #![warn(unreachable_pub)]
@@ -9,7 +9,6 @@ extern crate rustc_interface;
 extern crate rustc_session;
 extern crate rustc_target;
 
-use std::lazy::SyncLazy;
 use std::panic;
 
 use rustc_data_structures::profiling::{get_resident_set_size, print_time_passes_entry};
@@ -18,10 +17,13 @@ use rustc_session::config::ErrorOutputType;
 use rustc_session::early_error;
 use rustc_target::spec::PanicStrategy;
 
+// FIXME use std::lazy::SyncLazy once it stabilizes
+use once_cell::sync::Lazy;
+
 const BUG_REPORT_URL: &str = "https://github.com/bjorn3/rustc_codegen_cranelift/issues/new";
 
-static DEFAULT_HOOK: SyncLazy<Box<dyn Fn(&panic::PanicInfo<'_>) + Sync + Send + 'static>> =
-    SyncLazy::new(|| {
+static DEFAULT_HOOK: Lazy<Box<dyn Fn(&panic::PanicInfo<'_>) + Sync + Send + 'static>> =
+    Lazy::new(|| {
         let hook = panic::take_hook();
         panic::set_hook(Box::new(|info| {
             // Invoke the default handler, which prints the actual panic message and optionally a backtrace
@@ -61,7 +63,7 @@ fn main() {
     let start_rss = get_resident_set_size();
     rustc_driver::init_rustc_env_logger();
     let mut callbacks = CraneliftPassesCallbacks::default();
-    SyncLazy::force(&DEFAULT_HOOK); // Install ice hook
+    Lazy::force(&DEFAULT_HOOK); // Install ice hook
     let exit_code = rustc_driver::catch_with_exit_code(|| {
         let args = std::env::args_os()
             .enumerate()