Allow setting target_family
to multiple values
This enables us to set more generic labels shared between targets. For example `target_family="wasm"` across all targets that are conceptually "wasm". See https://github.com/rust-lang/reference/pull/1006
This commit is contained in:
parent
72c63de2cc
commit
4afea69090
18 changed files with 36 additions and 30 deletions
|
@ -813,7 +813,7 @@ pub fn default_configuration(sess: &Session) -> CrateConfig {
|
||||||
ret.reserve(6); // the minimum number of insertions
|
ret.reserve(6); // the minimum number of insertions
|
||||||
// Target bindings.
|
// Target bindings.
|
||||||
ret.insert((sym::target_os, Some(Symbol::intern(os))));
|
ret.insert((sym::target_os, Some(Symbol::intern(os))));
|
||||||
if let Some(ref fam) = sess.target.os_family {
|
for fam in &sess.target.families {
|
||||||
ret.insert((sym::target_family, Some(Symbol::intern(fam))));
|
ret.insert((sym::target_family, Some(Symbol::intern(fam))));
|
||||||
if fam == "windows" {
|
if fam == "windows" {
|
||||||
ret.insert((sym::windows, None));
|
ret.insert((sym::windows, None));
|
||||||
|
|
|
@ -23,7 +23,7 @@ pub fn opts(os: &str) -> TargetOptions {
|
||||||
function_sections: false,
|
function_sections: false,
|
||||||
dynamic_linking: true,
|
dynamic_linking: true,
|
||||||
executables: true,
|
executables: true,
|
||||||
os_family: Some("unix".to_string()),
|
families: vec!["unix".to_string()],
|
||||||
is_like_osx: true,
|
is_like_osx: true,
|
||||||
dwarf_version: Some(2),
|
dwarf_version: Some(2),
|
||||||
has_rpath: true,
|
has_rpath: true,
|
||||||
|
|
|
@ -5,7 +5,7 @@ pub fn opts() -> TargetOptions {
|
||||||
os: "dragonfly".to_string(),
|
os: "dragonfly".to_string(),
|
||||||
dynamic_linking: true,
|
dynamic_linking: true,
|
||||||
executables: true,
|
executables: true,
|
||||||
os_family: Some("unix".to_string()),
|
families: vec!["unix".to_string()],
|
||||||
linker_is_gnu: true,
|
linker_is_gnu: true,
|
||||||
has_rpath: true,
|
has_rpath: true,
|
||||||
position_independent_executables: true,
|
position_independent_executables: true,
|
||||||
|
|
|
@ -5,7 +5,7 @@ pub fn opts() -> TargetOptions {
|
||||||
os: "freebsd".to_string(),
|
os: "freebsd".to_string(),
|
||||||
dynamic_linking: true,
|
dynamic_linking: true,
|
||||||
executables: true,
|
executables: true,
|
||||||
os_family: Some("unix".to_string()),
|
families: vec!["unix".to_string()],
|
||||||
linker_is_gnu: true,
|
linker_is_gnu: true,
|
||||||
has_rpath: true,
|
has_rpath: true,
|
||||||
position_independent_executables: true,
|
position_independent_executables: true,
|
||||||
|
|
|
@ -25,7 +25,7 @@ pub fn opts() -> TargetOptions {
|
||||||
linker: Some("rust-lld".to_owned()),
|
linker: Some("rust-lld".to_owned()),
|
||||||
dynamic_linking: true,
|
dynamic_linking: true,
|
||||||
executables: true,
|
executables: true,
|
||||||
os_family: Some("unix".to_string()),
|
families: vec!["unix".to_string()],
|
||||||
is_like_fuchsia: true,
|
is_like_fuchsia: true,
|
||||||
linker_is_gnu: true,
|
linker_is_gnu: true,
|
||||||
pre_link_args,
|
pre_link_args,
|
||||||
|
|
|
@ -5,7 +5,7 @@ pub fn opts() -> TargetOptions {
|
||||||
os: "haiku".to_string(),
|
os: "haiku".to_string(),
|
||||||
dynamic_linking: true,
|
dynamic_linking: true,
|
||||||
executables: true,
|
executables: true,
|
||||||
os_family: Some("unix".to_string()),
|
families: vec!["unix".to_string()],
|
||||||
relro_level: RelroLevel::Full,
|
relro_level: RelroLevel::Full,
|
||||||
linker_is_gnu: true,
|
linker_is_gnu: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
|
|
@ -20,7 +20,7 @@ pub fn opts() -> TargetOptions {
|
||||||
dynamic_linking: true,
|
dynamic_linking: true,
|
||||||
executables: true,
|
executables: true,
|
||||||
has_rpath: true,
|
has_rpath: true,
|
||||||
os_family: Some("unix".to_string()),
|
families: vec!["unix".to_string()],
|
||||||
is_like_solaris: true,
|
is_like_solaris: true,
|
||||||
limit_rdylib_exports: false, // Linker doesn't support this
|
limit_rdylib_exports: false, // Linker doesn't support this
|
||||||
eliminate_frame_pointer: false,
|
eliminate_frame_pointer: false,
|
||||||
|
|
|
@ -20,7 +20,7 @@ pub fn opts() -> TargetOptions {
|
||||||
executables: true,
|
executables: true,
|
||||||
panic_strategy: PanicStrategy::Abort,
|
panic_strategy: PanicStrategy::Abort,
|
||||||
linker: Some("ld".to_string()),
|
linker: Some("ld".to_string()),
|
||||||
os_family: Some("unix".to_string()),
|
families: vec!["unix".to_string()],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ pub fn opts() -> TargetOptions {
|
||||||
os: "linux".to_string(),
|
os: "linux".to_string(),
|
||||||
dynamic_linking: true,
|
dynamic_linking: true,
|
||||||
executables: true,
|
executables: true,
|
||||||
os_family: Some("unix".to_string()),
|
families: vec!["unix".to_string()],
|
||||||
linker_is_gnu: true,
|
linker_is_gnu: true,
|
||||||
has_rpath: true,
|
has_rpath: true,
|
||||||
position_independent_executables: true,
|
position_independent_executables: true,
|
||||||
|
|
|
@ -1042,8 +1042,12 @@ pub struct TargetOptions {
|
||||||
pub staticlib_prefix: String,
|
pub staticlib_prefix: String,
|
||||||
/// String to append to the name of every static library. Defaults to ".a".
|
/// String to append to the name of every static library. Defaults to ".a".
|
||||||
pub staticlib_suffix: String,
|
pub staticlib_suffix: String,
|
||||||
/// OS family to use for conditional compilation. Valid options: "unix", "windows".
|
/// Values of the `target_family` cfg set for this target.
|
||||||
pub os_family: Option<String>,
|
///
|
||||||
|
/// Common options are: "unix", "windows". Defaults to no families.
|
||||||
|
///
|
||||||
|
/// See https://doc.rust-lang.org/reference/conditional-compilation.html#target_family
|
||||||
|
pub families: Vec<String>,
|
||||||
/// Whether the target toolchain's ABI supports returning small structs as an integer.
|
/// Whether the target toolchain's ABI supports returning small structs as an integer.
|
||||||
pub abi_return_struct_as_int: bool,
|
pub abi_return_struct_as_int: bool,
|
||||||
/// Whether the target toolchain is like macOS's. Only useful for compiling against iOS/macOS,
|
/// Whether the target toolchain is like macOS's. Only useful for compiling against iOS/macOS,
|
||||||
|
@ -1293,7 +1297,7 @@ impl Default for TargetOptions {
|
||||||
exe_suffix: String::new(),
|
exe_suffix: String::new(),
|
||||||
staticlib_prefix: "lib".to_string(),
|
staticlib_prefix: "lib".to_string(),
|
||||||
staticlib_suffix: ".a".to_string(),
|
staticlib_suffix: ".a".to_string(),
|
||||||
os_family: None,
|
families: Vec::new(),
|
||||||
abi_return_struct_as_int: false,
|
abi_return_struct_as_int: false,
|
||||||
is_like_osx: false,
|
is_like_osx: false,
|
||||||
is_like_solaris: false,
|
is_like_solaris: false,
|
||||||
|
@ -1605,14 +1609,6 @@ impl Target {
|
||||||
.map(|s| s.to_string() );
|
.map(|s| s.to_string() );
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
($key_name:ident = $json_name:expr, optional) => ( {
|
|
||||||
let name = $json_name;
|
|
||||||
if let Some(o) = obj.find(name) {
|
|
||||||
base.$key_name = o
|
|
||||||
.as_string()
|
|
||||||
.map(|s| s.to_string() );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
($key_name:ident, LldFlavor) => ( {
|
($key_name:ident, LldFlavor) => ( {
|
||||||
let name = (stringify!($key_name)).replace("_", "-");
|
let name = (stringify!($key_name)).replace("_", "-");
|
||||||
obj.find(&name[..]).and_then(|o| o.as_string().and_then(|s| {
|
obj.find(&name[..]).and_then(|o| o.as_string().and_then(|s| {
|
||||||
|
@ -1759,6 +1755,16 @@ impl Target {
|
||||||
Some(Ok(()))
|
Some(Ok(()))
|
||||||
})).unwrap_or(Ok(()))
|
})).unwrap_or(Ok(()))
|
||||||
} );
|
} );
|
||||||
|
($key_name:ident, TargetFamilies) => ( {
|
||||||
|
let value = obj.find("target-family");
|
||||||
|
if let Some(v) = value.and_then(Json::as_array) {
|
||||||
|
base.$key_name = v.iter()
|
||||||
|
.map(|a| a.as_string().unwrap().to_string())
|
||||||
|
.collect();
|
||||||
|
} else if let Some(v) = value.and_then(Json::as_string) {
|
||||||
|
base.$key_name = vec![v.to_string()];
|
||||||
|
}
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(s) = obj.find("target-endian").and_then(Json::as_string) {
|
if let Some(s) = obj.find("target-endian").and_then(Json::as_string) {
|
||||||
|
@ -1802,7 +1808,7 @@ impl Target {
|
||||||
key!(exe_suffix);
|
key!(exe_suffix);
|
||||||
key!(staticlib_prefix);
|
key!(staticlib_prefix);
|
||||||
key!(staticlib_suffix);
|
key!(staticlib_suffix);
|
||||||
key!(os_family = "target-family", optional);
|
key!(families, TargetFamilies);
|
||||||
key!(abi_return_struct_as_int, bool);
|
key!(abi_return_struct_as_int, bool);
|
||||||
key!(is_like_osx, bool);
|
key!(is_like_osx, bool);
|
||||||
key!(is_like_solaris, bool);
|
key!(is_like_solaris, bool);
|
||||||
|
@ -2042,7 +2048,7 @@ impl ToJson for Target {
|
||||||
target_option_val!(exe_suffix);
|
target_option_val!(exe_suffix);
|
||||||
target_option_val!(staticlib_prefix);
|
target_option_val!(staticlib_prefix);
|
||||||
target_option_val!(staticlib_suffix);
|
target_option_val!(staticlib_suffix);
|
||||||
target_option_val!(os_family, "target-family");
|
target_option_val!(families, "target-family");
|
||||||
target_option_val!(abi_return_struct_as_int);
|
target_option_val!(abi_return_struct_as_int);
|
||||||
target_option_val!(is_like_osx);
|
target_option_val!(is_like_osx);
|
||||||
target_option_val!(is_like_solaris);
|
target_option_val!(is_like_solaris);
|
||||||
|
|
|
@ -5,7 +5,7 @@ pub fn opts() -> TargetOptions {
|
||||||
os: "netbsd".to_string(),
|
os: "netbsd".to_string(),
|
||||||
dynamic_linking: true,
|
dynamic_linking: true,
|
||||||
executables: true,
|
executables: true,
|
||||||
os_family: Some("unix".to_string()),
|
families: vec!["unix".to_string()],
|
||||||
linker_is_gnu: true,
|
linker_is_gnu: true,
|
||||||
no_default_libraries: false,
|
no_default_libraries: false,
|
||||||
has_rpath: true,
|
has_rpath: true,
|
||||||
|
|
|
@ -5,7 +5,7 @@ pub fn opts() -> TargetOptions {
|
||||||
os: "openbsd".to_string(),
|
os: "openbsd".to_string(),
|
||||||
dynamic_linking: true,
|
dynamic_linking: true,
|
||||||
executables: true,
|
executables: true,
|
||||||
os_family: Some("unix".to_string()),
|
families: vec!["unix".to_string()],
|
||||||
linker_is_gnu: true,
|
linker_is_gnu: true,
|
||||||
has_rpath: true,
|
has_rpath: true,
|
||||||
abi_return_struct_as_int: true,
|
abi_return_struct_as_int: true,
|
||||||
|
|
|
@ -6,7 +6,7 @@ pub fn opts() -> TargetOptions {
|
||||||
env: "relibc".to_string(),
|
env: "relibc".to_string(),
|
||||||
dynamic_linking: true,
|
dynamic_linking: true,
|
||||||
executables: true,
|
executables: true,
|
||||||
os_family: Some("unix".to_string()),
|
families: vec!["unix".to_string()],
|
||||||
linker_is_gnu: true,
|
linker_is_gnu: true,
|
||||||
has_rpath: true,
|
has_rpath: true,
|
||||||
position_independent_executables: true,
|
position_independent_executables: true,
|
||||||
|
|
|
@ -6,7 +6,7 @@ pub fn opts() -> TargetOptions {
|
||||||
dynamic_linking: true,
|
dynamic_linking: true,
|
||||||
executables: true,
|
executables: true,
|
||||||
has_rpath: true,
|
has_rpath: true,
|
||||||
os_family: Some("unix".to_string()),
|
families: vec!["unix".to_string()],
|
||||||
is_like_solaris: true,
|
is_like_solaris: true,
|
||||||
limit_rdylib_exports: false, // Linker doesn't support this
|
limit_rdylib_exports: false, // Linker doesn't support this
|
||||||
eh_frame_header: false,
|
eh_frame_header: false,
|
||||||
|
|
|
@ -9,7 +9,7 @@ pub fn opts() -> TargetOptions {
|
||||||
exe_suffix: ".vxe".to_string(),
|
exe_suffix: ".vxe".to_string(),
|
||||||
dynamic_linking: true,
|
dynamic_linking: true,
|
||||||
executables: true,
|
executables: true,
|
||||||
os_family: Some("unix".to_string()),
|
families: vec!["unix".to_string()],
|
||||||
linker_is_gnu: true,
|
linker_is_gnu: true,
|
||||||
has_rpath: true,
|
has_rpath: true,
|
||||||
has_elf_tls: true,
|
has_elf_tls: true,
|
||||||
|
|
|
@ -38,7 +38,7 @@ pub fn target() -> Target {
|
||||||
is_like_emscripten: true,
|
is_like_emscripten: true,
|
||||||
panic_strategy: PanicStrategy::Unwind,
|
panic_strategy: PanicStrategy::Unwind,
|
||||||
post_link_args,
|
post_link_args,
|
||||||
os_family: Some("unix".to_string()),
|
families: vec!["unix".to_string()],
|
||||||
..options
|
..options
|
||||||
};
|
};
|
||||||
Target {
|
Target {
|
||||||
|
|
|
@ -71,7 +71,7 @@ pub fn opts() -> TargetOptions {
|
||||||
dll_prefix: String::new(),
|
dll_prefix: String::new(),
|
||||||
dll_suffix: ".dll".to_string(),
|
dll_suffix: ".dll".to_string(),
|
||||||
exe_suffix: ".exe".to_string(),
|
exe_suffix: ".exe".to_string(),
|
||||||
os_family: Some("windows".to_string()),
|
families: vec!["windows".to_string()],
|
||||||
is_like_windows: true,
|
is_like_windows: true,
|
||||||
allows_weak_linkage: false,
|
allows_weak_linkage: false,
|
||||||
pre_link_args,
|
pre_link_args,
|
||||||
|
|
|
@ -13,7 +13,7 @@ pub fn opts() -> TargetOptions {
|
||||||
exe_suffix: ".exe".to_string(),
|
exe_suffix: ".exe".to_string(),
|
||||||
staticlib_prefix: String::new(),
|
staticlib_prefix: String::new(),
|
||||||
staticlib_suffix: ".lib".to_string(),
|
staticlib_suffix: ".lib".to_string(),
|
||||||
os_family: Some("windows".to_string()),
|
families: vec!["windows".to_string()],
|
||||||
crt_static_allows_dylibs: true,
|
crt_static_allows_dylibs: true,
|
||||||
crt_static_respected: true,
|
crt_static_respected: true,
|
||||||
requires_uwtable: true,
|
requires_uwtable: true,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue