Skip to content

Commit 78ee4f1

Browse files
committed
Some more debugging
1 parent d84c074 commit 78ee4f1

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

src/back/lto.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,8 @@ fn fat_lto(
280280
context.set_optimization_level(to_gcc_opt_level(config.opt_level));
281281
context.add_command_line_option("-flto=auto");
282282
context.add_command_line_option("-flto-partition=one");
283-
//context.add_command_line_option("-fno-use-linker-plugin");
283+
context.add_command_line_option("-fno-use-linker-plugin");
284+
context.add_driver_option("-fno-use-linker-plugin");
284285
context.compile_to_file(OutputKind::ObjectFile, path);
285286
let buffer = ModuleBuffer::new(PathBuf::from(path));
286287
let llmod_id = CString::new(&module.name[..]).unwrap();
@@ -652,6 +653,8 @@ pub unsafe fn optimize_thin_module(
652653
Some(thin_buffer) => Arc::clone(&thin_buffer.context),
653654
None => {
654655
let context = Context::default();
656+
context.add_command_line_option("-fno-use-linker-plugin");
657+
context.add_driver_option("-fno-use-linker-plugin");
655658
let len = thin_module.shared.thin_buffers.len();
656659
let module = &thin_module.shared.serialized_modules[thin_module.idx - len];
657660
match *module {

src/back/write.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ pub(crate) unsafe fn codegen(
6767
);
6868
context.add_command_line_option("-flto=auto");
6969
context.add_command_line_option("-flto-partition=one");
70-
//context.add_command_line_option("-fno-use-linker-plugin");
70+
// FIXME FIXME FIXME: it seems that uncommenting "ADD_ARG ("-fno-use-linker-plugin")" in libgccjit
71+
// make the test fail (undefined symbol main).
72+
// TODO: Perhaps we're not sending this flag somewhere?
73+
context.add_command_line_option("-fno-use-linker-plugin");
74+
context.add_driver_option("-fno-use-linker-plugin");
7175
// TODO(antoyo): remove since we don't want fat objects when it is for Bitcode only.
7276
context.add_command_line_option("-ffat-lto-objects");
7377
context.compile_to_file(
@@ -86,7 +90,8 @@ pub(crate) unsafe fn codegen(
8690

8791
context.add_command_line_option("-flto=auto");
8892
context.add_command_line_option("-flto-partition=one");
89-
//context.add_command_line_option("-fno-use-linker-plugin");
93+
context.add_command_line_option("-fno-use-linker-plugin");
94+
context.add_driver_option("-fno-use-linker-plugin");
9095
context.add_command_line_option("-ffat-lto-objects");
9196
// TODO(antoyo): Send -plugin/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/liblto_plugin.so to linker (this should be done when specifying the appropriate rustc cli argument).
9297
context.compile_to_file(
@@ -175,7 +180,8 @@ pub(crate) unsafe fn codegen(
175180
context.add_command_line_option("-flto=auto");
176181
context.add_command_line_option("-flto-partition=one");
177182
//context.add_command_line_option("-ffat-lto-objects");
178-
//context.add_command_line_option("-fno-use-linker-plugin");
183+
context.add_command_line_option("-fno-use-linker-plugin");
184+
context.add_driver_option("-fno-use-linker-plugin");
179185

180186
// FIXME FIXME FIXME:
181187
// /usr/bin/ld: warning: incremental linking of LTO and non-LTO objects; using -flinker-output=nolto-rel which will bypass whole program optimization
@@ -215,6 +221,8 @@ pub(crate) unsafe fn codegen(
215221
println!("****************************************************************************************************");
216222

217223
let context = Context::default();
224+
context.add_command_line_option("-fno-use-linker-plugin");
225+
context.add_driver_option("-fno-use-linker-plugin");
218226
if cgcx.target_arch == "x86" || cgcx.target_arch == "x86_64" {
219227
// NOTE: it seems we need to use add_driver_option instead of
220228
// add_command_line_option here because we use the LTO frontend via gcc.

src/gcc_util.rs

+2
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ fn handle_native(name: &str) -> &str {
207207
{
208208
// Get the native arch.
209209
let context = Context::default();
210+
context.add_command_line_option("-fno-use-linker-plugin");
211+
context.add_driver_option("-fno-use-linker-plugin");
210212
context.get_target_info().arch().unwrap().to_str().unwrap()
211213
}
212214
#[cfg(not(feature = "master"))]

src/lib.rs

+8
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ impl CodegenBackend for GccCodegenBackend {
195195

196196
// Get the second TargetInfo with the correct CPU features by setting the arch.
197197
let context = Context::default();
198+
context.add_command_line_option("-fno-use-linker-plugin");
199+
context.add_driver_option("-fno-use-linker-plugin");
198200
if target_cpu != "generic" {
199201
context.add_command_line_option(format!("-march={}", target_cpu));
200202
}
@@ -210,6 +212,8 @@ impl CodegenBackend for GccCodegenBackend {
210212
let temp_dir = TempDir::new().expect("cannot create temporary directory");
211213
let temp_file = temp_dir.into_path().join("result.asm");
212214
let check_context = Context::default();
215+
context.add_command_line_option("-fno-use-linker-plugin");
216+
context.add_driver_option("-fno-use-linker-plugin");
213217
check_context.set_print_errors_to_stderr(false);
214218
let _int128_ty = check_context.new_c_type(CType::UInt128t);
215219
// NOTE: we cannot just call compile() as this would require other files than libgccjit.so.
@@ -267,6 +271,8 @@ impl CodegenBackend for GccCodegenBackend {
267271

268272
fn new_context<'gcc, 'tcx>(tcx: TyCtxt<'tcx>) -> Context<'gcc> {
269273
let context = Context::default();
274+
context.add_command_line_option("-fno-use-linker-plugin");
275+
context.add_driver_option("-fno-use-linker-plugin");
270276
if tcx.sess.target.arch == "x86" || tcx.sess.target.arch == "x86_64" {
271277
context.add_command_line_option("-masm=intel");
272278
}
@@ -461,6 +467,8 @@ pub fn __rustc_codegen_backend() -> Box<dyn CodegenBackend> {
461467
// Check whether the target supports 128-bit integers, and sized floating point types (like
462468
// Float16).
463469
let context = Context::default();
470+
context.add_command_line_option("-fno-use-linker-plugin");
471+
context.add_driver_option("-fno-use-linker-plugin");
464472
Arc::new(Mutex::new(IntoDynSyncSend(context.get_target_info())))
465473
};
466474
#[cfg(not(feature = "master"))]

0 commit comments

Comments
 (0)