mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-05 11:33:04 +00:00
Don't read CG_CLIF_JIT from init_global_lock
In preparation to moving away from an env var
This commit is contained in:
parent
787d078fb6
commit
838dd17a67
@ -10,10 +10,14 @@ use crate::prelude::*;
|
||||
pub static mut __cg_clif_global_atomic_mutex: libc::pthread_mutex_t =
|
||||
libc::PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
pub(crate) fn init_global_lock(module: &mut Module<impl Backend>, bcx: &mut FunctionBuilder<'_>) {
|
||||
if std::env::var("CG_CLIF_JIT").is_ok() {
|
||||
pub(crate) fn init_global_lock(
|
||||
module: &mut Module<impl Backend>,
|
||||
bcx: &mut FunctionBuilder<'_>,
|
||||
use_jit: bool,
|
||||
) {
|
||||
if use_jit {
|
||||
// When using JIT, dylibs won't find the __cg_clif_global_atomic_mutex data object defined here,
|
||||
// so instead define it in the cg_clif dylib.
|
||||
// so instead we define it in the cg_clif dylib.
|
||||
|
||||
return;
|
||||
}
|
||||
@ -80,7 +84,7 @@ pub(crate) fn init_global_lock_constructor(
|
||||
let block = bcx.create_block();
|
||||
bcx.switch_to_block(block);
|
||||
|
||||
crate::atomic_shim::init_global_lock(module, &mut bcx);
|
||||
crate::atomic_shim::init_global_lock(module, &mut bcx, false);
|
||||
|
||||
bcx.ins().return_(&[]);
|
||||
bcx.seal_all_blocks();
|
||||
|
@ -150,7 +150,7 @@ fn module_codegen(tcx: TyCtxt<'_>, cgu_name: rustc_span::Symbol) -> ModuleCodege
|
||||
super::codegen_mono_items(&mut cx, mono_items);
|
||||
let (mut module, global_asm, debug, mut unwind_context) =
|
||||
tcx.sess.time("finalize CodegenCx", || cx.finalize());
|
||||
crate::main_shim::maybe_create_entry_wrapper(tcx, &mut module, &mut unwind_context);
|
||||
crate::main_shim::maybe_create_entry_wrapper(tcx, &mut module, &mut unwind_context, false);
|
||||
|
||||
let codegen_result = emit_module(
|
||||
tcx,
|
||||
|
@ -76,7 +76,7 @@ pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! {
|
||||
if !global_asm.is_empty() {
|
||||
tcx.sess.fatal("Global asm is not supported in JIT mode");
|
||||
}
|
||||
crate::main_shim::maybe_create_entry_wrapper(tcx, &mut jit_module, &mut unwind_context);
|
||||
crate::main_shim::maybe_create_entry_wrapper(tcx, &mut jit_module, &mut unwind_context, true);
|
||||
crate::allocator::codegen(tcx, &mut jit_module, &mut unwind_context);
|
||||
|
||||
jit_module.finalize_definitions();
|
||||
|
@ -9,6 +9,7 @@ pub(crate) fn maybe_create_entry_wrapper(
|
||||
tcx: TyCtxt<'_>,
|
||||
module: &mut Module<impl Backend + 'static>,
|
||||
unwind_context: &mut UnwindContext<'_>,
|
||||
use_jit: bool,
|
||||
) {
|
||||
let (main_def_id, use_start_lang_item) = match tcx.entry_fn(LOCAL_CRATE) {
|
||||
Some((def_id, entry_ty)) => (
|
||||
@ -32,6 +33,7 @@ pub(crate) fn maybe_create_entry_wrapper(
|
||||
unwind_context,
|
||||
main_def_id,
|
||||
use_start_lang_item,
|
||||
use_jit,
|
||||
);
|
||||
|
||||
fn create_entry_fn(
|
||||
@ -40,6 +42,7 @@ pub(crate) fn maybe_create_entry_wrapper(
|
||||
unwind_context: &mut UnwindContext<'_>,
|
||||
rust_main_def_id: DefId,
|
||||
use_start_lang_item: bool,
|
||||
use_jit: bool,
|
||||
) {
|
||||
let main_ret_ty = tcx.fn_sig(rust_main_def_id).output();
|
||||
// Given that `main()` has no arguments,
|
||||
@ -83,7 +86,7 @@ pub(crate) fn maybe_create_entry_wrapper(
|
||||
let arg_argc = bcx.append_block_param(block, m.target_config().pointer_type());
|
||||
let arg_argv = bcx.append_block_param(block, m.target_config().pointer_type());
|
||||
|
||||
crate::atomic_shim::init_global_lock(m, &mut bcx);
|
||||
crate::atomic_shim::init_global_lock(m, &mut bcx, use_jit);
|
||||
|
||||
let main_func_ref = m.declare_func_in_func(main_func_id, &mut bcx.func);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user