parent
2d123d08c9
commit
bc8520d98e
8 changed files with 33 additions and 21 deletions
|
|
@ -307,7 +307,6 @@ fn fat_lto(
|
|||
match bc_decoded {
|
||||
SerializedModule::Local(ref module_buffer) => {
|
||||
module.module_llvm.should_combine_object_files = true;
|
||||
module.module_llvm.fat_lto = true;
|
||||
module
|
||||
.module_llvm
|
||||
.context
|
||||
|
|
@ -490,6 +489,7 @@ fn thin_lto(
|
|||
//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;
|
||||
module
|
||||
.module_llvm
|
||||
|
|
@ -626,6 +626,11 @@ pub unsafe fn optimize_thin_module(
|
|||
match *module {
|
||||
SerializedModule::Local(ref module_buffer) => {
|
||||
let path = module_buffer.0.to_str().expect("path");
|
||||
|
||||
//let my_path = PathBuf::from(path);
|
||||
//let exists = my_path.exists();
|
||||
//println!("Path2: {:?}: {}", path, exists);
|
||||
|
||||
context.add_driver_option(path);
|
||||
should_combine_object_files = true;
|
||||
/*module.module_llvm.should_combine_object_files = true;
|
||||
|
|
@ -643,12 +648,7 @@ pub unsafe fn optimize_thin_module(
|
|||
}
|
||||
};
|
||||
let module = ModuleCodegen {
|
||||
module_llvm: GccContext {
|
||||
context,
|
||||
should_combine_object_files,
|
||||
fat_lto: false,
|
||||
temp_dir: None,
|
||||
},
|
||||
module_llvm: GccContext { context, should_combine_object_files, temp_dir: None },
|
||||
name: thin_module.name().to_string(),
|
||||
kind: ModuleKind::Regular,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -32,12 +32,12 @@ pub(crate) unsafe fn codegen(
|
|||
// NOTE: Only generate object files with GIMPLE when this environment variable is set for
|
||||
// now because this requires a particular setup (same gcc/lto1/lto-wrapper commit as libgccjit).
|
||||
// TODO: remove this environment variable.
|
||||
let fat_lto = module.module_llvm.fat_lto;
|
||||
let fat_lto = env::var("EMBED_LTO_BITCODE").as_deref() == Ok("1");
|
||||
|
||||
let bc_out = cgcx.output_filenames.temp_path(OutputType::Bitcode, module_name);
|
||||
let obj_out = cgcx.output_filenames.temp_path(OutputType::Object, module_name);
|
||||
|
||||
if config.bitcode_needed() {
|
||||
if config.bitcode_needed() && fat_lto {
|
||||
let _timer = cgcx
|
||||
.prof
|
||||
.generic_activity_with_arg("GCC_module_codegen_make_bitcode", &*module.name);
|
||||
|
|
@ -57,8 +57,6 @@ pub(crate) unsafe fn codegen(
|
|||
.generic_activity_with_arg("GCC_module_codegen_emit_bitcode", &*module.name);
|
||||
context.add_command_line_option("-flto=auto");
|
||||
context.add_command_line_option("-flto-partition=one");
|
||||
// TODO: remove since we don't want fat objects when it is for Bitcode only.
|
||||
context.add_command_line_option("-ffat-lto-objects");
|
||||
context
|
||||
.compile_to_file(OutputKind::ObjectFile, bc_out.to_str().expect("path to str"));
|
||||
}
|
||||
|
|
@ -120,11 +118,11 @@ pub(crate) unsafe fn codegen(
|
|||
if fat_lto {
|
||||
context.add_command_line_option("-flto=auto");
|
||||
context.add_command_line_option("-flto-partition=one");
|
||||
}
|
||||
|
||||
// NOTE: without -fuse-linker-plugin, we get the following error:
|
||||
// lto1: internal compiler error: decompressed stream: Destination buffer is too small
|
||||
//context.add_driver_option("-fuse-linker-plugin");
|
||||
// NOTE: without -fuse-linker-plugin, we get the following error:
|
||||
// lto1: internal compiler error: decompressed stream: Destination buffer is too small
|
||||
context.add_driver_option("-fuse-linker-plugin");
|
||||
}
|
||||
|
||||
context.add_driver_option("-Wl,-r");
|
||||
// NOTE: we need -nostdlib, otherwise, we get the following error:
|
||||
|
|
@ -137,6 +135,7 @@ pub(crate) unsafe fn codegen(
|
|||
obj_out.to_str().expect("path to str"),
|
||||
);
|
||||
} else {
|
||||
//println!("Combining to object file");
|
||||
context.compile_to_file(
|
||||
OutputKind::ObjectFile,
|
||||
obj_out.to_str().expect("path to str"),
|
||||
|
|
|
|||
|
|
@ -225,7 +225,6 @@ pub fn compile_codegen_unit(
|
|||
name: cgu_name.to_string(),
|
||||
module_llvm: GccContext {
|
||||
context: Arc::new(SyncContext::new(context)),
|
||||
fat_lto: false,
|
||||
should_combine_object_files: false,
|
||||
temp_dir: None,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -304,7 +304,6 @@ impl ExtraBackendMethods for GccCodegenBackend {
|
|||
) -> Self::Module {
|
||||
let mut mods = GccContext {
|
||||
context: Arc::new(SyncContext::new(new_context(tcx))),
|
||||
fat_lto: false,
|
||||
should_combine_object_files: false,
|
||||
temp_dir: None,
|
||||
};
|
||||
|
|
@ -337,7 +336,6 @@ impl ExtraBackendMethods for GccCodegenBackend {
|
|||
pub struct GccContext {
|
||||
context: Arc<SyncContext>,
|
||||
should_combine_object_files: bool,
|
||||
fat_lto: bool,
|
||||
// Temporary directory used by LTO. We keep it here so that it's not removed before linking.
|
||||
temp_dir: Option<TempDir>,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue