Add a feature flag for the JIT
This commit is contained in:
parent
b6150be206
commit
ac77371852
@ -12,6 +12,7 @@ crate-type = ["dylib"]
|
|||||||
cranelift-codegen = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main", features = ["unwind"] }
|
cranelift-codegen = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main", features = ["unwind"] }
|
||||||
cranelift-frontend = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" }
|
cranelift-frontend = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" }
|
||||||
cranelift-module = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" }
|
cranelift-module = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" }
|
||||||
|
cranelift-simplejit = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main", optional = true }
|
||||||
cranelift-object = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" }
|
cranelift-object = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" }
|
||||||
target-lexicon = "0.10.0"
|
target-lexicon = "0.10.0"
|
||||||
|
|
||||||
@ -19,6 +20,7 @@ ar = "0.8.0"
|
|||||||
byteorder = "1.2.7"
|
byteorder = "1.2.7"
|
||||||
indexmap = "1.0.2"
|
indexmap = "1.0.2"
|
||||||
cfg-if = "0.1.10"
|
cfg-if = "0.1.10"
|
||||||
|
libloading = { version = "0.6.0", optional = true }
|
||||||
|
|
||||||
[dependencies.object]
|
[dependencies.object]
|
||||||
version = "0.20.0"
|
version = "0.20.0"
|
||||||
@ -41,9 +43,9 @@ features = ["write"] # We don't need read support
|
|||||||
#[patch.crates-io]
|
#[patch.crates-io]
|
||||||
#gimli = { path = "../" }
|
#gimli = { path = "../" }
|
||||||
|
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[features]
|
||||||
cranelift-simplejit = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" }
|
default = ["jit"]
|
||||||
libloading = "0.6.0"
|
jit = ["cranelift-simplejit", "libloading"]
|
||||||
|
|
||||||
[profile.dev]
|
[profile.dev]
|
||||||
# By compiling dependencies with optimizations, performing tests gets much faster.
|
# By compiling dependencies with optimizations, performing tests gets much faster.
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
|
#[cfg(feature = "jit")]
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub static mut __cg_clif_global_atomic_mutex: libc::pthread_mutex_t = libc::PTHREAD_MUTEX_INITIALIZER;
|
pub static mut __cg_clif_global_atomic_mutex: libc::pthread_mutex_t = libc::PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
use std::convert::TryInto;
|
|
||||||
|
|
||||||
use rustc_data_structures::fx::FxHashMap;
|
use rustc_data_structures::fx::FxHashMap;
|
||||||
|
|
||||||
use gimli::write::{Address, AttributeValue, EndianVec, Result, Sections, Writer};
|
use gimli::write::{Address, AttributeValue, EndianVec, Result, Sections, Writer};
|
||||||
@ -70,10 +68,13 @@ impl WriterRelocate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "jit")]
|
||||||
pub(super) fn relocate_for_jit(
|
pub(super) fn relocate_for_jit(
|
||||||
mut self,
|
mut self,
|
||||||
jit_module: &mut cranelift_module::Module<cranelift_simplejit::SimpleJITBackend>,
|
jit_module: &mut cranelift_module::Module<cranelift_simplejit::SimpleJITBackend>,
|
||||||
) -> Vec<u8> {
|
) -> Vec<u8> {
|
||||||
|
use std::convert::TryInto;
|
||||||
|
|
||||||
for reloc in self.relocs.drain(..) {
|
for reloc in self.relocs.drain(..) {
|
||||||
match reloc.name {
|
match reloc.name {
|
||||||
super::DebugRelocName::Section(_) => unreachable!(),
|
super::DebugRelocName::Section(_) => unreachable!(),
|
||||||
|
@ -69,6 +69,7 @@ impl<'tcx> UnwindContext<'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "jit")]
|
||||||
pub(crate) unsafe fn register_jit(
|
pub(crate) unsafe fn register_jit(
|
||||||
self,
|
self,
|
||||||
jit_module: &mut Module<cranelift_simplejit::SimpleJITBackend>,
|
jit_module: &mut Module<cranelift_simplejit::SimpleJITBackend>,
|
||||||
|
@ -6,7 +6,7 @@ use rustc_middle::mir::mono::{Linkage as RLinkage, MonoItem, Visibility};
|
|||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
mod aot;
|
mod aot;
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(feature = "jit")]
|
||||||
mod jit;
|
mod jit;
|
||||||
|
|
||||||
pub(crate) fn codegen_crate(
|
pub(crate) fn codegen_crate(
|
||||||
@ -19,11 +19,11 @@ pub(crate) fn codegen_crate(
|
|||||||
if std::env::var("CG_CLIF_JIT").is_ok()
|
if std::env::var("CG_CLIF_JIT").is_ok()
|
||||||
&& tcx.sess.crate_types().contains(&rustc_session::config::CrateType::Executable)
|
&& tcx.sess.crate_types().contains(&rustc_session::config::CrateType::Executable)
|
||||||
{
|
{
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(feature = "jit")]
|
||||||
let _: ! = jit::run_jit(tcx);
|
let _: ! = jit::run_jit(tcx);
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(not(feature = "jit"))]
|
||||||
panic!("jit not supported on wasm");
|
tcx.sess.fatal("jit support was disabled when compiling rustc_codegen_cranelift");
|
||||||
}
|
}
|
||||||
|
|
||||||
aot::run_aot(tcx, metadata, need_metadata_module)
|
aot::run_aot(tcx, metadata, need_metadata_module)
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#![warn(unused_lifetimes)]
|
#![warn(unused_lifetimes)]
|
||||||
|
|
||||||
extern crate flate2;
|
extern crate flate2;
|
||||||
|
#[cfg(feature = "jit")]
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
extern crate rustc_middle;
|
extern crate rustc_middle;
|
||||||
extern crate rustc_codegen_ssa;
|
extern crate rustc_codegen_ssa;
|
||||||
|
Loading…
Reference in New Issue
Block a user