Cleanup
This commit is contained in:
parent
59afbe0913
commit
3f23706c6c
7 changed files with 60 additions and 60 deletions
|
@ -130,7 +130,7 @@ pub fn build_sysroot(env: &HashMap<String, String>, config: &ConfigInfo) -> Resu
|
|||
if config.no_default_features {
|
||||
rustflags.push_str(" -Csymbol-mangling-version=v0");
|
||||
}
|
||||
rustflags.push_str(" --print link-args");
|
||||
//rustflags.push_str(" --print link-args");
|
||||
|
||||
let mut args: Vec<&dyn AsRef<OsStr>> = vec![&"cargo", &"build", &"--target", &config.target];
|
||||
for feature in &config.features {
|
||||
|
@ -178,7 +178,7 @@ pub fn build_sysroot(env: &HashMap<String, String>, config: &ConfigInfo) -> Resu
|
|||
//rustflags.push_str(" -Clink-arg=--ld-path=/usr/bin/mold");
|
||||
//rustflags.push_str(" -Clink-arg=--ld-path=/usr/bin/ld.bfd");
|
||||
//rustflags.push_str(" -Clink-arg=--ld-path=/usr/bin/ld.gold");
|
||||
env.insert("RUSTC_LOG".to_string(), "rustc_codegen_ssa::back::link=info".to_string());
|
||||
//env.insert("RUSTC_LOG".to_string(), "rustc_codegen_ssa::back::link=info".to_string());
|
||||
env.insert("RUSTFLAGS".to_string(), rustflags);
|
||||
run_command_with_output_and_env(&args, Some(&start_dir), Some(&env))?;
|
||||
|
||||
|
|
|
@ -692,11 +692,11 @@ fn test_libcore(env: &Env, args: &TestArg) -> Result<(), String> {
|
|||
println!("[TEST] libcore");
|
||||
let path = get_sysroot_dir().join("sysroot_src/library/core/tests");
|
||||
let _ = remove_dir_all(path.join("target"));
|
||||
let mut env = env.clone();
|
||||
env.insert("RUSTC_LOG".to_string(), "rustc_codegen_ssa::back::link=info".to_string());
|
||||
let rustflags =
|
||||
/*let mut env = env.clone();
|
||||
env.insert("RUSTC_LOG".to_string(), "rustc_codegen_ssa::back::link=info".to_string());*/
|
||||
/*let rustflags =
|
||||
env.entry("RUSTFLAGS".to_string())
|
||||
.or_default();
|
||||
.or_default();*/
|
||||
//rustflags.push_str(" -C link-arg=-Wl,--verbose");
|
||||
//rustflags.push_str(" -C link-arg=-Wl,--fatal-warnings");
|
||||
//rustflags.push_str(" -C link-arg=-Wl,--warn-unresolved-symbols");
|
||||
|
@ -718,7 +718,7 @@ fn test_libcore(env: &Env, args: &TestArg) -> Result<(), String> {
|
|||
//rustflags.push_str(" -C link-arg=-Wl,--trace-symbol=_ZN6memchr4arch6x86_646memchr10memchr_raw2FN17haaf621f7b8ca567eE");
|
||||
//rustflags.push_str(" -C link-arg=-Wl,--print-map");
|
||||
//rustflags.push_str(" -Clink-arg=-not-an-arg");
|
||||
run_cargo_command(&[&"test"], Some(&path), &env, args)?;
|
||||
run_cargo_command(&[&"test"], Some(&path), env, args)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use std::{env, fs};
|
||||
|
||||
use gccjit::{Context, OutputKind};
|
||||
use gccjit::OutputKind;
|
||||
use rustc_codegen_ssa::back::link::ensure_removed;
|
||||
use rustc_codegen_ssa::back::write::{BitcodeSection, CodegenContext, EmitObj, ModuleConfig};
|
||||
use rustc_codegen_ssa::{CompiledModule, ModuleCodegen};
|
||||
use rustc_errors::DiagCtxtHandle;
|
||||
use rustc_fs_util::link_or_copy;
|
||||
use rustc_session::config::{Lto, OutputType};
|
||||
use rustc_session::config::OutputType;
|
||||
use rustc_span::fatal_error::FatalError;
|
||||
use rustc_target::spec::SplitDebuginfo;
|
||||
|
||||
|
@ -34,10 +34,10 @@ pub(crate) unsafe fn codegen(
|
|||
// TODO: remove this environment variable.
|
||||
let fat_lto = env::var("EMBED_LTO_BITCODE").as_deref() == Ok("1");
|
||||
|
||||
if cgcx.msvc_imps_needed {
|
||||
/*if cgcx.msvc_imps_needed {
|
||||
println!("************************************************** Imps needed");
|
||||
create_msvc_imps(cgcx, context);
|
||||
}
|
||||
}*/
|
||||
|
||||
let bc_out = cgcx.output_filenames.temp_path(OutputType::Bitcode, module_name);
|
||||
let obj_out = cgcx.output_filenames.temp_path(OutputType::Object, module_name);
|
||||
|
@ -58,21 +58,25 @@ pub(crate) unsafe fn codegen(
|
|||
}*/
|
||||
|
||||
if config.emit_bc || config.emit_obj == EmitObj::Bitcode {
|
||||
let _timer = cgcx
|
||||
.prof
|
||||
.generic_activity_with_arg("GCC_module_codegen_emit_bitcode", &*module.name);
|
||||
let _timer = cgcx.prof.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"));
|
||||
context.compile_to_file(
|
||||
OutputKind::ObjectFile,
|
||||
bc_out.to_str().expect("path to str"),
|
||||
);
|
||||
}
|
||||
|
||||
if config.emit_obj == EmitObj::ObjectCode(BitcodeSection::Full) {
|
||||
let _timer = cgcx
|
||||
.prof
|
||||
.generic_activity_with_arg("GCC_module_codegen_embed_bitcode", &*module.name);
|
||||
let _timer = cgcx.prof.generic_activity_with_arg(
|
||||
"GCC_module_codegen_embed_bitcode",
|
||||
&*module.name,
|
||||
);
|
||||
// TODO(antoyo): maybe we should call embed_bitcode to have the proper iOS fixes?
|
||||
//embed_bitcode(cgcx, llcx, llmod, &config.bc_cmdline, data);
|
||||
|
||||
|
@ -80,26 +84,30 @@ pub(crate) unsafe fn codegen(
|
|||
context.add_command_line_option("-flto-partition=one");
|
||||
context.add_command_line_option("-ffat-lto-objects");
|
||||
// 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).
|
||||
context
|
||||
.compile_to_file(OutputKind::ObjectFile, bc_out.to_str().expect("path to str"));
|
||||
context.compile_to_file(
|
||||
OutputKind::ObjectFile,
|
||||
bc_out.to_str().expect("path to str"),
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if config.emit_bc || config.emit_obj == EmitObj::Bitcode {
|
||||
let _timer = cgcx
|
||||
.prof
|
||||
.generic_activity_with_arg("GCC_module_codegen_emit_bitcode", &*module.name);
|
||||
context
|
||||
.compile_to_file(OutputKind::ObjectFile, bc_out.to_str().expect("path to str"));
|
||||
let _timer = cgcx.prof.generic_activity_with_arg(
|
||||
"GCC_module_codegen_emit_bitcode",
|
||||
&*module.name,
|
||||
);
|
||||
context.compile_to_file(
|
||||
OutputKind::ObjectFile,
|
||||
bc_out.to_str().expect("path to str"),
|
||||
);
|
||||
}
|
||||
|
||||
if config.emit_obj == EmitObj::ObjectCode(BitcodeSection::Full) {
|
||||
// TODO: we might want to emit to emit an error here, saying to set the
|
||||
// environment variable EMBED_LTO_BITCODE.
|
||||
unreachable!();
|
||||
let _timer = cgcx
|
||||
.prof
|
||||
.generic_activity_with_arg("GCC_module_codegen_embed_bitcode", &*module.name);
|
||||
let _timer = cgcx.prof.generic_activity_with_arg(
|
||||
"GCC_module_codegen_embed_bitcode",
|
||||
&*module.name,
|
||||
);
|
||||
// TODO(antoyo): maybe we should call embed_bitcode to have the proper iOS fixes?
|
||||
//embed_bitcode(cgcx, llcx, llmod, &config.bc_cmdline, data);
|
||||
|
||||
|
@ -107,8 +115,10 @@ pub(crate) unsafe fn codegen(
|
|||
context.add_command_line_option("-flto-partition=one");
|
||||
context.add_command_line_option("-ffat-lto-objects");
|
||||
// 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).
|
||||
context
|
||||
.compile_to_file(OutputKind::ObjectFile, bc_out.to_str().expect("path to str"));
|
||||
context.compile_to_file(
|
||||
OutputKind::ObjectFile,
|
||||
bc_out.to_str().expect("path to str"),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -231,18 +241,10 @@ pub(crate) fn save_temp_bitcode(
|
|||
}*/
|
||||
}
|
||||
|
||||
fn create_msvc_imps<'gcc>(
|
||||
cgcx: &CodegenContext<GccCodegenBackend>,
|
||||
context: &Context<'gcc>,
|
||||
) {
|
||||
/*fn create_msvc_imps<'gcc>(cgcx: &CodegenContext<GccCodegenBackend>, _context: &Context<'gcc>) {
|
||||
if !cgcx.msvc_imps_needed {
|
||||
return;
|
||||
}
|
||||
// The x86 ABI seems to require that leading underscores are added to symbol
|
||||
// names, so we need an extra underscore on x86. There's also a leading
|
||||
// '\x01' here which disables LLVM's symbol mangling (e.g., no extra
|
||||
// underscores added in front).
|
||||
let prefix = if cgcx.target_arch == "x86" { "\x01__imp__" } else { "\x01__imp_" };
|
||||
|
||||
/*unsafe {
|
||||
let ptr_ty = Type::ptr_llcx(llcx);
|
||||
|
@ -265,4 +267,4 @@ fn create_msvc_imps<'gcc>(
|
|||
llvm::set_linkage(imp, llvm::Linkage::ExternalLinkage);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}*/
|
||||
|
|
|
@ -156,17 +156,17 @@ pub fn compile_codegen_unit(
|
|||
//println!("*** Static");
|
||||
context.add_command_line_option("-fno-pie");
|
||||
context.add_driver_option("-fno-pie");
|
||||
},
|
||||
}
|
||||
rustc_target::spec::RelocModel::Pic => {
|
||||
//println!("*** Pic");
|
||||
context.add_command_line_option("-fPIC");
|
||||
context.add_driver_option("-fPIC");
|
||||
},
|
||||
}
|
||||
rustc_target::spec::RelocModel::Pie => {
|
||||
//println!("*** Pie");
|
||||
context.add_command_line_option("-fPIE");
|
||||
context.add_driver_option("-fPIE");
|
||||
},
|
||||
}
|
||||
model => eprintln!("Unsupported relocation model: {:?}", model),
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#[cfg(feature = "master")]
|
||||
use gccjit::{FnAttribute, VarAttribute, Visibility};
|
||||
use gccjit::{Function, FunctionType, GlobalKind, LValue, RValue, ToRValue, Type};
|
||||
use gccjit::{Function, GlobalKind, LValue, RValue, ToRValue, Type};
|
||||
use rustc_codegen_ssa::traits::{
|
||||
BaseTypeCodegenMethods, ConstCodegenMethods, StaticCodegenMethods,
|
||||
};
|
||||
|
@ -92,13 +92,12 @@ impl<'gcc, 'tcx> StaticCodegenMethods for CodegenCx<'gcc, 'tcx> {
|
|||
}
|
||||
set_global_alignment(self, global, alloc.align);
|
||||
|
||||
|
||||
// TODO: if I still use this code, find the name of the variable in a better way (using
|
||||
// def_id).
|
||||
let var_name = format!("{:?}", global);
|
||||
if var_name.contains("FN") && var_name.contains("memchr") {
|
||||
//println!("Var name: {:?}", var_name);
|
||||
println!("INITIALIZE: {:?} = {:?}", var_name, value);
|
||||
//println!("INITIALIZE: {:?} = {:?}", var_name, value);
|
||||
|
||||
/*
|
||||
let ptr_type = value.get_type().make_pointer();
|
||||
|
@ -168,9 +167,8 @@ impl<'gcc, 'tcx> StaticCodegenMethods for CodegenCx<'gcc, 'tcx> {
|
|||
//let value = self.context.new_bitcast(None, value, fn_ptr_type); // Also WORKS
|
||||
let value = self.context.new_bitcast(None, value, val_llty);*/
|
||||
global.global_set_initializer_rvalue(value);
|
||||
println!("=== AFTER INITIALIZE");
|
||||
}
|
||||
else {
|
||||
//println!("=== AFTER INITIALIZE");
|
||||
} else {
|
||||
global.global_set_initializer_rvalue(value);
|
||||
}
|
||||
|
||||
|
@ -329,9 +327,9 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
|
|||
}
|
||||
|
||||
let is_tls = fn_attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL);
|
||||
if sym.contains("memchr") && sym.contains("FN") {
|
||||
/*if sym.contains("memchr") && sym.contains("FN") {
|
||||
println!("** DECLARE");
|
||||
}
|
||||
}*/
|
||||
let global = self.declare_global(
|
||||
sym,
|
||||
gcc_type,
|
||||
|
|
|
@ -70,9 +70,9 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
|
|||
is_tls: bool,
|
||||
link_section: Option<Symbol>,
|
||||
) -> LValue<'gcc> {
|
||||
if name.contains("memchr") && name.contains("FN") {
|
||||
/*if name.contains("memchr") && name.contains("FN") {
|
||||
println!("{}: {:?}: {:?}", self.codegen_unit.name(), name, global_kind);
|
||||
}
|
||||
}*/
|
||||
let global = self.context.new_global(None, global_kind, ty, name);
|
||||
if is_tls {
|
||||
global.set_tls_model(self.tls_model);
|
||||
|
|
|
@ -32,9 +32,9 @@ impl<'gcc, 'tcx> PreDefineCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
|
|||
let gcc_type = self.layout_of(ty).gcc_type(self);
|
||||
|
||||
let is_tls = attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL);
|
||||
if symbol_name.contains("memchr") && symbol_name.contains("FN") {
|
||||
/*if symbol_name.contains("memchr") && symbol_name.contains("FN") {
|
||||
println!("** DECLARE static");
|
||||
}
|
||||
}*/
|
||||
let global = self.define_global(symbol_name, gcc_type, is_tls, attrs.link_section);
|
||||
#[cfg(feature = "master")]
|
||||
global.add_attribute(VarAttribute::Visibility(base::visibility_to_gcc(visibility)));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue