librustc_back: convert fn target() to return Result

Change all the target generation functions to return a Result<Target,
String> so that targets that are unable to be instantiated can be
expressed as an Err instead of a panic!(). This should improve #33497 as
well.
This commit is contained in:
Doug Goldstein 2016-07-24 11:47:39 -05:00
parent c7b6ed27bc
commit eafecbf868
45 changed files with 212 additions and 202 deletions

View File

@ -8,11 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::{Target, TargetOptions};
use target::{Target, TargetOptions, TargetResult};
use super::apple_ios_base::{opts, Arch};
pub fn target() -> Target {
Target {
pub fn target() -> TargetResult {
let base = try!(opts(Arch::Arm64));
Ok(Target {
llvm_target: "arm64-apple-ios".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
@ -25,7 +26,7 @@ pub fn target() -> Target {
features: "+neon,+fp-armv8,+cyclone".to_string(),
eliminate_frame_pointer: false,
max_atomic_width: 128,
.. opts(Arch::Arm64)
.. base
},
}
})
}

View File

@ -8,15 +8,15 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::Target;
use target::{Target, TargetResult};
pub fn target() -> Target {
pub fn target() -> TargetResult {
let mut base = super::android_base::opts();
base.max_atomic_width = 128;
// As documented in http://developer.android.com/ndk/guides/cpu-features.html
// the neon (ASIMD) and FP must exist on all android aarch64 targets.
base.features = "+neon,+fp-armv8".to_string();
Target {
Ok(Target {
llvm_target: "aarch64-linux-android".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
@ -26,5 +26,5 @@ pub fn target() -> Target {
target_env: "".to_string(),
target_vendor: "unknown".to_string(),
options: base,
}
})
}

View File

@ -8,12 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::Target;
use target::{Target, TargetResult};
pub fn target() -> Target {
pub fn target() -> TargetResult {
let mut base = super::linux_base::opts();
base.max_atomic_width = 128;
Target {
Ok(Target {
llvm_target: "aarch64-unknown-linux-gnu".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
@ -23,5 +23,5 @@ pub fn target() -> Target {
target_os: "linux".to_string(),
target_vendor: "unknown".to_string(),
options: base,
}
})
}

View File

@ -36,7 +36,7 @@ impl Arch {
}
}
pub fn get_sdk_root(sdk_name: &str) -> String {
pub fn get_sdk_root(sdk_name: &str) -> Result<String, String> {
let res = Command::new("xcrun")
.arg("--show-sdk-path")
.arg("-sdk")
@ -55,12 +55,12 @@ pub fn get_sdk_root(sdk_name: &str) -> String {
});
match res {
Ok(output) => output.trim().to_string(),
Err(e) => panic!("failed to get {} SDK path: {}", sdk_name, e)
Ok(output) => Ok(output.trim().to_string()),
Err(e) => Err(format!("failed to get {} SDK path: {}", sdk_name, e))
}
}
fn pre_link_args(arch: Arch) -> Vec<String> {
fn build_pre_link_args(arch: Arch) -> Result<Vec<String>, String> {
let sdk_name = match arch {
Armv7 | Armv7s | Arm64 => "iphoneos",
I386 | X86_64 => "iphonesimulator"
@ -68,8 +68,10 @@ fn pre_link_args(arch: Arch) -> Vec<String> {
let arch_name = arch.to_string();
vec!["-arch".to_string(), arch_name.to_string(),
"-Wl,-syslibroot".to_string(), get_sdk_root(sdk_name)]
let sdk_root = try!(get_sdk_root(sdk_name));
Ok(vec!["-arch".to_string(), arch_name.to_string(),
"-Wl,-syslibroot".to_string(), sdk_root])
}
fn target_cpu(arch: Arch) -> String {
@ -82,13 +84,14 @@ fn target_cpu(arch: Arch) -> String {
}.to_string()
}
pub fn opts(arch: Arch) -> TargetOptions {
TargetOptions {
pub fn opts(arch: Arch) -> Result<TargetOptions, String> {
let pre_link_args = try!(build_pre_link_args(arch));
Ok(TargetOptions {
cpu: target_cpu(arch),
dynamic_linking: false,
executables: true,
pre_link_args: pre_link_args(arch),
pre_link_args: pre_link_args,
has_elf_tls: false,
.. super::apple_base::opts()
}
})
}

View File

@ -8,14 +8,14 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::Target;
use target::{Target, TargetResult};
pub fn target() -> Target {
pub fn target() -> TargetResult {
let mut base = super::android_base::opts();
base.features = "+v7,+vfp3,+d16".to_string();
base.max_atomic_width = 64;
Target {
Ok(Target {
llvm_target: "arm-linux-androideabi".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
@ -25,5 +25,5 @@ pub fn target() -> Target {
target_env: "".to_string(),
target_vendor: "unknown".to_string(),
options: base,
}
})
}

View File

@ -8,12 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::{Target, TargetOptions};
use target::{Target, TargetOptions, TargetResult};
pub fn target() -> Target {
pub fn target() -> TargetResult {
let mut base = super::linux_base::opts();
base.max_atomic_width = 64;
Target {
Ok(Target {
llvm_target: "arm-unknown-linux-gnueabi".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
@ -27,5 +27,5 @@ pub fn target() -> Target {
features: "+v6".to_string(),
.. base
},
}
})
}

View File

@ -8,12 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::{Target, TargetOptions};
use target::{Target, TargetOptions, TargetResult};
pub fn target() -> Target {
pub fn target() -> TargetResult {
let mut base = super::linux_base::opts();
base.max_atomic_width = 64;
Target {
Ok(Target {
llvm_target: "arm-unknown-linux-gnueabihf".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
@ -27,5 +27,5 @@ pub fn target() -> Target {
features: "+v6,+vfp2".to_string(),
.. base
}
}
})
}

View File

@ -8,11 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::{Target, TargetOptions};
use target::{Target, TargetOptions, TargetResult};
use super::apple_ios_base::{opts, Arch};
pub fn target() -> Target {
Target {
pub fn target() -> TargetResult {
let base = try!(opts(Arch::Armv7));
Ok(Target {
llvm_target: "armv7-apple-ios".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
@ -24,7 +25,7 @@ pub fn target() -> Target {
options: TargetOptions {
features: "+v7,+vfp3,+neon".to_string(),
max_atomic_width: 64,
.. opts(Arch::Armv7)
.. base
}
}
})
}

View File

@ -8,14 +8,14 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::Target;
use target::{Target, TargetResult};
pub fn target() -> Target {
pub fn target() -> TargetResult {
let mut base = super::android_base::opts();
base.features = "+v7,+thumb2,+vfp3,+d16".to_string();
base.max_atomic_width = 64;
Target {
Ok(Target {
llvm_target: "armv7-none-linux-android".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
@ -25,5 +25,5 @@ pub fn target() -> Target {
target_env: "".to_string(),
target_vendor: "unknown".to_string(),
options: base,
}
})
}

View File

@ -8,11 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::{Target, TargetOptions};
use target::{Target, TargetOptions, TargetResult};
pub fn target() -> Target {
pub fn target() -> TargetResult {
let base = super::linux_base::opts();
Target {
Ok(Target {
llvm_target: "armv7-unknown-linux-gnueabihf".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
@ -28,6 +28,6 @@ pub fn target() -> Target {
max_atomic_width: 64,
.. base
}
}
})
}

View File

@ -8,11 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::{Target, TargetOptions};
use target::{Target, TargetOptions, TargetResult};
use super::apple_ios_base::{opts, Arch};
pub fn target() -> Target {
Target {
pub fn target() -> TargetResult {
let base = try!(opts(Arch::Armv7s));
Ok(Target {
llvm_target: "armv7s-apple-ios".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
@ -24,7 +25,7 @@ pub fn target() -> Target {
options: TargetOptions {
features: "+v7,+vfp4,+neon".to_string(),
max_atomic_width: 64,
.. opts(Arch::Armv7s)
.. base
}
}
})
}

View File

@ -10,7 +10,7 @@
use super::{Target, TargetOptions};
pub fn target() -> Target {
pub fn target() -> Result<Target, String> {
let opts = TargetOptions {
linker: "emcc".to_string(),
ar: "emar".to_string(),
@ -25,7 +25,7 @@ pub fn target() -> Target {
max_atomic_width: 32,
.. Default::default()
};
Target {
Ok(Target {
llvm_target: "asmjs-unknown-emscripten".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
@ -35,5 +35,5 @@ pub fn target() -> Target {
data_layout: "e-p:32:32-i64:64-v128:32:128-n32-S128".to_string(),
arch: "asmjs".to_string(),
options: opts,
}
})
}

View File

@ -8,11 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::{Target, TargetOptions};
use target::{Target, TargetOptions, TargetResult};
use super::apple_ios_base::{opts, Arch};
pub fn target() -> Target {
Target {
pub fn target() -> TargetResult {
let base = try!(opts(Arch::I386));
Ok(Target {
llvm_target: "i386-apple-ios".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
@ -23,7 +24,7 @@ pub fn target() -> Target {
target_vendor: "apple".to_string(),
options: TargetOptions {
max_atomic_width: 64,
.. opts(Arch::I386)
.. base
}
}
})
}

View File

@ -8,11 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::Target;
use target::TargetResult;
pub fn target() -> Target {
let mut base = super::i686_pc_windows_msvc::target();
pub fn target() -> TargetResult {
let mut base = try!(super::i686_pc_windows_msvc::target());
base.options.cpu = "pentium".to_string();
base.llvm_target = "i586-pc-windows-msvc".to_string();
return base
Ok(base)
}

View File

@ -8,11 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::Target;
use target::TargetResult;
pub fn target() -> Target {
let mut base = super::i686_unknown_linux_gnu::target();
pub fn target() -> TargetResult {
let mut base = try!(super::i686_unknown_linux_gnu::target());
base.options.cpu = "pentium".to_string();
base.llvm_target = "i586-unknown-linux-gnu".to_string();
return base
Ok(base)
}

View File

@ -8,15 +8,15 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::Target;
use target::{Target, TargetResult};
pub fn target() -> Target {
pub fn target() -> TargetResult {
let mut base = super::apple_base::opts();
base.cpu = "yonah".to_string();
base.max_atomic_width = 64;
base.pre_link_args.push("-m32".to_string());
Target {
Ok(Target {
llvm_target: "i686-apple-darwin".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
@ -26,5 +26,5 @@ pub fn target() -> Target {
target_env: "".to_string(),
target_vendor: "apple".to_string(),
options: base,
}
})
}

View File

@ -8,9 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::Target;
use target::{Target, TargetResult};
pub fn target() -> Target {
pub fn target() -> TargetResult {
let mut base = super::android_base::opts();
base.max_atomic_width = 64;
@ -19,7 +19,7 @@ pub fn target() -> Target {
base.cpu = "pentiumpro".to_string();
base.features = "+mmx,+sse,+sse2,+sse3,+ssse3".to_string();
Target {
Ok(Target {
llvm_target: "i686-linux-android".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
@ -29,5 +29,5 @@ pub fn target() -> Target {
target_env: "".to_string(),
target_vendor: "unknown".to_string(),
options: base,
}
})
}

View File

@ -8,9 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::Target;
use target::{Target, TargetResult};
pub fn target() -> Target {
pub fn target() -> TargetResult {
let mut base = super::windows_base::opts();
base.cpu = "pentium4".to_string();
base.max_atomic_width = 64;
@ -19,7 +19,7 @@ pub fn target() -> Target {
// space available to x86 Windows binaries on x86_64.
base.pre_link_args.push("-Wl,--large-address-aware".to_string());
Target {
Ok(Target {
llvm_target: "i686-pc-windows-gnu".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
@ -29,5 +29,5 @@ pub fn target() -> Target {
target_env: "gnu".to_string(),
target_vendor: "pc".to_string(),
options: base,
}
})
}

View File

@ -8,9 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::Target;
use target::{Target, TargetResult};
pub fn target() -> Target {
pub fn target() -> TargetResult {
let mut base = super::windows_msvc_base::opts();
base.cpu = "pentium4".to_string();
base.max_atomic_width = 64;
@ -24,7 +24,7 @@ pub fn target() -> Target {
// https://msdn.microsoft.com/en-us/library/9a89h429.aspx
base.pre_link_args.push("/SAFESEH".to_string());
Target {
Ok(Target {
llvm_target: "i686-pc-windows-msvc".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
@ -34,5 +34,5 @@ pub fn target() -> Target {
target_env: "msvc".to_string(),
target_vendor: "pc".to_string(),
options: base,
}
})
}

View File

@ -8,15 +8,15 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::Target;
use target::{Target, TargetResult};
pub fn target() -> Target {
pub fn target() -> TargetResult {
let mut base = super::dragonfly_base::opts();
base.cpu = "pentium4".to_string();
base.max_atomic_width = 64;
base.pre_link_args.push("-m32".to_string());
Target {
Ok(Target {
llvm_target: "i686-unknown-dragonfly".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
@ -26,5 +26,5 @@ pub fn target() -> Target {
target_env: "".to_string(),
target_vendor: "unknown".to_string(),
options: base,
}
})
}

View File

@ -8,15 +8,15 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::Target;
use target::{Target, TargetResult};
pub fn target() -> Target {
pub fn target() -> TargetResult {
let mut base = super::freebsd_base::opts();
base.cpu = "pentium4".to_string();
base.max_atomic_width = 64;
base.pre_link_args.push("-m32".to_string());
Target {
Ok(Target {
llvm_target: "i686-unknown-freebsd".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
@ -26,5 +26,5 @@ pub fn target() -> Target {
target_env: "".to_string(),
target_vendor: "unknown".to_string(),
options: base,
}
})
}

View File

@ -8,15 +8,15 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::Target;
use target::{Target, TargetResult};
pub fn target() -> Target {
pub fn target() -> TargetResult {
let mut base = super::linux_base::opts();
base.cpu = "pentium4".to_string();
base.max_atomic_width = 64;
base.pre_link_args.push("-m32".to_string());
Target {
Ok(Target {
llvm_target: "i686-unknown-linux-gnu".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
@ -26,5 +26,5 @@ pub fn target() -> Target {
target_env: "gnu".to_string(),
target_vendor: "unknown".to_string(),
options: base,
}
})
}

View File

@ -8,16 +8,16 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::Target;
use target::{Target, TargetResult};
pub fn target() -> Target {
pub fn target() -> TargetResult {
let mut base = super::linux_musl_base::opts();
base.cpu = "pentium4".to_string();
base.max_atomic_width = 64;
base.pre_link_args.push("-m32".to_string());
base.pre_link_args.push("-Wl,-melf_i386".to_string());
Target {
Ok(Target {
llvm_target: "i686-unknown-linux-musl".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
@ -27,5 +27,5 @@ pub fn target() -> Target {
target_env: "musl".to_string(),
target_vendor: "unknown".to_string(),
options: base,
}
})
}

View File

@ -8,9 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use super::{Target, TargetOptions};
use super::{Target, TargetOptions, TargetResult};
pub fn target() -> Target {
pub fn target() -> TargetResult {
let opts = TargetOptions {
linker: "pnacl-clang".to_string(),
ar: "pnacl-ar".to_string(),
@ -28,7 +28,7 @@ pub fn target() -> Target {
max_atomic_width: 32,
.. Default::default()
};
Target {
Ok(Target {
llvm_target: "le32-unknown-nacl".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
@ -38,5 +38,5 @@ pub fn target() -> Target {
data_layout: "e-i64:64:64-p:32:32:32-v128:32:32".to_string(),
arch: "le32".to_string(),
options: opts,
}
})
}

View File

@ -8,10 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::{Target, TargetOptions};
use target::{Target, TargetOptions, TargetResult};
pub fn target() -> Target {
Target {
pub fn target() -> TargetResult {
Ok(Target {
llvm_target: "mips-unknown-linux-gnu".to_string(),
target_endian: "big".to_string(),
target_pointer_width: "32".to_string(),
@ -26,5 +26,5 @@ pub fn target() -> Target {
max_atomic_width: 32,
..super::linux_base::opts()
},
}
})
}

View File

@ -8,10 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::{Target, TargetOptions};
use target::{Target, TargetOptions, TargetResult};
pub fn target() -> Target {
Target {
pub fn target() -> TargetResult {
Ok(Target {
llvm_target: "mips-unknown-linux-musl".to_string(),
target_endian: "big".to_string(),
target_pointer_width: "32".to_string(),
@ -26,5 +26,5 @@ pub fn target() -> Target {
max_atomic_width: 32,
..super::linux_base::opts()
}
}
})
}

View File

@ -8,10 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::{Target, TargetOptions};
use target::{Target, TargetOptions, TargetResult};
pub fn target() -> Target {
Target {
pub fn target() -> TargetResult {
Ok(Target {
llvm_target: "mipsel-unknown-linux-gnu".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
@ -27,5 +27,5 @@ pub fn target() -> Target {
max_atomic_width: 32,
..super::linux_base::opts()
},
}
})
}

View File

@ -8,10 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::{Target, TargetOptions};
use target::{Target, TargetOptions, TargetResult};
pub fn target() -> Target {
Target {
pub fn target() -> TargetResult {
Ok(Target {
llvm_target: "mipsel-unknown-linux-musl".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
@ -26,5 +26,5 @@ pub fn target() -> Target {
max_atomic_width: 32,
..super::linux_base::opts()
}
}
})
}

View File

@ -64,6 +64,8 @@ mod solaris_base;
mod windows_base;
mod windows_msvc_base;
pub type TargetResult = Result<Target, String>;
macro_rules! supported_targets {
( $(($triple:expr, $module:ident)),+ ) => (
$(mod $module;)*
@ -71,17 +73,17 @@ macro_rules! supported_targets {
/// List of supported targets
pub const TARGETS: &'static [&'static str] = &[$($triple),*];
fn load_specific(target: &str) -> Option<Target> {
fn load_specific(target: &str) -> TargetResult {
match target {
$(
$triple => {
let mut t = $module::target();
let mut t = try!($module::target());
t.options.is_builtin = true;
debug!("Got builtin target: {:?}", t);
Some(t)
Ok(t)
},
)+
_ => None
_ => Err(format!("Unable to find target: {}", target))
}
}
)
@ -364,7 +366,7 @@ impl Target {
}
/// Load a target descriptor from a JSON object.
pub fn from_json(obj: Json) -> Target {
pub fn from_json(obj: Json) -> TargetResult {
// While ugly, this code must remain this way to retain
// compatibility with existing JSON fields and the internal
// expected naming of the Target and TargetOptions structs.
@ -376,9 +378,9 @@ impl Target {
match obj.find(name)
.map(|s| s.as_string())
.and_then(|os| os.map(|s| s.to_string())) {
Some(val) => val,
Some(val) => Ok(val),
None => {
panic!("Field {} in target specification is required", name)
return Err(format!("Field {} in target specification is required", name))
}
}
};
@ -390,12 +392,12 @@ impl Target {
};
let mut base = Target {
llvm_target: get_req_field("llvm-target"),
target_endian: get_req_field("target-endian"),
target_pointer_width: get_req_field("target-pointer-width"),
data_layout: get_req_field("data-layout"),
arch: get_req_field("arch"),
target_os: get_req_field("os"),
llvm_target: try!(get_req_field("llvm-target")),
target_endian: try!(get_req_field("target-endian")),
target_pointer_width: try!(get_req_field("target-pointer-width")),
data_layout: try!(get_req_field("data-layout")),
arch: try!(get_req_field("arch")),
target_os: try!(get_req_field("os")),
target_env: get_opt_field("env", ""),
target_vendor: get_opt_field("vendor", "unknown"),
options: Default::default(),
@ -483,7 +485,7 @@ impl Target {
key!(obj_is_bitcode, bool);
key!(max_atomic_width, u64);
base
Ok(base)
}
/// Search RUST_TARGET_PATH for a JSON file specifying the given target
@ -506,10 +508,10 @@ impl Target {
f.read_to_end(&mut contents).map_err(|e| e.to_string())?;
let obj = json::from_reader(&mut &contents[..])
.map_err(|e| e.to_string())?;
Ok(Target::from_json(obj))
Target::from_json(obj)
}
if let Some(t) = load_specific(target) {
if let Ok(t) = load_specific(target) {
return Ok(t)
}

View File

@ -8,15 +8,15 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::Target;
use target::{Target, TargetResult};
pub fn target() -> Target {
pub fn target() -> TargetResult {
let mut base = super::linux_base::opts();
base.cpu = "ppc64".to_string();
base.pre_link_args.push("-m64".to_string());
base.max_atomic_width = 64;
Target {
Ok(Target {
llvm_target: "powerpc64-unknown-linux-gnu".to_string(),
target_endian: "big".to_string(),
target_pointer_width: "64".to_string(),
@ -26,5 +26,5 @@ pub fn target() -> Target {
target_env: "gnu".to_string(),
target_vendor: "unknown".to_string(),
options: base,
}
})
}

View File

@ -8,15 +8,15 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::Target;
use target::{Target, TargetResult};
pub fn target() -> Target {
pub fn target() -> TargetResult {
let mut base = super::linux_base::opts();
base.cpu = "ppc64le".to_string();
base.pre_link_args.push("-m64".to_string());
base.max_atomic_width = 64;
Target {
Ok(Target {
llvm_target: "powerpc64le-unknown-linux-gnu".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
@ -26,5 +26,5 @@ pub fn target() -> Target {
target_env: "gnu".to_string(),
target_vendor: "unknown".to_string(),
options: base,
}
})
}

View File

@ -8,14 +8,14 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::Target;
use target::{Target, TargetResult};
pub fn target() -> Target {
pub fn target() -> TargetResult {
let mut base = super::linux_base::opts();
base.pre_link_args.push("-m32".to_string());
base.max_atomic_width = 32;
Target {
Ok(Target {
llvm_target: "powerpc-unknown-linux-gnu".to_string(),
target_endian: "big".to_string(),
target_pointer_width: "32".to_string(),
@ -25,5 +25,5 @@ pub fn target() -> Target {
target_env: "gnu".to_string(),
target_vendor: "unknown".to_string(),
options: base,
}
})
}

View File

@ -8,16 +8,16 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::Target;
use target::{Target, TargetResult};
pub fn target() -> Target {
pub fn target() -> TargetResult {
let mut base = super::apple_base::opts();
base.cpu = "core2".to_string();
base.max_atomic_width = 128; // core2 support cmpxchg16b
base.eliminate_frame_pointer = false;
base.pre_link_args.push("-m64".to_string());
Target {
Ok(Target {
llvm_target: "x86_64-apple-darwin".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
@ -27,5 +27,5 @@ pub fn target() -> Target {
target_env: "".to_string(),
target_vendor: "apple".to_string(),
options: base,
}
})
}

View File

@ -8,11 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::{Target, TargetOptions};
use target::{Target, TargetOptions, TargetResult};
use super::apple_ios_base::{opts, Arch};
pub fn target() -> Target {
Target {
pub fn target() -> TargetResult {
let base = try!(opts(Arch::X86_64));
Ok(Target {
llvm_target: "x86_64-apple-ios".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
@ -23,7 +24,7 @@ pub fn target() -> Target {
target_vendor: "apple".to_string(),
options: TargetOptions {
max_atomic_width: 64,
.. opts(Arch::X86_64)
.. base
}
}
})
}

View File

@ -8,15 +8,15 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::Target;
use target::{Target, TargetResult};
pub fn target() -> Target {
pub fn target() -> TargetResult {
let mut base = super::windows_base::opts();
base.cpu = "x86-64".to_string();
base.pre_link_args.push("-m64".to_string());
base.max_atomic_width = 64;
Target {
Ok(Target {
llvm_target: "x86_64-pc-windows-gnu".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
@ -26,5 +26,5 @@ pub fn target() -> Target {
target_env: "gnu".to_string(),
target_vendor: "pc".to_string(),
options: base,
}
})
}

View File

@ -8,14 +8,14 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::Target;
use target::{Target, TargetResult};
pub fn target() -> Target {
pub fn target() -> TargetResult {
let mut base = super::windows_msvc_base::opts();
base.cpu = "x86-64".to_string();
base.max_atomic_width = 64;
Target {
Ok(Target {
llvm_target: "x86_64-pc-windows-msvc".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
@ -25,5 +25,5 @@ pub fn target() -> Target {
target_env: "msvc".to_string(),
target_vendor: "pc".to_string(),
options: base,
}
})
}

View File

@ -8,9 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::Target;
use target::{Target, TargetResult};
pub fn target() -> Target {
pub fn target() -> TargetResult {
let mut base = super::netbsd_base::opts();
base.pre_link_args.push("-m64".to_string());
base.linker = "x86_64-rumprun-netbsd-gcc".to_string();
@ -24,7 +24,7 @@ pub fn target() -> Target {
base.no_default_libraries = false;
base.exe_allocation_crate = "alloc_system".to_string();
Target {
Ok(Target {
llvm_target: "x86_64-rumprun-netbsd".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
@ -34,5 +34,5 @@ pub fn target() -> Target {
target_env: "".to_string(),
target_vendor: "rumprun".to_string(),
options: base,
}
})
}

View File

@ -8,15 +8,15 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::Target;
use target::{Target, TargetResult};
pub fn target() -> Target {
pub fn target() -> TargetResult {
let mut base = super::solaris_base::opts();
base.pre_link_args.push("-m64".to_string());
base.cpu = "x86-64".to_string();
base.max_atomic_width = 64;
Target {
Ok(Target {
llvm_target: "x86_64-pc-solaris".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
@ -26,5 +26,5 @@ pub fn target() -> Target {
target_env: "".to_string(),
target_vendor: "sun".to_string(),
options: base,
}
})
}

View File

@ -8,14 +8,14 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::Target;
use target::{Target, TargetResult};
pub fn target() -> Target {
pub fn target() -> TargetResult {
let mut base = super::bitrig_base::opts();
base.max_atomic_width = 64;
base.pre_link_args.push("-m64".to_string());
Target {
Ok(Target {
llvm_target: "x86_64-unknown-bitrig".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
@ -25,5 +25,5 @@ pub fn target() -> Target {
target_env: "".to_string(),
target_vendor: "unknown".to_string(),
options: base,
}
})
}

View File

@ -8,15 +8,15 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::Target;
use target::{Target, TargetResult};
pub fn target() -> Target {
pub fn target() -> TargetResult {
let mut base = super::dragonfly_base::opts();
base.cpu = "x86-64".to_string();
base.max_atomic_width = 64;
base.pre_link_args.push("-m64".to_string());
Target {
Ok(Target {
llvm_target: "x86_64-unknown-dragonfly".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
@ -26,5 +26,5 @@ pub fn target() -> Target {
target_env: "".to_string(),
target_vendor: "unknown".to_string(),
options: base,
}
})
}

View File

@ -8,15 +8,15 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::Target;
use target::{Target, TargetResult};
pub fn target() -> Target {
pub fn target() -> TargetResult {
let mut base = super::freebsd_base::opts();
base.cpu = "x86-64".to_string();
base.max_atomic_width = 64;
base.pre_link_args.push("-m64".to_string());
Target {
Ok(Target {
llvm_target: "x86_64-unknown-freebsd".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
@ -26,5 +26,5 @@ pub fn target() -> Target {
target_env: "".to_string(),
target_vendor: "unknown".to_string(),
options: base,
}
})
}

View File

@ -8,15 +8,15 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::Target;
use target::{Target, TargetResult};
pub fn target() -> Target {
pub fn target() -> TargetResult {
let mut base = super::linux_base::opts();
base.cpu = "x86-64".to_string();
base.max_atomic_width = 64;
base.pre_link_args.push("-m64".to_string());
Target {
Ok(Target {
llvm_target: "x86_64-unknown-linux-gnu".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
@ -26,5 +26,5 @@ pub fn target() -> Target {
target_env: "gnu".to_string(),
target_vendor: "unknown".to_string(),
options: base,
}
})
}

View File

@ -8,15 +8,15 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::Target;
use target::{Target, TargetResult};
pub fn target() -> Target {
pub fn target() -> TargetResult {
let mut base = super::linux_musl_base::opts();
base.cpu = "x86-64".to_string();
base.max_atomic_width = 64;
base.pre_link_args.push("-m64".to_string());
Target {
Ok(Target {
llvm_target: "x86_64-unknown-linux-musl".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
@ -26,5 +26,5 @@ pub fn target() -> Target {
target_env: "musl".to_string(),
target_vendor: "unknown".to_string(),
options: base,
}
})
}

View File

@ -8,14 +8,14 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::Target;
use target::{Target, TargetResult};
pub fn target() -> Target {
pub fn target() -> TargetResult {
let mut base = super::netbsd_base::opts();
base.max_atomic_width = 64;
base.pre_link_args.push("-m64".to_string());
Target {
Ok(Target {
llvm_target: "x86_64-unknown-netbsd".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
@ -25,5 +25,5 @@ pub fn target() -> Target {
target_env: "".to_string(),
target_vendor: "unknown".to_string(),
options: base,
}
})
}

View File

@ -8,15 +8,15 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::Target;
use target::{Target, TargetResult};
pub fn target() -> Target {
pub fn target() -> TargetResult {
let mut base = super::openbsd_base::opts();
base.cpu = "x86-64".to_string();
base.max_atomic_width = 64;
base.pre_link_args.push("-m64".to_string());
Target {
Ok(Target {
llvm_target: "x86_64-unknown-openbsd".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
@ -26,5 +26,5 @@ pub fn target() -> Target {
target_env: "".to_string(),
target_vendor: "unknown".to_string(),
options: base,
}
})
}