mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-10 14:02:57 +00:00
Return L4Re TargetOptions as a Result type instead of panic
If the environment variable L4RE_LIBDIR ist not set an Error will be returned wrapped in a result type instead of a panic.
This commit is contained in:
parent
beedf4e7d8
commit
c60fc4bd58
@ -26,9 +26,9 @@ fn get_path_or(filename: &str) -> String {
|
||||
.expect("Couldn't read path from GCC").trim().into()
|
||||
}
|
||||
|
||||
pub fn opts() -> TargetOptions {
|
||||
let l4re_lib_path = env::var_os("L4RE_LIBDIR").expect("Unable to find L4Re \
|
||||
library directory: L4RE_LIBDIR not set.").into_string().unwrap();
|
||||
pub fn opts() -> Result<TargetOptions, String> {
|
||||
let l4re_lib_path = env::var_os("L4RE_LIBDIR").ok_or("Unable to find L4Re \
|
||||
library directory: L4RE_LIBDIR not set.")?.into_string().unwrap();
|
||||
let mut pre_link_args = LinkArgs::new();
|
||||
pre_link_args.insert(LinkerFlavor::Ld, vec![
|
||||
format!("-T{}/main_stat.ld", l4re_lib_path),
|
||||
@ -68,7 +68,7 @@ pub fn opts() -> TargetOptions {
|
||||
format!("{}/crtn.o", l4re_lib_path),
|
||||
]);
|
||||
|
||||
TargetOptions {
|
||||
Ok(TargetOptions {
|
||||
executables: true,
|
||||
has_elf_tls: false,
|
||||
exe_allocation_crate: None,
|
||||
@ -78,5 +78,5 @@ pub fn opts() -> TargetOptions {
|
||||
post_link_args,
|
||||
target_family: Some("unix".to_string()),
|
||||
.. Default::default()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ use LinkerFlavor;
|
||||
use target::{Target, TargetResult};
|
||||
|
||||
pub fn target() -> TargetResult {
|
||||
let mut base = super::l4re_base::opts();
|
||||
let mut base = super::l4re_base::opts()?;
|
||||
base.cpu = "x86-64".to_string();
|
||||
base.max_atomic_width = Some(64);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user