Remove almost all remaining feature gates
Only rustc_private is still enabled as cg_clif by definition needs to use internal rustc api's.
This commit is contained in:
parent
cfc1a2cd68
commit
fef517eae7
7
Cargo.lock
generated
7
Cargo.lock
generated
@ -228,6 +228,12 @@ dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[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"
|
||||
@ -272,6 +278,7 @@ dependencies = [
|
||||
"indexmap",
|
||||
"libloading",
|
||||
"object",
|
||||
"once_cell",
|
||||
"smallvec",
|
||||
"target-lexicon",
|
||||
]
|
||||
|
@ -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
|
||||
|
@ -81,6 +81,8 @@ pub(crate) unsafe fn register_jit(self, _jit_module: &cranelift_jit::JITModule)
|
||||
|
||||
#[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 @@ pub(crate) unsafe fn register_jit(self, jit_module: &cranelift_jit::JITModule) {
|
||||
|
||||
// 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 @@ pub(crate) unsafe fn register_jit(self, jit_module: &cranelift_jit::JITModule) {
|
||||
#[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 @@ pub(crate) unsafe fn register_jit(self, jit_module: &cranelift_jit::JITModule) {
|
||||
#[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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 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 @@ struct JitState {
|
||||
}
|
||||
|
||||
/// 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.
|
||||
|
@ -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 @@ fn codegen_crate(
|
||||
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");
|
||||
|
Loading…
Reference in New Issue
Block a user