Skip to content

Commit 3f23706

Browse files
committed
Cleanup
1 parent 59afbe0 commit 3f23706

File tree

7 files changed

+60
-60
lines changed

7 files changed

+60
-60
lines changed

build_system/src/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ pub fn build_sysroot(env: &HashMap<String, String>, config: &ConfigInfo) -> Resu
130130
if config.no_default_features {
131131
rustflags.push_str(" -Csymbol-mangling-version=v0");
132132
}
133-
rustflags.push_str(" --print link-args");
133+
//rustflags.push_str(" --print link-args");
134134

135135
let mut args: Vec<&dyn AsRef<OsStr>> = vec![&"cargo", &"build", &"--target", &config.target];
136136
for feature in &config.features {
@@ -178,7 +178,7 @@ pub fn build_sysroot(env: &HashMap<String, String>, config: &ConfigInfo) -> Resu
178178
//rustflags.push_str(" -Clink-arg=--ld-path=/usr/bin/mold");
179179
//rustflags.push_str(" -Clink-arg=--ld-path=/usr/bin/ld.bfd");
180180
//rustflags.push_str(" -Clink-arg=--ld-path=/usr/bin/ld.gold");
181-
env.insert("RUSTC_LOG".to_string(), "rustc_codegen_ssa::back::link=info".to_string());
181+
//env.insert("RUSTC_LOG".to_string(), "rustc_codegen_ssa::back::link=info".to_string());
182182
env.insert("RUSTFLAGS".to_string(), rustflags);
183183
run_command_with_output_and_env(&args, Some(&start_dir), Some(&env))?;
184184

build_system/src/test.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -692,11 +692,11 @@ fn test_libcore(env: &Env, args: &TestArg) -> Result<(), String> {
692692
println!("[TEST] libcore");
693693
let path = get_sysroot_dir().join("sysroot_src/library/core/tests");
694694
let _ = remove_dir_all(path.join("target"));
695-
let mut env = env.clone();
696-
env.insert("RUSTC_LOG".to_string(), "rustc_codegen_ssa::back::link=info".to_string());
697-
let rustflags =
698-
env.entry("RUSTFLAGS".to_string())
699-
.or_default();
695+
/*let mut env = env.clone();
696+
env.insert("RUSTC_LOG".to_string(), "rustc_codegen_ssa::back::link=info".to_string());*/
697+
/*let rustflags =
698+
env.entry("RUSTFLAGS".to_string())
699+
.or_default();*/
700700
//rustflags.push_str(" -C link-arg=-Wl,--verbose");
701701
//rustflags.push_str(" -C link-arg=-Wl,--fatal-warnings");
702702
//rustflags.push_str(" -C link-arg=-Wl,--warn-unresolved-symbols");
@@ -718,7 +718,7 @@ fn test_libcore(env: &Env, args: &TestArg) -> Result<(), String> {
718718
//rustflags.push_str(" -C link-arg=-Wl,--trace-symbol=_ZN6memchr4arch6x86_646memchr10memchr_raw2FN17haaf621f7b8ca567eE");
719719
//rustflags.push_str(" -C link-arg=-Wl,--print-map");
720720
//rustflags.push_str(" -Clink-arg=-not-an-arg");
721-
run_cargo_command(&[&"test"], Some(&path), &env, args)?;
721+
run_cargo_command(&[&"test"], Some(&path), env, args)?;
722722
Ok(())
723723
}
724724

src/back/write.rs

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
use std::{env, fs};
22

3-
use gccjit::{Context, OutputKind};
3+
use gccjit::OutputKind;
44
use rustc_codegen_ssa::back::link::ensure_removed;
55
use rustc_codegen_ssa::back::write::{BitcodeSection, CodegenContext, EmitObj, ModuleConfig};
66
use rustc_codegen_ssa::{CompiledModule, ModuleCodegen};
77
use rustc_errors::DiagCtxtHandle;
88
use rustc_fs_util::link_or_copy;
9-
use rustc_session::config::{Lto, OutputType};
9+
use rustc_session::config::OutputType;
1010
use rustc_span::fatal_error::FatalError;
1111
use rustc_target::spec::SplitDebuginfo;
1212

@@ -34,10 +34,10 @@ pub(crate) unsafe fn codegen(
3434
// TODO: remove this environment variable.
3535
let fat_lto = env::var("EMBED_LTO_BITCODE").as_deref() == Ok("1");
3636

37-
if cgcx.msvc_imps_needed {
37+
/*if cgcx.msvc_imps_needed {
3838
println!("************************************************** Imps needed");
3939
create_msvc_imps(cgcx, context);
40-
}
40+
}*/
4141

4242
let bc_out = cgcx.output_filenames.temp_path(OutputType::Bitcode, module_name);
4343
let obj_out = cgcx.output_filenames.temp_path(OutputType::Object, module_name);
@@ -58,57 +58,67 @@ pub(crate) unsafe fn codegen(
5858
}*/
5959

6060
if config.emit_bc || config.emit_obj == EmitObj::Bitcode {
61-
let _timer = cgcx
62-
.prof
63-
.generic_activity_with_arg("GCC_module_codegen_emit_bitcode", &*module.name);
61+
let _timer = cgcx.prof.generic_activity_with_arg(
62+
"GCC_module_codegen_emit_bitcode",
63+
&*module.name,
64+
);
6465
context.add_command_line_option("-flto=auto");
6566
context.add_command_line_option("-flto-partition=one");
6667
// TODO: remove since we don't want fat objects when it is for Bitcode only.
6768
context.add_command_line_option("-ffat-lto-objects");
68-
context
69-
.compile_to_file(OutputKind::ObjectFile, bc_out.to_str().expect("path to str"));
69+
context.compile_to_file(
70+
OutputKind::ObjectFile,
71+
bc_out.to_str().expect("path to str"),
72+
);
7073
}
7174

7275
if config.emit_obj == EmitObj::ObjectCode(BitcodeSection::Full) {
73-
let _timer = cgcx
74-
.prof
75-
.generic_activity_with_arg("GCC_module_codegen_embed_bitcode", &*module.name);
76+
let _timer = cgcx.prof.generic_activity_with_arg(
77+
"GCC_module_codegen_embed_bitcode",
78+
&*module.name,
79+
);
7680
// TODO(antoyo): maybe we should call embed_bitcode to have the proper iOS fixes?
7781
//embed_bitcode(cgcx, llcx, llmod, &config.bc_cmdline, data);
7882

7983
context.add_command_line_option("-flto=auto");
8084
context.add_command_line_option("-flto-partition=one");
8185
context.add_command_line_option("-ffat-lto-objects");
8286
// 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).
83-
context
84-
.compile_to_file(OutputKind::ObjectFile, bc_out.to_str().expect("path to str"));
87+
context.compile_to_file(
88+
OutputKind::ObjectFile,
89+
bc_out.to_str().expect("path to str"),
90+
);
8591
}
86-
}
87-
else {
92+
} else {
8893
if config.emit_bc || config.emit_obj == EmitObj::Bitcode {
89-
let _timer = cgcx
90-
.prof
91-
.generic_activity_with_arg("GCC_module_codegen_emit_bitcode", &*module.name);
92-
context
93-
.compile_to_file(OutputKind::ObjectFile, bc_out.to_str().expect("path to str"));
94+
let _timer = cgcx.prof.generic_activity_with_arg(
95+
"GCC_module_codegen_emit_bitcode",
96+
&*module.name,
97+
);
98+
context.compile_to_file(
99+
OutputKind::ObjectFile,
100+
bc_out.to_str().expect("path to str"),
101+
);
94102
}
95103

96104
if config.emit_obj == EmitObj::ObjectCode(BitcodeSection::Full) {
97105
// TODO: we might want to emit to emit an error here, saying to set the
98106
// environment variable EMBED_LTO_BITCODE.
99-
unreachable!();
100-
let _timer = cgcx
101-
.prof
102-
.generic_activity_with_arg("GCC_module_codegen_embed_bitcode", &*module.name);
107+
let _timer = cgcx.prof.generic_activity_with_arg(
108+
"GCC_module_codegen_embed_bitcode",
109+
&*module.name,
110+
);
103111
// TODO(antoyo): maybe we should call embed_bitcode to have the proper iOS fixes?
104112
//embed_bitcode(cgcx, llcx, llmod, &config.bc_cmdline, data);
105113

106114
context.add_command_line_option("-flto=auto");
107115
context.add_command_line_option("-flto-partition=one");
108116
context.add_command_line_option("-ffat-lto-objects");
109117
// 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).
110-
context
111-
.compile_to_file(OutputKind::ObjectFile, bc_out.to_str().expect("path to str"));
118+
context.compile_to_file(
119+
OutputKind::ObjectFile,
120+
bc_out.to_str().expect("path to str"),
121+
);
112122
}
113123
}
114124
}
@@ -231,18 +241,10 @@ pub(crate) fn save_temp_bitcode(
231241
}*/
232242
}
233243

234-
fn create_msvc_imps<'gcc>(
235-
cgcx: &CodegenContext<GccCodegenBackend>,
236-
context: &Context<'gcc>,
237-
) {
244+
/*fn create_msvc_imps<'gcc>(cgcx: &CodegenContext<GccCodegenBackend>, _context: &Context<'gcc>) {
238245
if !cgcx.msvc_imps_needed {
239246
return;
240247
}
241-
// The x86 ABI seems to require that leading underscores are added to symbol
242-
// names, so we need an extra underscore on x86. There's also a leading
243-
// '\x01' here which disables LLVM's symbol mangling (e.g., no extra
244-
// underscores added in front).
245-
let prefix = if cgcx.target_arch == "x86" { "\x01__imp__" } else { "\x01__imp_" };
246248
247249
/*unsafe {
248250
let ptr_ty = Type::ptr_llcx(llcx);
@@ -265,4 +267,4 @@ fn create_msvc_imps<'gcc>(
265267
llvm::set_linkage(imp, llvm::Linkage::ExternalLinkage);
266268
}
267269
}*/
268-
}
270+
}*/

