Introduce a TargetTriple enum to support absolute target paths

This commit is contained in:
Philipp Oppermann 2018-03-14 15:27:06 +01:00
parent b4aa80dd73
commit 3908b2e443
12 changed files with 118 additions and 56 deletions

View file

@ -950,7 +950,7 @@ impl<'a, 'tcx> FnType<'tcx> {
"s390x" => cabi_s390x::compute_abi_info(cx, self),
"asmjs" => cabi_asmjs::compute_abi_info(cx, self),
"wasm32" => {
if cx.sess().opts.target_triple.contains("emscripten") {
if cx.sess().opts.target_triple.triple().contains("emscripten") {
cabi_asmjs::compute_abi_info(cx, self)
} else {
cabi_wasm32::compute_abi_info(cx, self)

View file

@ -31,6 +31,7 @@ use rustc::util::fs::fix_windows_verbatim_for_gcc;
use rustc::hir::def_id::CrateNum;
use tempdir::TempDir;
use rustc_back::{PanicStrategy, RelroLevel};
use rustc_back::target::TargetTriple;
use context::get_reloc_model;
use llvm;
@ -81,7 +82,7 @@ pub fn get_linker(sess: &Session) -> (PathBuf, Command) {
}
};
let msvc_tool = windows_registry::find_tool(&sess.opts.target_triple, "link.exe");
let msvc_tool = windows_registry::find_tool(&sess.opts.target_triple.triple(), "link.exe");
let linker_path = sess.opts.cg.linker.as_ref().map(|s| &**s)
.or(sess.target.target.options.linker.as_ref().map(|s| s.as_ref()))
@ -812,7 +813,7 @@ fn link_natively(sess: &Session,
}
}
if sess.opts.target_triple == "wasm32-unknown-unknown" {
if sess.opts.target_triple == TargetTriple::from_triple("wasm32-unknown-unknown") {
wasm::rewrite_imports(&out_filename, &trans.crate_info.wasm_imports);
wasm::add_custom_sections(&out_filename,
&trans.crate_info.wasm_custom_sections);
@ -1090,7 +1091,7 @@ fn link_args(cmd: &mut Linker,
// addl_lib_search_paths
if sess.opts.cg.rpath {
let sysroot = sess.sysroot();
let target_triple = &sess.opts.target_triple;
let target_triple = sess.opts.target_triple.triple();
let mut get_install_prefix_lib_path = || {
let install_prefix = option_env!("CFG_PREFIX").expect("CFG_PREFIX");
let tlib = filesearch::relative_target_lib_path(sysroot, target_triple);

View file

@ -848,7 +848,7 @@ unsafe fn embed_bitcode(cgcx: &CodegenContext,
"rustc.embedded.module\0".as_ptr() as *const _,
);
llvm::LLVMSetInitializer(llglobal, llconst);
let section = if cgcx.opts.target_triple.contains("-ios") {
let section = if cgcx.opts.target_triple.triple().contains("-ios") {
"__LLVM,__bitcode\0"
} else {
".llvmbc\0"
@ -863,7 +863,7 @@ unsafe fn embed_bitcode(cgcx: &CodegenContext,
"rustc.embedded.cmdline\0".as_ptr() as *const _,
);
llvm::LLVMSetInitializer(llglobal, llconst);
let section = if cgcx.opts.target_triple.contains("-ios") {
let section = if cgcx.opts.target_triple.triple().contains("-ios") {
"__LLVM,__cmdline\0"
} else {
".llvmcmd\0"

View file

@ -73,6 +73,7 @@ use type_of::LayoutLlvmExt;
use rustc::util::nodemap::{FxHashMap, FxHashSet, DefIdSet};
use CrateInfo;
use rustc_data_structures::sync::Lrc;
use rustc_back::target::TargetTriple;
use std::any::Any;
use std::collections::BTreeMap;
@ -1079,7 +1080,7 @@ impl CrateInfo {
let load_wasm_items = tcx.sess.crate_types.borrow()
.iter()
.any(|c| *c != config::CrateTypeRlib) &&
tcx.sess.opts.target_triple == "wasm32-unknown-unknown";
tcx.sess.opts.target_triple == TargetTriple::from_triple("wasm32-unknown-unknown");
if load_wasm_items {
info!("attempting to load all wasm sections");