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