src/base.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,17 +156,17 @@ pub fn compile_codegen_unit(
156156
//println!("*** Static");
157157
context.add_command_line_option("-fno-pie");
158158
context.add_driver_option("-fno-pie");
159-
},
159+
}
160160
rustc_target::spec::RelocModel::Pic => {
161161
//println!("*** Pic");
162162
context.add_command_line_option("-fPIC");
163163
context.add_driver_option("-fPIC");
164-
},
164+
}
165165
rustc_target::spec::RelocModel::Pie => {
166166
//println!("*** Pie");
167167
context.add_command_line_option("-fPIE");
168168
context.add_driver_option("-fPIE");
169-
},
169+
}
170170
model => eprintln!("Unsupported relocation model: {:?}", model),
171171
}
172172

src/consts.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#[cfg(feature = "master")]
22
use gccjit::{FnAttribute, VarAttribute, Visibility};
3-
use gccjit::{Function, FunctionType, GlobalKind, LValue, RValue, ToRValue, Type};
3+
use gccjit::{Function, GlobalKind, LValue, RValue, ToRValue, Type};
44
use rustc_codegen_ssa::traits::{
55
BaseTypeCodegenMethods, ConstCodegenMethods, StaticCodegenMethods,
66
};
@@ -92,13 +92,12 @@ impl<'gcc, 'tcx> StaticCodegenMethods for CodegenCx<'gcc, 'tcx> {
9292
}
9393
set_global_alignment(self, global, alloc.align);
9494

