Skip to content

Commit

Permalink
auto merge of rust-lang#20788 : Zoxc/rust/loader, r=huonw
Browse files Browse the repository at this point in the history
  • Loading branch information
bors committed Jan 9, 2015
2 parents 20bce44 + 9dea210 commit 2e2372c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/librustc/metadata/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ impl<'a> CrateReader<'a> {
crate_name: name,
hash: hash.map(|a| &*a),
filesearch: self.sess.target_filesearch(kind),
target: &self.sess.target.target,
triple: &self.sess.opts.target_triple[],
root: root,
rejected_via_hash: vec!(),
Expand Down Expand Up @@ -472,6 +473,7 @@ impl<'a> CrateReader<'a> {
crate_name: &name[],
hash: None,
filesearch: self.sess.host_filesearch(PathKind::Crate),
target: &self.sess.host,
triple: config::host_triple(),
root: &None,
rejected_via_hash: vec!(),
Expand All @@ -486,6 +488,7 @@ impl<'a> CrateReader<'a> {
target_only = true;
should_link = info.should_link;

load_ctxt.target = &self.sess.target.target;
load_ctxt.triple = target_triple;
load_ctxt.filesearch = self.sess.target_filesearch(PathKind::Crate);
load_ctxt.load_library_crate()
Expand Down
7 changes: 5 additions & 2 deletions src/librustc/metadata/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ use metadata::filesearch::{FileSearch, FileMatches, FileDoesntMatch};
use syntax::codemap::Span;
use syntax::diagnostic::SpanHandler;
use util::fs;
use rustc_back::target::Target;

use std::ffi::CString;
use std::cmp;
Expand All @@ -248,6 +249,8 @@ pub struct Context<'a> {
pub ident: &'a str,
pub crate_name: &'a str,
pub hash: Option<&'a Svh>,
// points to either self.sess.target.target or self.sess.host, must match triple
pub target: &'a Target,
pub triple: &'a str,
pub filesearch: FileSearch<'a>,
pub root: &'a Option<CratePaths>,
Expand Down Expand Up @@ -499,7 +502,7 @@ impl<'a> Context<'a> {

for lib in m.into_iter() {
info!("{} reading metadata from: {}", flavor, lib.display());
let metadata = match get_metadata_section(self.sess.target.target.options.is_like_osx,
let metadata = match get_metadata_section(self.target.options.is_like_osx,
&lib) {
Ok(blob) => {
if self.crate_matches(blob.as_slice(), &lib) {
Expand Down Expand Up @@ -588,7 +591,7 @@ impl<'a> Context<'a> {
// Returns the corresponding (prefix, suffix) that files need to have for
// dynamic libraries
fn dylibname(&self) -> (String, String) {
let t = &self.sess.target.target;
let t = &self.target;
(t.options.dll_prefix.clone(), t.options.dll_suffix.clone())
}

Expand Down
11 changes: 11 additions & 0 deletions src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ use syntax::parse::token;
use syntax::parse::ParseSess;
use syntax::{ast, codemap};

use rustc_back::target::Target;

use std::os;
use std::cell::{Cell, RefCell};

Expand All @@ -35,6 +37,7 @@ pub mod search_paths;
// session for a single crate.
pub struct Session {
pub target: config::Config,
pub host: Target,
pub opts: config::Options,
pub cstore: CStore,
pub parse_sess: ParseSess,
Expand Down Expand Up @@ -243,6 +246,13 @@ pub fn build_session_(sopts: config::Options,
local_crate_source_file: Option<Path>,
span_diagnostic: diagnostic::SpanHandler)
-> Session {
let host = match Target::search(config::host_triple()) {
Ok(t) => t,
Err(e) => {
span_diagnostic.handler()
.fatal((format!("Error loading host specification: {}", e)).as_slice());
}
};
let target_cfg = config::build_target_config(&sopts, &span_diagnostic);
let p_s = parse::new_parse_sess_special_handler(span_diagnostic);
let default_sysroot = match sopts.maybe_sysroot {
Expand All @@ -268,6 +278,7 @@ pub fn build_session_(sopts: config::Options,

let sess = Session {
target: target_cfg,
host: host,
opts: sopts,
cstore: CStore::new(token::get_ident_interner()),
parse_sess: p_s,
Expand Down

0 comments on commit 2e2372c

Please sign in to comment.