Skip to content

Commit c8d7c04

Browse files
committed
Fix after rebase
1 parent 5d189a7 commit c8d7c04

File tree

6 files changed

+18
-13
lines changed

6 files changed

+18
-13
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ default = ["master"]
2222
master = ["gccjit/master"]
2323

2424
[dependencies]
25-
#gccjit = { git = "https://github.com/antoyo/gccjit.rs" }
25+
gccjit = { git = "https://github.com/antoyo/gccjit.rs" }
2626

2727
# Local copy.
28-
gccjit = { path = "../gccjit.rs" }
28+
#gccjit = { path = "../gccjit.rs" }
2929

3030
object = { version = "0.30.1", default-features = false, features = [
3131
"std",

src/back/lto.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
// FIXME:
1919
// I had to copy lto1, crtbegin.o from the system to /opt/…
2020
// * sudo cp /usr/lib/gcc/x86_64-pc-linux-gnu/13.1.1/lto1 /opt/gcc/libexec/gcc/x86_64-pc-linux-gnu/13.1.1/lto1
21-
// I had to copy liblto_plugin.so to /opt/gcc/lib/gcc
21+
// I had to copy liblto_plugin.so/lto-wrapper to /opt/gcc/lib/gcc
2222

2323
use std::ffi::CString;
2424
use std::fs::{self, File};
@@ -29,7 +29,7 @@ use gccjit::{OutputKind, OptimizationLevel};
2929
use object::read::archive::ArchiveFile;
3030
use rustc_codegen_ssa::back::lto::{LtoModuleCodegen, SerializedModule};
3131
use rustc_codegen_ssa::back::symbol_export;
32-
use rustc_codegen_ssa::back::write::{CodegenContext, FatLTOInput};
32+
use rustc_codegen_ssa::back::write::{CodegenContext, FatLtoInput};
3333
use rustc_codegen_ssa::traits::*;
3434
use rustc_codegen_ssa::{looks_like_rust_object_file, ModuleCodegen, ModuleKind};
3535
use rustc_data_structures::memmap::Mmap;
@@ -179,7 +179,7 @@ fn save_as_file(obj: &[u8], path: &Path) -> Result<(), LtoBitcodeFromRlib> {
179179
/// for further optimization.
180180
pub(crate) fn run_fat(
181181
cgcx: &CodegenContext<GccCodegenBackend>,
182-
modules: Vec<FatLTOInput<GccCodegenBackend>>,
182+
modules: Vec<FatLtoInput<GccCodegenBackend>>,
183183
cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>,
184184
) -> Result<LtoModuleCodegen<GccCodegenBackend>, FatalError> {
185185
let diag_handler = cgcx.create_diag_handler();
@@ -191,7 +191,7 @@ pub(crate) fn run_fat(
191191
)
192192
}
193193

194-
fn fat_lto(cgcx: &CodegenContext<GccCodegenBackend>, _diag_handler: &Handler, modules: Vec<FatLTOInput<GccCodegenBackend>>, cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>, mut serialized_modules: Vec<(SerializedModule<ModuleBuffer>, CString)>, tmp_path: TempDir,
194+
fn fat_lto(cgcx: &CodegenContext<GccCodegenBackend>, _diag_handler: &Handler, modules: Vec<FatLtoInput<GccCodegenBackend>>, cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>, mut serialized_modules: Vec<(SerializedModule<ModuleBuffer>, CString)>, tmp_path: TempDir,
195195
//symbols_below_threshold: &[*const libc::c_char],
196196
) -> Result<LtoModuleCodegen<GccCodegenBackend>, FatalError> {
197197
let _timer = cgcx.prof.generic_activity("LLVM_fat_lto_build_monolithic_module");
@@ -214,8 +214,8 @@ fn fat_lto(cgcx: &CodegenContext<GccCodegenBackend>, _diag_handler: &Handler, mo
214214
}));
215215
for module in modules {
216216
match module {
217-
FatLTOInput::InMemory(m) => in_memory.push(m),
218-
FatLTOInput::Serialized { name, buffer } => {
217+
FatLtoInput::InMemory(m) => in_memory.push(m),
218+
FatLtoInput::Serialized { name, buffer } => {
219219
info!("pushing serialized module {:?}", name);
220220
let buffer = SerializedModule::Local(buffer);
221221
serialized_modules.push((buffer, CString::new(name).unwrap()));
@@ -248,7 +248,7 @@ fn fat_lto(cgcx: &CodegenContext<GccCodegenBackend>, _diag_handler: &Handler, mo
248248
// all our inputs were incrementally reread from the cache and we're just
249249
// re-executing the LTO passes. If that's the case deserialize the first
250250
// module and create a linker with it.
251-
let module: ModuleCodegen<GccContext> = match costliest_module {
251+
let mut module: ModuleCodegen<GccContext> = match costliest_module {
252252
Some((_cost, i)) => in_memory.remove(i),
253253
None => {
254254
unimplemented!("Incremental");
@@ -303,7 +303,7 @@ fn fat_lto(cgcx: &CodegenContext<GccCodegenBackend>, _diag_handler: &Handler, mo
303303
info!("linking {:?}", name);
304304
match bc_decoded {
305305
SerializedModule::Local(ref module_buffer) => {
306-
cgcx.backend.should_combine_object_files.store(true, Ordering::SeqCst);
306+
module.module_llvm.should_combine_object_files = true;
307307
module.module_llvm.context.add_driver_option(module_buffer.0.to_str().expect("path"));
308308
},
309309
SerializedModule::FromRlib(_) => unimplemented!("from rlib"),

src/back/write.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub(crate) unsafe fn codegen(cgcx: &CodegenContext<GccCodegenBackend>, diag_hand
2121

2222
let module_name = module.name.clone();
2323

24-
let should_combine_object_files = cgcx.backend.should_combine_object_files.load(Ordering::SeqCst);
24+
let should_combine_object_files = module.module_llvm.should_combine_object_files;
2525

2626
let module_name = Some(&module_name[..]);
2727

src/base.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ pub fn compile_codegen_unit(tcx: TyCtxt<'_>, cgu_name: Symbol, target_info: Arc<
207207
ModuleCodegen {
208208
name: cgu_name.to_string(),
209209
module_llvm: GccContext {
210-
context
210+
context,
211+
should_combine_object_files: false,
211212
},
212213
kind: ModuleKind::Regular,
213214
}

src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ impl ExtraBackendMethods for GccCodegenBackend {
211211
fn codegen_allocator<'tcx>(&self, tcx: TyCtxt<'tcx>, module_name: &str, kind: AllocatorKind, alloc_error_handler_kind: AllocatorKind) -> Self::Module {
212212
let mut mods = GccContext {
213213
context: Context::default(),
214+
should_combine_object_files: false,
214215
};
215216

216217
/*
@@ -261,6 +262,7 @@ impl ThinBufferMethods for ThinBuffer {
261262

262263
pub struct GccContext {
263264
context: Context<'static>,
265+
should_combine_object_files: bool,
264266
}
265267

266268
unsafe impl Send for GccContext {}
@@ -275,7 +277,7 @@ impl WriteBackendMethods for GccCodegenBackend {
275277
type ThinData = ();
276278
type ThinBuffer = ThinBuffer;
277279

278-
fn run_fat_lto(cgcx: &CodegenContext<Self>, modules: Vec<FatLTOInput<Self>>, cached_modules: Vec<(SerializedModule<Self::ModuleBuffer>, WorkProduct)>) -> Result<LtoModuleCodegen<Self>, FatalError> {
280+
fn run_fat_lto(cgcx: &CodegenContext<Self>, modules: Vec<FatLtoInput<Self>>, cached_modules: Vec<(SerializedModule<Self::ModuleBuffer>, WorkProduct)>) -> Result<LtoModuleCodegen<Self>, FatalError> {
279281
back::lto::run_fat(cgcx, modules, cached_modules)
280282
}
281283

0 commit comments

Comments
 (0)