about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <bjorn3@users.noreply.github.com>2020-09-29 18:12:23 +0200
committerbjorn3 <bjorn3@users.noreply.github.com>2020-09-29 18:12:23 +0200
commit838dd17a67b750bce9fcca149759db236f145eea (patch)
tree2bd1bfc8ccf55967ecd11554b58514d15a593e95
parent787d078fb6bdc425e71b5277fd7312b46beab165 (diff)
downloadrust-838dd17a67b750bce9fcca149759db236f145eea.tar.gz
rust-838dd17a67b750bce9fcca149759db236f145eea.zip
Don't read CG_CLIF_JIT from init_global_lock
In preparation to moving away from an env var
-rw-r--r--src/atomic_shim.rs12
-rw-r--r--src/driver/aot.rs2
-rw-r--r--src/driver/jit.rs2
-rw-r--r--src/main_shim.rs5
4 files changed, 14 insertions, 7 deletions
diff --git a/src/atomic_shim.rs b/src/atomic_shim.rs
index 2f9f9e3a4f7..f29e269c01f 100644
--- a/src/atomic_shim.rs
+++ b/src/atomic_shim.rs
@@ -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();
diff --git a/src/driver/aot.rs b/src/driver/aot.rs
index 2cf136ceb67..fc01398c40d 100644
--- a/src/driver/aot.rs
+++ b/src/driver/aot.rs
@@ -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,
diff --git a/src/driver/jit.rs b/src/driver/jit.rs
index fd3a628922d..9f8426961ee 100644
--- a/src/driver/jit.rs
+++ b/src/driver/jit.rs
@@ -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();
diff --git a/src/main_shim.rs b/src/main_shim.rs
index 520a54b8e53..c4b21dcecd3 100644
--- a/src/main_shim.rs
+++ b/src/main_shim.rs
@@ -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);