Fix clippy warnings
This commit is contained in:
parent
21b1b11981
commit
bbc765b49b
@ -39,7 +39,7 @@
|
||||
|
||||
use crate::back::write::save_temp_bitcode;
|
||||
use crate::errors::{DynamicLinkingWithLTO, LtoBitcodeFromRlib, LtoDisallowed, LtoDylib};
|
||||
use crate::{to_gcc_opt_level, GccCodegenBackend, GccContext};
|
||||
use crate::{to_gcc_opt_level, GccCodegenBackend, GccContext, SyncContext};
|
||||
|
||||
/// We keep track of the computed LTO cache keys from the previous
|
||||
/// session to determine which CGUs we can reuse.
|
||||
@ -485,9 +485,9 @@ fn thin_lto(
|
||||
});*/
|
||||
|
||||
match module {
|
||||
SerializedModule::Local(ref module_buffer) => {
|
||||
let path = module_buffer.0.to_str().expect("path");
|
||||
let my_path = PathBuf::from(path);
|
||||
SerializedModule::Local(_) => {
|
||||
//let path = module_buffer.0.to_str().expect("path");
|
||||
//let my_path = PathBuf::from(path);
|
||||
//let exists = my_path.exists();
|
||||
//println!("Path: {:?}: {}", path, exists);
|
||||
/*module.module_llvm.should_combine_object_files = true;
|
||||
@ -644,7 +644,7 @@ pub unsafe fn optimize_thin_module(
|
||||
unimplemented!("from uncompressed file")
|
||||
}
|
||||
}
|
||||
Arc::new(context)
|
||||
Arc::new(SyncContext::new(context))
|
||||
}
|
||||
};
|
||||
let module = ModuleCodegen {
|
||||
@ -718,7 +718,7 @@ pub unsafe fn optimize_thin_module(
|
||||
}
|
||||
|
||||
pub struct ThinBuffer {
|
||||
context: Arc<Context<'static>>,
|
||||
context: Arc<SyncContext>,
|
||||
}
|
||||
|
||||
// TODO: check if this makes sense to make ThinBuffer Send and Sync.
|
||||
@ -726,7 +726,7 @@ unsafe impl Send for ThinBuffer {}
|
||||
unsafe impl Sync for ThinBuffer {}
|
||||
|
||||
impl ThinBuffer {
|
||||
pub fn new(context: &Arc<Context<'static>>) -> Self {
|
||||
pub(crate) fn new(context: &Arc<SyncContext>) -> Self {
|
||||
Self { context: Arc::clone(context) }
|
||||
}
|
||||
}
|
||||
|
@ -19,8 +19,8 @@
|
||||
|
||||
use crate::builder::Builder;
|
||||
use crate::context::CodegenCx;
|
||||
use crate::GccContext;
|
||||
use crate::{gcc_util, new_context, LockedTargetInfo};
|
||||
use crate::{GccContext, SyncContext};
|
||||
|
||||
#[cfg(feature = "master")]
|
||||
pub fn visibility_to_gcc(linkage: Visibility) -> gccjit::Visibility {
|
||||
@ -207,7 +207,7 @@ fn module_codegen(
|
||||
ModuleCodegen {
|
||||
name: cgu_name.to_string(),
|
||||
module_llvm: GccContext {
|
||||
context: Arc::new(context),
|
||||
context: Arc::new(SyncContext::new(context)),
|
||||
should_combine_object_files: false,
|
||||
temp_dir: None,
|
||||
},
|
||||
|
30
src/lib.rs
30
src/lib.rs
@ -73,6 +73,7 @@
|
||||
|
||||
use std::any::Any;
|
||||
use std::fmt::Debug;
|
||||
use std::ops::Deref;
|
||||
#[cfg(not(feature = "master"))]
|
||||
use std::sync::atomic::AtomicBool;
|
||||
#[cfg(not(feature = "master"))]
|
||||
@ -294,7 +295,7 @@ fn codegen_allocator(
|
||||
alloc_error_handler_kind: AllocatorKind,
|
||||
) -> Self::Module {
|
||||
let mut mods = GccContext {
|
||||
context: Arc::new(new_context(tcx)),
|
||||
context: Arc::new(SyncContext::new(new_context(tcx))),
|
||||
should_combine_object_files: false,
|
||||
temp_dir: None,
|
||||
};
|
||||
@ -325,15 +326,34 @@ fn target_machine_factory(
|
||||
}
|
||||
|
||||
pub struct GccContext {
|
||||
context: Arc<Context<'static>>,
|
||||
context: Arc<SyncContext>,
|
||||
should_combine_object_files: bool,
|
||||
// Temporary directory used by LTO. We keep it here so that it's not removed before linking.
|
||||
temp_dir: Option<TempDir>,
|
||||
}
|
||||
|
||||
unsafe impl Send for GccContext {}
|
||||
// FIXME(antoyo): that shouldn't be Sync. Parallel compilation is currently disabled with "-Zno-parallel-llvm". Try to disable it here.
|
||||
unsafe impl Sync for GccContext {}
|
||||
struct SyncContext {
|
||||
context: Context<'static>,
|
||||
}
|
||||
|
||||
impl SyncContext {
|
||||
fn new(context: Context<'static>) -> Self {
|
||||
Self { context }
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for SyncContext {
|
||||
type Target = Context<'static>;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.context
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl Send for SyncContext {}
|
||||
// FIXME(antoyo): that shouldn't be Sync. Parallel compilation is currently disabled with "-Zno-parallel-llvm".
|
||||
// TODO: disable it here by returing false in CodegenBackend::supports_parallel().
|
||||
unsafe impl Sync for SyncContext {}
|
||||
|
||||
impl WriteBackendMethods for GccCodegenBackend {
|
||||
type Module = GccContext;
|
||||
|
Loading…
Reference in New Issue
Block a user