From cdf6cebc0010653aa2fbf315f7f7660983d007da Mon Sep 17 00:00:00 2001 From: Richard Diamond Date: Mon, 7 Sep 2015 00:35:57 -0500 Subject: Refactor `TargetOptions::data_layout` into an `Option`al value to reflect current usage. NFC. --- src/librustc_back/target/mod.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/librustc_back') diff --git a/src/librustc_back/target/mod.rs b/src/librustc_back/target/mod.rs index 1f3b823d008..56562c8dfdb 100644 --- a/src/librustc_back/target/mod.rs +++ b/src/librustc_back/target/mod.rs @@ -91,7 +91,7 @@ pub struct Target { #[derive(Clone, Debug)] pub struct TargetOptions { /// [Data layout](http://llvm.org/docs/LangRef.html#data-layout) to pass to LLVM. - pub data_layout: String, + pub data_layout: Option, /// Linker to invoke. Defaults to "cc". pub linker: String, /// Archive utility to use when managing archives. Defaults to "ar". @@ -186,7 +186,7 @@ impl Default for TargetOptions { /// incomplete, and if used for compilation, will certainly not work. fn default() -> TargetOptions { TargetOptions { - data_layout: String::new(), + data_layout: None, linker: option_env!("CFG_DEFAULT_LINKER").unwrap_or("cc").to_string(), ar: option_env!("CFG_DEFAULT_AR").unwrap_or("ar").to_string(), pre_link_args: Vec::new(), @@ -287,6 +287,14 @@ impl Target { ) ); } ); + ($key_name:ident, optional) => ( { + let name = (stringify!($key_name)).replace("_", "-"); + if let Some(o) = obj.find(&name[..]) { + base.options.$key_name = o + .as_string() + .map(|s| s.to_string() ); + } + } ); } key!(cpu); @@ -300,7 +308,7 @@ impl Target { key!(staticlib_prefix); key!(staticlib_suffix); key!(features); - key!(data_layout); + key!(data_layout, optional); key!(dynamic_linking, bool); key!(executables, bool); key!(disable_redzone, bool); -- cgit 1.4.1-3-g733a5