Auto merge of #59564 - bjorn3:move_link_to_cg_ssa, r=eddyb

Move back::link and debuginfo::type_names to cg ssa

r? @eddyb
This commit is contained in:
bors 2019-04-20 12:18:49 +00:00
commit 0d1732212f
19 changed files with 1629 additions and 1608 deletions

View file

@ -2634,6 +2634,7 @@ dependencies = [
"serialize 0.0.0",
"syntax 0.0.0",
"syntax_pos 0.0.0",
"tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]

View file

@ -7,14 +7,13 @@ use std::path::{Path, PathBuf};
use std::ptr;
use std::str;
use crate::back::bytecode::RLIB_BYTECODE_EXTENSION;
use crate::llvm::archive_ro::{ArchiveRO, Child};
use crate::llvm::{self, ArchiveKind};
use crate::metadata::METADATA_FILENAME;
use rustc_codegen_ssa::back::archive::find_library;
use rustc_codegen_ssa::{METADATA_FILENAME, RLIB_BYTECODE_EXTENSION};
use rustc_codegen_ssa::back::archive::{ArchiveBuilder, find_library};
use rustc::session::Session;
pub struct ArchiveConfig<'a> {
struct ArchiveConfig<'a> {
pub sess: &'a Session,
pub dst: PathBuf,
pub src: Option<PathBuf>,
@ -23,7 +22,7 @@ pub struct ArchiveConfig<'a> {
/// Helper for adding many files to an archive.
#[must_use = "must call build() to finish building the archive"]
pub struct ArchiveBuilder<'a> {
pub struct LlvmArchiveBuilder<'a> {
config: ArchiveConfig<'a>,
removals: Vec<String>,
additions: Vec<Addition>,
@ -49,11 +48,26 @@ fn is_relevant_child(c: &Child<'_>) -> bool {
}
}
impl<'a> ArchiveBuilder<'a> {
fn archive_config<'a>(sess: &'a Session,
output: &Path,
input: Option<&Path>) -> ArchiveConfig<'a> {
use rustc_codegen_ssa::back::link::archive_search_paths;
ArchiveConfig {
sess,
dst: output.to_path_buf(),
src: input.map(|p| p.to_path_buf()),
lib_search_paths: archive_search_paths(sess),
}
}
impl<'a> ArchiveBuilder<'a> for LlvmArchiveBuilder<'a> {
/// Creates a new static archive, ready for modifying the archive specified
/// by `config`.
pub fn new(config: ArchiveConfig<'a>) -> ArchiveBuilder<'a> {
ArchiveBuilder {
fn new(sess: &'a Session,
output: &Path,
input: Option<&Path>) -> LlvmArchiveBuilder<'a> {
let config = archive_config(sess, output, input);
LlvmArchiveBuilder {
config,
removals: Vec::new(),
additions: Vec::new(),
@ -63,12 +77,12 @@ impl<'a> ArchiveBuilder<'a> {
}
/// Removes a file from this archive
pub fn remove_file(&mut self, file: &str) {
fn remove_file(&mut self, file: &str) {
self.removals.push(file.to_string());
}
/// Lists all files in an archive
pub fn src_files(&mut self) -> Vec<String> {
fn src_files(&mut self) -> Vec<String> {
if self.src_archive().is_none() {
return Vec::new()
}
@ -84,18 +98,9 @@ impl<'a> ArchiveBuilder<'a> {
.collect()
}
fn src_archive(&mut self) -> Option<&ArchiveRO> {
if let Some(ref a) = self.src_archive {
return a.as_ref()
}
let src = self.config.src.as_ref()?;
self.src_archive = Some(ArchiveRO::open(src).ok());
self.src_archive.as_ref().unwrap().as_ref()
}
/// Adds all of the contents of a native library to this archive. This will
/// search in the relevant locations for a library named `name`.
pub fn add_native_library(&mut self, name: &str) {
fn add_native_library(&mut self, name: &str) {
let location = find_library(name, &self.config.lib_search_paths,
self.config.sess);
self.add_archive(&location, |_| false).unwrap_or_else(|e| {
@ -109,7 +114,7 @@ impl<'a> ArchiveBuilder<'a> {
///
/// This ignores adding the bytecode from the rlib, and if LTO is enabled
/// then the object file also isn't added.
pub fn add_rlib(&mut self,
fn add_rlib(&mut self,
rlib: &Path,
name: &str,
lto: bool,
@ -141,6 +146,44 @@ impl<'a> ArchiveBuilder<'a> {
})
}
/// Adds an arbitrary file to this archive
fn add_file(&mut self, file: &Path) {
let name = file.file_name().unwrap().to_str().unwrap();
self.additions.push(Addition::File {
path: file.to_path_buf(),
name_in_archive: name.to_owned(),
});
}
/// Indicate that the next call to `build` should update all symbols in
/// the archive (equivalent to running 'ar s' over it).
fn update_symbols(&mut self) {
self.should_update_symbols = true;
}
/// Combine the provided files, rlibs, and native libraries into a single
/// `Archive`.
fn build(mut self) {
let kind = self.llvm_archive_kind().unwrap_or_else(|kind|
self.config.sess.fatal(&format!("Don't know how to build archive of type: {}", kind)));
if let Err(e) = self.build_with_llvm(kind) {
self.config.sess.fatal(&format!("failed to build archive: {}", e));
}
}
}
impl<'a> LlvmArchiveBuilder<'a> {
fn src_archive(&mut self) -> Option<&ArchiveRO> {
if let Some(ref a) = self.src_archive {
return a.as_ref()
}
let src = self.config.src.as_ref()?;
self.src_archive = Some(ArchiveRO::open(src).ok());
self.src_archive.as_ref().unwrap().as_ref()
}
fn add_archive<F>(&mut self, archive: &Path, skip: F)
-> io::Result<()>
where F: FnMut(&str) -> bool + 'static
@ -156,33 +199,6 @@ impl<'a> ArchiveBuilder<'a> {
Ok(())
}
/// Adds an arbitrary file to this archive
pub fn add_file(&mut self, file: &Path) {
let name = file.file_name().unwrap().to_str().unwrap();
self.additions.push(Addition::File {
path: file.to_path_buf(),
name_in_archive: name.to_owned(),
});
}
/// Indicate that the next call to `build` should update all symbols in
/// the archive (equivalent to running 'ar s' over it).
pub fn update_symbols(&mut self) {
self.should_update_symbols = true;
}
/// Combine the provided files, rlibs, and native libraries into a single
/// `Archive`.
pub fn build(&mut self) {
let kind = self.llvm_archive_kind().unwrap_or_else(|kind|
self.config.sess.fatal(&format!("Don't know how to build archive of type: {}", kind)));
if let Err(e) = self.build_with_llvm(kind) {
self.config.sess.fatal(&format!("failed to build archive: {}", e));
}
}
fn llvm_archive_kind(&self) -> Result<ArchiveKind, &str> {
let kind = &*self.config.sess.target.target.options.archive_format;
kind.parse().map_err(|_| kind)

View file

@ -37,8 +37,6 @@ pub const RLIB_BYTECODE_OBJECT_MAGIC: &[u8] = b"RUST_OBJECT";
// The version number this compiler will write to bytecode objects in rlibs
pub const RLIB_BYTECODE_OBJECT_VERSION: u8 = 2;
pub const RLIB_BYTECODE_EXTENSION: &str = "bc.z";
pub fn encode(identifier: &str, bytecode: &[u8]) -> Vec<u8> {
let mut encoded = Vec::new();

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
use crate::back::bytecode::{DecodedBytecode, RLIB_BYTECODE_EXTENSION};
use crate::back::bytecode::DecodedBytecode;
use crate::back::write::{self, DiagnosticHandlers, with_llvm_pmb, save_temp_bitcode,
to_llvm_opt_settings};
use crate::llvm::archive_ro::ArchiveRO;
@ -16,7 +16,7 @@ use rustc::middle::exported_symbols::SymbolExportLevel;
use rustc::session::config::{self, Lto};
use rustc::util::common::time_ext;
use rustc_data_structures::fx::FxHashMap;
use rustc_codegen_ssa::{ModuleCodegen, ModuleKind};
use rustc_codegen_ssa::{RLIB_BYTECODE_EXTENSION, ModuleCodegen, ModuleKind};
use std::ffi::{CStr, CString};
use std::ptr;

View file

@ -1,5 +1,5 @@
use crate::attributes;
use crate::back::bytecode::{self, RLIB_BYTECODE_EXTENSION};
use crate::back::bytecode;
use crate::back::lto::ThinBuffer;
use crate::base;
use crate::consts;
@ -16,7 +16,7 @@ use rustc_codegen_ssa::traits::*;
use rustc::session::config::{self, OutputType, Passes, Lto, PgoGenerate};
use rustc::session::Session;
use rustc::ty::TyCtxt;
use rustc_codegen_ssa::{ModuleCodegen, CompiledModule};
use rustc_codegen_ssa::{RLIB_BYTECODE_EXTENSION, ModuleCodegen, CompiledModule};
use rustc::util::common::time_ext;
use rustc_fs_util::{path_to_c_string, link_or_copy};
use rustc_data_structures::small_c_str::SmallCStr;

View file

@ -376,7 +376,7 @@ fn vec_slice_metadata(
return_if_metadata_created_in_meantime!(cx, unique_type_id);
let slice_type_name = compute_debuginfo_type_name(cx, slice_ptr_type, true);
let slice_type_name = compute_debuginfo_type_name(cx.tcx, slice_ptr_type, true);
let (pointer_size, pointer_align) = cx.size_and_align_of(data_ptr_type);
let (usize_size, usize_align) = cx.size_and_align_of(cx.tcx.types.usize);
@ -479,7 +479,7 @@ fn trait_pointer_metadata(
let trait_object_type = trait_object_type.unwrap_or(trait_type);
let trait_type_name =
compute_debuginfo_type_name(cx, trait_object_type, false);
compute_debuginfo_type_name(cx.tcx, trait_object_type, false);
let file_metadata = unknown_file_metadata(cx);
@ -866,7 +866,7 @@ fn foreign_type_metadata(
) -> &'ll DIType {
debug!("foreign_type_metadata: {:?}", t);
let name = compute_debuginfo_type_name(cx, t, false);
let name = compute_debuginfo_type_name(cx.tcx, t, false);
create_struct_stub(cx, t, &name, unique_type_id, NO_SCOPE_METADATA)
}
@ -876,7 +876,7 @@ fn pointer_type_metadata(
pointee_type_metadata: &'ll DIType,
) -> &'ll DIType {
let (pointer_size, pointer_align) = cx.size_and_align_of(pointer_type);
let name = compute_debuginfo_type_name(cx, pointer_type, false);
let name = compute_debuginfo_type_name(cx.tcx, pointer_type, false);
let name = SmallCStr::new(&name);
unsafe {
llvm::LLVMRustDIBuilderCreatePointerType(
@ -1072,7 +1072,7 @@ fn prepare_struct_metadata(
unique_type_id: UniqueTypeId,
span: Span,
) -> RecursiveTypeDescription<'ll, 'tcx> {
let struct_name = compute_debuginfo_type_name(cx, struct_type, false);
let struct_name = compute_debuginfo_type_name(cx.tcx, struct_type, false);
let (struct_def_id, variant) = match struct_type.sty {
ty::Adt(def, _) => (def.did, def.non_enum_variant()),
@ -1138,7 +1138,7 @@ fn prepare_tuple_metadata(
unique_type_id: UniqueTypeId,
span: Span,
) -> RecursiveTypeDescription<'ll, 'tcx> {
let tuple_name = compute_debuginfo_type_name(cx, tuple_type, false);
let tuple_name = compute_debuginfo_type_name(cx.tcx, tuple_type, false);
let struct_stub = create_struct_stub(cx,
tuple_type,
@ -1194,7 +1194,7 @@ fn prepare_union_metadata(
unique_type_id: UniqueTypeId,
span: Span,
) -> RecursiveTypeDescription<'ll, 'tcx> {
let union_name = compute_debuginfo_type_name(cx, union_type, false);
let union_name = compute_debuginfo_type_name(cx.tcx, union_type, false);
let (union_def_id, variant) = match union_type.sty {
ty::Adt(def, _) => (def.did, def.non_enum_variant()),
@ -1607,7 +1607,7 @@ fn prepare_enum_metadata(
unique_type_id: UniqueTypeId,
span: Span,
) -> RecursiveTypeDescription<'ll, 'tcx> {
let enum_name = compute_debuginfo_type_name(cx, enum_type, false);
let enum_name = compute_debuginfo_type_name(cx.tcx, enum_type, false);
let containing_scope = get_namespace_for_item(cx, enum_def_id);
// FIXME: This should emit actual file metadata for the enum, but we

View file

@ -29,7 +29,7 @@ use rustc::util::nodemap::{DefIdMap, FxHashMap, FxHashSet};
use rustc_data_structures::small_c_str::SmallCStr;
use rustc_data_structures::indexed_vec::IndexVec;
use rustc_codegen_ssa::debuginfo::{FunctionDebugContext, MirDebugScope, VariableAccess,
VariableKind, FunctionDebugContextData};
VariableKind, FunctionDebugContextData, type_names};
use libc::c_uint;
use std::cell::RefCell;
@ -44,7 +44,6 @@ use rustc_codegen_ssa::traits::*;
pub mod gdb;
mod utils;
mod namespace;
mod type_names;
pub mod metadata;
mod create_scope_map;
mod source_loc;
@ -422,7 +421,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
let actual_type =
cx.tcx.normalize_erasing_regions(ParamEnv::reveal_all(), actual_type);
// Add actual type name to <...> clause of function name
let actual_type_name = compute_debuginfo_type_name(cx,
let actual_type_name = compute_debuginfo_type_name(cx.tcx(),
actual_type,
true);
name_to_append_suffix_to.push_str(&actual_type_name[..]);

View file

@ -44,8 +44,6 @@ extern crate rustc_fs_util;
#[macro_use] extern crate syntax;
extern crate syntax_pos;
extern crate rustc_errors as errors;
extern crate serialize;
extern crate tempfile;
use rustc_codegen_ssa::traits::*;
use rustc_codegen_ssa::back::write::{CodegenContext, ModuleConfig, FatLTOInput};
@ -73,13 +71,10 @@ use rustc_codegen_utils::codegen_backend::CodegenBackend;
mod error_codes;
mod back {
mod archive;
pub mod archive;
pub mod bytecode;
pub mod link;
pub mod lto;
pub mod write;
mod rpath;
pub mod wasm;
}
mod abi;
@ -331,8 +326,17 @@ impl CodegenBackend for LlvmCodegenBackend {
// This should produce either a finished executable or library.
sess.profiler(|p| p.start_activity("link_crate"));
time(sess, "linking", || {
back::link::link_binary(sess, &codegen_results,
outputs, &codegen_results.crate_name.as_str());
use rustc_codegen_ssa::back::link::link_binary;
use crate::back::archive::LlvmArchiveBuilder;
let target_cpu = crate::llvm_util::target_cpu(sess);
link_binary::<LlvmArchiveBuilder<'_>>(
sess,
&codegen_results,
outputs,
&codegen_results.crate_name.as_str(),
target_cpu,
);
});
sess.profiler(|p| p.end_activity("link_crate"));

View file

@ -5,6 +5,8 @@ use rustc::middle::cstore::MetadataLoader;
use rustc_target::spec::Target;
use rustc_data_structures::owning_ref::OwningRef;
use rustc_codegen_ssa::METADATA_FILENAME;
use std::path::Path;
use std::ptr;
use std::slice;
@ -12,8 +14,6 @@ use rustc_fs_util::path_to_c_string;
pub use rustc_data_structures::sync::MetadataRef;
pub const METADATA_FILENAME: &str = "rust.metadata.bin";
pub struct LlvmMetadataLoader;
impl MetadataLoader for LlvmMetadataLoader {

View file

@ -20,6 +20,7 @@ log = "0.4.5"
libc = "0.2.44"
jobserver = "0.1.11"
parking_lot = "0.7"
tempfile = "3.0.5"
serialize = { path = "../libserialize" }
syntax = { path = "../libsyntax" }

View file

@ -1,6 +1,7 @@
use rustc::session::Session;
use std::path::PathBuf;
use std::io;
use std::path::{Path, PathBuf};
pub fn find_library(name: &str, search_paths: &[PathBuf], sess: &Session)
-> PathBuf {
@ -24,3 +25,23 @@ pub fn find_library(name: &str, search_paths: &[PathBuf], sess: &Session)
sess.fatal(&format!("could not find native static library `{}`, \
perhaps an -L flag is missing?", name));
}
pub trait ArchiveBuilder<'a> {
fn new(sess: &'a Session, output: &Path, input: Option<&Path>) -> Self;
fn add_file(&mut self, path: &Path);
fn remove_file(&mut self, name: &str);
fn src_files(&mut self) -> Vec<String>;
fn add_rlib(
&mut self,
path: &Path,
name: &str,
lto: bool,
skip_objects: bool,
) -> io::Result<()>;
fn add_native_library(&mut self, name: &str);
fn update_symbols(&mut self);
fn build(self);
}

File diff suppressed because it is too large Load diff

View file

@ -5,3 +5,5 @@ pub mod link;
pub mod command;
pub mod symbol_export;
pub mod archive;
pub mod rpath;
pub mod wasm;

View file

@ -1,6 +1,8 @@
use syntax_pos::{BytePos, Span};
use rustc::hir::def_id::CrateNum;
pub mod type_names;
pub enum FunctionDebugContext<D> {
RegularContext(FunctionDebugContextData<D>),
DebugInfoDisabled,

View file

@ -1,31 +1,26 @@
// Type Names for Debug Info.
use crate::common::CodegenCx;
use rustc::hir::def_id::DefId;
use rustc::ty::subst::SubstsRef;
use rustc::ty::{self, Ty};
use rustc_codegen_ssa::traits::*;
use rustc::hir::{self, def_id::DefId};
use rustc::ty::{self, Ty, TyCtxt, subst::SubstsRef};
use rustc_data_structures::fx::FxHashSet;
use rustc::hir;
// Compute the name of the type as it should be stored in debuginfo. Does not do
// any caching, i.e., calling the function twice with the same type will also do
// the work twice. The `qualified` parameter only affects the first level of the
// type name, further levels (i.e., type parameters) are always fully qualified.
pub fn compute_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
pub fn compute_debuginfo_type_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
t: Ty<'tcx>,
qualified: bool)
-> String {
let mut result = String::with_capacity(64);
let mut visited = FxHashSet::default();
push_debuginfo_type_name(cx, t, qualified, &mut result, &mut visited);
push_debuginfo_type_name(tcx, t, qualified, &mut result, &mut visited);
result
}
// Pushes the name of the type as it should be stored in debuginfo on the
// `output` String. See also compute_debuginfo_type_name().
pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
pub fn push_debuginfo_type_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
t: Ty<'tcx>,
qualified: bool,
output: &mut String,
@ -33,7 +28,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
// When targeting MSVC, emit C++ style type names for compatibility with
// .natvis visualizers (and perhaps other existing native debuggers?)
let cpp_like_names = cx.sess().target.target.options.is_like_msvc;
let cpp_like_names = tcx.sess.target.target.options.is_like_msvc;
match t.sty {
ty::Bool => output.push_str("bool"),
@ -43,15 +38,15 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
ty::Int(int_ty) => output.push_str(int_ty.ty_to_string()),
ty::Uint(uint_ty) => output.push_str(uint_ty.ty_to_string()),
ty::Float(float_ty) => output.push_str(float_ty.ty_to_string()),
ty::Foreign(def_id) => push_item_name(cx, def_id, qualified, output),
ty::Foreign(def_id) => push_item_name(tcx, def_id, qualified, output),
ty::Adt(def, substs) => {
push_item_name(cx, def.did, qualified, output);
push_type_params(cx, substs, output, visited);
push_item_name(tcx, def.did, qualified, output);
push_type_params(tcx, substs, output, visited);
},
ty::Tuple(component_types) => {
output.push('(');
for &component_type in component_types {
push_debuginfo_type_name(cx, component_type, true, output, visited);
push_debuginfo_type_name(tcx, component_type, true, output, visited);
output.push_str(", ");
}
if !component_types.is_empty() {
@ -69,7 +64,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
hir::MutMutable => output.push_str("mut "),
}
push_debuginfo_type_name(cx, inner_type, true, output, visited);
push_debuginfo_type_name(tcx, inner_type, true, output, visited);
if cpp_like_names {
output.push('*');
@ -83,7 +78,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
output.push_str("mut ");
}
push_debuginfo_type_name(cx, inner_type, true, output, visited);
push_debuginfo_type_name(tcx, inner_type, true, output, visited);
if cpp_like_names {
output.push('*');
@ -91,8 +86,8 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
},
ty::Array(inner_type, len) => {
output.push('[');
push_debuginfo_type_name(cx, inner_type, true, output, visited);
output.push_str(&format!("; {}", len.unwrap_usize(cx.tcx)));
push_debuginfo_type_name(tcx, inner_type, true, output, visited);
output.push_str(&format!("; {}", len.unwrap_usize(tcx)));
output.push(']');
},
ty::Slice(inner_type) => {
@ -102,7 +97,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
output.push('[');
}
push_debuginfo_type_name(cx, inner_type, true, output, visited);
push_debuginfo_type_name(tcx, inner_type, true, output, visited);
if cpp_like_names {
output.push('>');
@ -112,12 +107,12 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
},
ty::Dynamic(ref trait_data, ..) => {
if let Some(principal) = trait_data.principal() {
let principal = cx.tcx.normalize_erasing_late_bound_regions(
let principal = tcx.normalize_erasing_late_bound_regions(
ty::ParamEnv::reveal_all(),
&principal,
);
push_item_name(cx, principal.def_id, false, output);
push_type_params(cx, principal.substs, output, visited);
push_item_name(tcx, principal.def_id, false, output);
push_type_params(tcx, principal.substs, output, visited);
} else {
output.push_str("dyn '_");
}
@ -142,13 +137,13 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
}
let sig = t.fn_sig(cx.tcx);
let sig = t.fn_sig(tcx);
if sig.unsafety() == hir::Unsafety::Unsafe {
output.push_str("unsafe ");
}
let abi = sig.abi();
if abi != crate::abi::Abi::Rust {
if abi != rustc_target::spec::abi::Abi::Rust {
output.push_str("extern \"");
output.push_str(abi.name());
output.push_str("\" ");
@ -156,10 +151,10 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
output.push_str("fn(");
let sig = cx.tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), &sig);
let sig = tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), &sig);
if !sig.inputs().is_empty() {
for &parameter_type in sig.inputs() {
push_debuginfo_type_name(cx, parameter_type, true, output, visited);
push_debuginfo_type_name(tcx, parameter_type, true, output, visited);
output.push_str(", ");
}
output.pop();
@ -178,7 +173,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
if !sig.output().is_unit() {
output.push_str(" -> ");
push_debuginfo_type_name(cx, sig.output(), true, output, visited);
push_debuginfo_type_name(tcx, sig.output(), true, output, visited);
}
@ -213,18 +208,18 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
}
}
fn push_item_name(cx: &CodegenCx<'_, '_>,
fn push_item_name(tcx: TyCtxt<'a, 'tcx, 'tcx>,
def_id: DefId,
qualified: bool,
output: &mut String) {
if qualified {
output.push_str(&cx.tcx.crate_name(def_id.krate).as_str());
for path_element in cx.tcx.def_path(def_id).data {
output.push_str(&tcx.crate_name(def_id.krate).as_str());
for path_element in tcx.def_path(def_id).data {
output.push_str("::");
output.push_str(&path_element.data.as_interned_str().as_str());
}
} else {
output.push_str(&cx.tcx.item_name(def_id).as_str());
output.push_str(&tcx.item_name(def_id).as_str());
}
}
@ -233,7 +228,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
// reconstructed for items from non-local crates. For local crates, this
// would be possible but with inlining and LTO we have to use the least
// common denominator - otherwise we would run into conflicts.
fn push_type_params<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
fn push_type_params<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
substs: SubstsRef<'tcx>,
output: &mut String,
visited: &mut FxHashSet<Ty<'tcx>>) {
@ -244,7 +239,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
output.push('<');
for type_parameter in substs.types() {
push_debuginfo_type_name(cx, type_parameter, true, output, visited);
push_debuginfo_type_name(tcx, type_parameter, true, output, visited);
output.push_str(", ");
}

View file

@ -66,6 +66,7 @@ pub struct ModuleCodegen<M> {
pub kind: ModuleKind,
}
pub const METADATA_FILENAME: &str = "rust.metadata.bin";
pub const RLIB_BYTECODE_EXTENSION: &str = "bc.z";
impl<M> ModuleCodegen<M> {