1
Fork 0

use tcx.crate_name(LOCAL_CRATE) rather than LinkMeta::crate_name

This commit is contained in:
Niko Matsakis 2017-04-13 14:58:20 -04:00
parent 3f59079f8a
commit c22fdf9a3a
8 changed files with 14 additions and 15 deletions

View file

@ -53,7 +53,6 @@ pub use self::NativeLibraryKind::*;
#[derive(Clone, Debug)]
pub struct LinkMeta {
pub crate_name: Symbol,
pub crate_hash: Svh,
}

View file

@ -1140,7 +1140,7 @@ pub fn phase_6_link_output(sess: &Session,
outputs: &OutputFilenames) {
time(sess.time_passes(),
"linking",
|| link::link_binary(sess, trans, outputs, &trans.link.crate_name.as_str()));
|| link::link_binary(sess, trans, outputs, &trans.crate_name.as_str()));
}
fn escape_dep_filename(filename: &str) -> String {

View file

@ -14,7 +14,7 @@ use schema::*;
use rustc::middle::cstore::{LinkMeta, LinkagePreference, NativeLibrary,
EncodedMetadata, EncodedMetadataHash};
use rustc::hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefIndex, DefId};
use rustc::hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefIndex, DefId, LOCAL_CRATE};
use rustc::hir::map::definitions::DefPathTable;
use rustc::middle::dependency_format::Linkage;
use rustc::middle::lang_items;
@ -1380,7 +1380,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
let link_meta = self.link_meta;
let is_proc_macro = tcx.sess.crate_types.borrow().contains(&CrateTypeProcMacro);
let root = self.lazy(&CrateRoot {
name: link_meta.crate_name,
name: tcx.crate_name(LOCAL_CRATE),
triple: tcx.sess.opts.target_triple.clone(),
hash: link_meta.crate_hash,
disambiguator: tcx.sess.local_crate_disambiguator(),

View file

@ -47,7 +47,6 @@ use std::str;
use flate;
use syntax::ast;
use syntax::attr;
use syntax::symbol::Symbol;
use syntax_pos::Span;
/// The LLVM module name containing crate-metadata. This includes a `.` on
@ -136,11 +135,8 @@ pub fn find_crate_name(sess: Option<&Session>,
"rust_out".to_string()
}
pub fn build_link_meta(incremental_hashes_map: &IncrementalHashesMap,
name: &str)
-> LinkMeta {
pub fn build_link_meta(incremental_hashes_map: &IncrementalHashesMap) -> LinkMeta {
let r = LinkMeta {
crate_name: Symbol::intern(name),
crate_hash: Svh::new(incremental_hashes_map[&DepNode::Krate].to_smaller_hash()),
};
info!("{:?}", r);

View file

@ -1063,12 +1063,12 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
// particular items that will be processed.
let krate = tcx.hir.krate();
let ty::CrateAnalysis { reachable, name, .. } = analysis;
let ty::CrateAnalysis { reachable, .. } = analysis;
let exported_symbols = find_exported_symbols(tcx, reachable);
let check_overflow = tcx.sess.overflow_checks();
let link_meta = link::build_link_meta(incremental_hashes_map, &name);
let link_meta = link::build_link_meta(incremental_hashes_map);
let shared_ccx = SharedCrateContext::new(tcx,
link_meta.clone(),
@ -1096,6 +1096,7 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
let empty_exported_symbols = ExportedSymbols::empty();
let linker_info = LinkerInfo::new(&shared_ccx, &empty_exported_symbols);
return CrateTranslation {
crate_name: tcx.crate_name(LOCAL_CRATE),
modules: vec![],
metadata_module: metadata_module,
link: link_meta,
@ -1307,6 +1308,7 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
});
CrateTranslation {
crate_name: tcx.crate_name(LOCAL_CRATE),
modules: modules,
metadata_module: metadata_module,
link: link_meta,

View file

@ -13,7 +13,7 @@ use llvm::{ContextRef, ModuleRef, ValueRef};
use rustc::dep_graph::{DepGraph, DepGraphSafe, DepNode, DepTrackingMap, DepTrackingMapConfig};
use middle::cstore::LinkMeta;
use rustc::hir;
use rustc::hir::def_id::DefId;
use rustc::hir::def_id::{DefId, LOCAL_CRATE};
use rustc::traits;
use debuginfo;
use callee;
@ -439,7 +439,7 @@ impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> {
pub fn metadata_symbol_name(&self) -> String {
format!("rust_metadata_{}_{}",
self.link_meta().crate_name,
self.tcx().crate_name(LOCAL_CRATE),
self.link_meta().crate_hash)
}
}

View file

@ -26,7 +26,7 @@ use llvm::debuginfo::{DIType, DIFile, DIScope, DIDescriptor,
DICompositeType, DILexicalBlock, DIFlags};
use rustc::hir::def::CtorKind;
use rustc::hir::def_id::DefId;
use rustc::hir::def_id::{DefId, LOCAL_CRATE};
use rustc::ty::fold::TypeVisitor;
use rustc::ty::subst::Substs;
use rustc::ty::util::TypeIdHasher;
@ -810,7 +810,7 @@ pub fn compile_unit_metadata(scc: &SharedCrateContext,
};
fn fallback_path(scc: &SharedCrateContext) -> CString {
CString::new(scc.link_meta().crate_name.to_string()).unwrap()
CString::new(scc.tcx().crate_name(LOCAL_CRATE).to_string()).unwrap()
}
}

View file

@ -40,6 +40,7 @@
#![feature(conservative_impl_trait)]
use rustc::dep_graph::WorkProduct;
use syntax_pos::symbol::Symbol;
extern crate flate;
extern crate libc;
@ -165,6 +166,7 @@ unsafe impl Send for ModuleTranslation { }
unsafe impl Sync for ModuleTranslation { }
pub struct CrateTranslation {
pub crate_name: Symbol,
pub modules: Vec<ModuleTranslation>,
pub metadata_module: ModuleTranslation,
pub link: middle::cstore::LinkMeta,