95-
9695
// TODO: if I still use this code, find the name of the variable in a better way (using
9796
// def_id).
9897
let var_name = format!("{:?}", global);
9998
if var_name.contains("FN") && var_name.contains("memchr") {
10099
//println!("Var name: {:?}", var_name);
101-
println!("INITIALIZE: {:?} = {:?}", var_name, value);
100+
//println!("INITIALIZE: {:?} = {:?}", var_name, value);
102101

103102
/*
104103
let ptr_type = value.get_type().make_pointer();
@@ -168,9 +167,8 @@ impl<'gcc, 'tcx> StaticCodegenMethods for CodegenCx<'gcc, 'tcx> {
168167
//let value = self.context.new_bitcast(None, value, fn_ptr_type); // Also WORKS
169168
let value = self.context.new_bitcast(None, value, val_llty);*/
170169
global.global_set_initializer_rvalue(value);
171-
println!("=== AFTER INITIALIZE");
172-
}
173-
else {
170+
//println!("=== AFTER INITIALIZE");
171+
} else {
174172
global.global_set_initializer_rvalue(value);
175173
}
176174

@@ -329,9 +327,9 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
329327
}
330328

331329
let is_tls = fn_attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL);
332-
if sym.contains("memchr") && sym.contains("FN") {
330+
/*if sym.contains("memchr") && sym.contains("FN") {
333331
println!("** DECLARE");
334-
}
332+
}*/
335333
let global = self.declare_global(
336334
sym,
337335
gcc_type,

src/declare.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
7070
is_tls: bool,
7171
link_section: Option<Symbol>,
7272
) -> LValue<'gcc> {
73-
if name.contains("memchr") && name.contains("FN") {
73+
/*if name.contains("memchr") && name.contains("FN") {
7474
println!("{}: {:?}: {:?}", self.codegen_unit.name(), name, global_kind);
75-
}
75+
}*/
7676
let global = self.context.new_global(None, global_kind, ty, name);
7777
if is_tls {
7878
global.set_tls_model(self.tls_model);

src/mono_item.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ impl<'gcc, 'tcx> PreDefineCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
3232
let gcc_type = self.layout_of(ty).gcc_type(self);
3333

3434
let is_tls = attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL);
35-
if symbol_name.contains("memchr") && symbol_name.contains("FN") {
35+
/*if symbol_name.contains("memchr") && symbol_name.contains("FN") {
3636
println!("** DECLARE static");
37-
}
37+
}*/
3838
let global = self.define_global(symbol_name, gcc_type, is_tls, attrs.link_section);
3939
#[cfg(feature = "master")]
4040
global.add_attribute(VarAttribute::Visibility(base::visibility_to_gcc(visibility)));

0 commit comments

Comments
 (0)