Skip to content

Commit

Permalink
Use IntoDynSyncSend
Browse files Browse the repository at this point in the history
  • Loading branch information
antoyo committed Oct 9, 2023
1 parent 2cbac9c commit 06c5ac4
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions compiler/rustc_codegen_gcc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ mod type_;
mod type_of;

use std::any::Any;
use std::fmt::Debug;
use std::sync::Arc;
use std::sync::Mutex;
#[cfg(not(feature="master"))]
Expand All @@ -93,6 +94,7 @@ use rustc_codegen_ssa::back::write::{CodegenContext, FatLtoInput, ModuleConfig,
use rustc_codegen_ssa::back::lto::{LtoModuleCodegen, SerializedModule, ThinModule};
use rustc_codegen_ssa::target_features::supported_target_features;
use rustc_data_structures::fx::FxIndexMap;
use rustc_data_structures::sync::IntoDynSyncSend;
use rustc_codegen_ssa::traits::{CodegenBackend, ExtraBackendMethods, ThinBufferMethods, WriteBackendMethods};
use rustc_errors::{DiagnosticMessage, ErrorGuaranteed, Handler, SubdiagnosticMessage};
use rustc_fluent_macro::fluent_messages;
Expand Down Expand Up @@ -138,9 +140,15 @@ impl TargetInfo {
}
}

#[derive(Clone, Debug)]
#[derive(Clone)]
pub struct LockedTargetInfo {
info: Arc<Mutex<TargetInfo>>,
info: Arc<Mutex<IntoDynSyncSend<TargetInfo>>>,
}

impl Debug for LockedTargetInfo {
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.info.lock().expect("lock").fmt(formatter)
}
}

impl LockedTargetInfo {
Expand Down Expand Up @@ -174,7 +182,7 @@ impl CodegenBackend for GccCodegenBackend {
context.add_command_line_option(&format!("-march={}", target_cpu));
}

*self.target_info.info.lock().expect("lock") = context.get_target_info();
**self.target_info.info.lock().expect("lock") = context.get_target_info();
}

#[cfg(feature="master")]
Expand Down Expand Up @@ -340,12 +348,12 @@ pub fn __rustc_codegen_backend() -> Box<dyn CodegenBackend> {
let info = {
// Check whether the target supports 128-bit integers.
let context = Context::default();
Arc::new(Mutex::new(context.get_target_info()))
Arc::new(Mutex::new(IntoDynSyncSend(context.get_target_info())))
};
#[cfg(not(feature="master"))]
let info = Arc::new(Mutex::new(TargetInfo {
let info = Arc::new(Mutex::new(IntoDynSyncSend(TargetInfo {
supports_128bit_integers: AtomicBool::new(false),
}));
})));

Box::new(GccCodegenBackend {
target_info: LockedTargetInfo { info },
Expand Down

0 comments on commit 06c5ac4

Please sign in to comment.