Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 20, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
@@ -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]]
94 changes: 55 additions & 39 deletions src/librustc_codegen_llvm/back/archive.rs
Original file line number Diff line number Diff line change
@@ -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,23 +146,8 @@ impl<'a> ArchiveBuilder<'a> {
})
}

fn add_archive<F>(&mut self, archive: &Path, skip: F)
-> io::Result<()>
where F: FnMut(&str) -> bool + 'static
{
let archive = match ArchiveRO::open(archive) {
Ok(ar) => ar,
Err(e) => return Err(io::Error::new(io::ErrorKind::Other, e)),
};
self.additions.push(Addition::Archive {
archive,
skip: Box::new(skip),
});
Ok(())
}

/// Adds an arbitrary file to this archive
pub fn add_file(&mut self, file: &Path) {
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(),
@@ -167,13 +157,13 @@ impl<'a> ArchiveBuilder<'a> {

/// 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) {
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) {
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)));

@@ -182,6 +172,32 @@ impl<'a> ArchiveBuilder<'a> {
}

}
}

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
{
let archive = match ArchiveRO::open(archive) {
Ok(ar) => ar,
Err(e) => return Err(io::Error::new(io::ErrorKind::Other, e)),
};
self.additions.push(Addition::Archive {
archive,
skip: Box::new(skip),
});
Ok(())
}

fn llvm_archive_kind(&self) -> Result<ArchiveKind, &str> {
let kind = &*self.config.sess.target.target.options.archive_format;
2 changes: 0 additions & 2 deletions src/librustc_codegen_llvm/back/bytecode.rs
Original file line number Diff line number Diff line change
@@ -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();

1,494 changes: 0 additions & 1,494 deletions src/librustc_codegen_llvm/back/link.rs

This file was deleted.

4 changes: 2 additions & 2 deletions src/librustc_codegen_llvm/back/lto.rs
Original file line number Diff line number Diff line change
@@ -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;
4 changes: 2 additions & 2 deletions src/librustc_codegen_llvm/back/write.rs
Original file line number Diff line number Diff line change
@@ -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;
16 changes: 8 additions & 8 deletions src/librustc_codegen_llvm/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
@@ -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
5 changes: 2 additions & 3 deletions src/librustc_codegen_llvm/debuginfo/mod.rs
Original file line number Diff line number Diff line change
@@ -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[..]);
20 changes: 12 additions & 8 deletions src/librustc_codegen_llvm/lib.rs
Original file line number Diff line number Diff line change
@@ -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"));

4 changes: 2 additions & 2 deletions src/librustc_codegen_llvm/metadata.rs
Original file line number Diff line number Diff line change
@@ -5,15 +5,15 @@ 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;
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 {
1 change: 1 addition & 0 deletions src/librustc_codegen_ssa/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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" }
23 changes: 22 additions & 1 deletion src/librustc_codegen_ssa/back/archive.rs
Original file line number Diff line number Diff line change
@@ -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);
}
1,483 changes: 1,479 additions & 4 deletions src/librustc_codegen_ssa/back/link.rs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/librustc_codegen_ssa/back/mod.rs
Original file line number Diff line number Diff line change
@@ -5,3 +5,5 @@ pub mod link;
pub mod command;
pub mod symbol_export;
pub mod archive;
pub mod rpath;
pub mod wasm;
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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,
Original file line number Diff line number Diff line change
@@ -1,39 +1,34 @@
// 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,
visited: &mut FxHashSet<Ty<'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,16 +78,16 @@ 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('*');
}
},
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,24 +137,24 @@ 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("\" ");
}

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(", ");
}

1 change: 1 addition & 0 deletions src/librustc_codegen_ssa/lib.rs
Original file line number Diff line number Diff line change
@@ -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";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a problem, because bc is LLVM-specific.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But feel free to file an issue and leave it for later.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the convention on those kind of issues? File it right now and add a comment here referencing it?


impl<M> ModuleCodegen<M> {