about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <bjorn3@users.noreply.github.com>2022-03-13 15:31:34 +0100
committerbjorn3 <bjorn3@users.noreply.github.com>2022-03-13 17:55:55 +0100
commitfef517eae74336ef290c3982ab5543458b7b9b5a (patch)
treee111a3d9daaf1a75e32d889b2839b8f0c020b0f2
parentcfc1a2cd6832f62aed7be6292a89e31dc29da056 (diff)
downloadrust-fef517eae74336ef290c3982ab5543458b7b9b5a.tar.gz
rust-fef517eae74336ef290c3982ab5543458b7b9b5a.zip
Remove almost all remaining feature gates
Only rustc_private is still enabled as cg_clif by definition needs to
use internal rustc api's.
-rw-r--r--Cargo.lock7
-rw-r--r--Cargo.toml3
-rw-r--r--src/debuginfo/unwind.rs11
-rw-r--r--src/driver/jit.rs7
-rw-r--r--src/lib.rs4
5 files changed, 21 insertions, 11 deletions
diff --git a/Cargo.lock b/Cargo.lock
index f226a03672c..30e9627c48d 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -229,6 +229,12 @@ dependencies = [
 ]
 
 [[package]]
+name = "once_cell"
+version = "1.10.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9"
+
+[[package]]
 name = "regalloc"
 version = "0.0.34"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -272,6 +278,7 @@ dependencies = [
  "indexmap",
  "libloading",
  "object",
+ "once_cell",
  "smallvec",
  "target-lexicon",
 ]
diff --git a/Cargo.toml b/Cargo.toml
index 02a67d18441..dbe370d9f01 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -21,6 +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 }
 smallvec = "1.6.1"
 
 [patch.crates-io]
@@ -37,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"]
+jit = ["cranelift-jit", "libloading", "once_cell"]
 inline_asm = []
 
 # Disable optimizations and debuginfo of build scripts and some of the heavy build deps, as the
diff --git a/src/debuginfo/unwind.rs b/src/debuginfo/unwind.rs
index cc9ccbaf43f..d26392c4913 100644
--- a/src/debuginfo/unwind.rs
+++ b/src/debuginfo/unwind.rs
@@ -81,6 +81,8 @@ impl UnwindContext {
 
     #[cfg(all(feature = "jit", not(windows)))]
     pub(crate) unsafe fn register_jit(self, jit_module: &cranelift_jit::JITModule) {
+        use std::mem::ManuallyDrop;
+
         let mut eh_frame = EhFrame::from(super::emit::WriterRelocate::new(self.endian));
         self.frame_table.write_eh_frame(&mut eh_frame).unwrap();
 
@@ -95,8 +97,7 @@ impl UnwindContext {
 
         // FIXME support unregistering unwind tables once cranelift-jit supports deallocating
         // individual functions
-        #[allow(unused_variables)]
-        let (eh_frame, eh_frame_len, _) = Vec::into_raw_parts(eh_frame);
+        let eh_frame = ManuallyDrop::new(eh_frame);
 
         // =======================================================================
         // Everything after this line up to the end of the file is loosely based on
@@ -104,8 +105,8 @@ impl UnwindContext {
         #[cfg(target_os = "macos")]
         {
             // On macOS, `__register_frame` takes a pointer to a single FDE
-            let start = eh_frame;
-            let end = start.add(eh_frame_len);
+            let start = eh_frame.as_ptr();
+            let end = start.add(eh_frame.len());
             let mut current = start;
 
             // Walk all of the entries in the frame table and register them
@@ -124,7 +125,7 @@ impl UnwindContext {
         #[cfg(not(target_os = "macos"))]
         {
             // On other platforms, `__register_frame` will walk the FDEs until an entry of length 0
-            __register_frame(eh_frame);
+            __register_frame(eh_frame.as_ptr());
         }
     }
 }
diff --git a/src/driver/jit.rs b/src/driver/jit.rs
index 9e07528313d..6c22296db71 100644
--- a/src/driver/jit.rs
+++ b/src/driver/jit.rs
@@ -3,7 +3,6 @@
 
 use std::cell::RefCell;
 use std::ffi::CString;
-use std::lazy::SyncOnceCell;
 use std::os::raw::{c_char, c_int};
 use std::sync::{mpsc, Mutex};
 
@@ -14,6 +13,9 @@ use rustc_span::Symbol;
 
 use cranelift_jit::{JITBuilder, JITModule};
 
+// FIXME use std::lazy::SyncOnceCell once it stabilizes
+use once_cell::sync::OnceCell;
+
 use crate::{prelude::*, BackendConfig};
 use crate::{CodegenCx, CodegenMode};
 
@@ -27,8 +29,7 @@ thread_local! {
 }
 
 /// The Sender owned by the rustc thread
-static GLOBAL_MESSAGE_SENDER: SyncOnceCell<Mutex<mpsc::Sender<UnsafeMessage>>> =
-    SyncOnceCell::new();
+static GLOBAL_MESSAGE_SENDER: OnceCell<Mutex<mpsc::Sender<UnsafeMessage>>> = OnceCell::new();
 
 /// A message that is sent from the jitted runtime to the rustc thread.
 /// Senders are responsible for upholding `Send` semantics.
diff --git a/src/lib.rs b/src/lib.rs
index 8b517104df2..a3c794fb156 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,5 +1,5 @@
 #![feature(rustc_private)]
-#![cfg_attr(feature = "jit", feature(never_type, vec_into_raw_parts, once_cell))]
+// Note: please avoid adding other feature gates where possible
 #![warn(rust_2018_idioms)]
 #![warn(unused_lifetimes)]
 #![warn(unreachable_pub)]
@@ -196,7 +196,7 @@ impl CodegenBackend for CraneliftCodegenBackend {
             CodegenMode::Aot => driver::aot::run_aot(tcx, config, metadata, need_metadata_module),
             CodegenMode::Jit | CodegenMode::JitLazy => {
                 #[cfg(feature = "jit")]
-                let _: ! = driver::jit::run_jit(tcx, config);
+                driver::jit::run_jit(tcx, config);
 
                 #[cfg(not(feature = "jit"))]
                 tcx.sess.fatal("jit support was disabled when compiling rustc_codegen_cranelift");