rustc: Add target_env for triples by default
This adds a new `#[cfg]` matcher against the `target_env` property of the destination target triple. For example all windows triples today end with `-gnu` but we will also hopefully support non-`gnu` targets for Windows, at which point we'll need to differentiate between the two. This new `target_env` matches is provided and filled in with the target's environment name. Currently the only non-empty value of this name is `gnu`, but `musl` will be shortly added for the linux triples.
This commit is contained in:
parent
681fc82456
commit
ba2380d7b3
26 changed files with 31 additions and 2 deletions
|
@ -621,6 +621,7 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
|
|||
let arch = &sess.target.target.arch;
|
||||
let wordsz = &sess.target.target.target_pointer_width;
|
||||
let os = &sess.target.target.target_os;
|
||||
let env = &sess.target.target.target_env;
|
||||
|
||||
let fam = match sess.target.target.options.is_like_windows {
|
||||
true => InternedString::new("windows"),
|
||||
|
@ -634,8 +635,8 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
|
|||
mk(InternedString::new("target_family"), fam),
|
||||
mk(InternedString::new("target_arch"), intern(arch)),
|
||||
mk(InternedString::new("target_endian"), intern(end)),
|
||||
mk(InternedString::new("target_pointer_width"),
|
||||
intern(wordsz))
|
||||
mk(InternedString::new("target_pointer_width"), intern(wordsz)),
|
||||
mk(InternedString::new("target_env"), intern(env)),
|
||||
];
|
||||
if sess.opts.debug_assertions {
|
||||
ret.push(attr::mk_word_item(InternedString::new("debug_assertions")));
|
||||
|
|
|
@ -22,6 +22,7 @@ pub fn target() -> Target {
|
|||
target_pointer_width: "64".to_string(),
|
||||
arch: "aarch64".to_string(),
|
||||
target_os: "ios".to_string(),
|
||||
target_env: "".to_string(),
|
||||
options: TargetOptions {
|
||||
features: "+neon,+fp-armv8,+cyclone".to_string(),
|
||||
eliminate_frame_pointer: false,
|
||||
|
|
|
@ -24,6 +24,7 @@ pub fn target() -> Target {
|
|||
target_pointer_width: "64".to_string(),
|
||||
arch: "aarch64".to_string(),
|
||||
target_os: "android".to_string(),
|
||||
target_env: "".to_string(),
|
||||
options: base,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ pub fn target() -> Target {
|
|||
llvm_target: "aarch64-unknown-linux-gnu".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
target_pointer_width: "64".to_string(),
|
||||
target_env: "gnu".to_string(),
|
||||
arch: "aarch64".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
options: base,
|
||||
|
|
|
@ -31,6 +31,7 @@ pub fn target() -> Target {
|
|||
target_pointer_width: "32".to_string(),
|
||||
arch: "arm".to_string(),
|
||||
target_os: "android".to_string(),
|
||||
target_env: "gnu".to_string(),
|
||||
options: base,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ pub fn target() -> Target {
|
|||
target_pointer_width: "32".to_string(),
|
||||
arch: "arm".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
target_env: "gnueabi".to_string(),
|
||||
|
||||
options: TargetOptions {
|
||||
features: "+v6".to_string(),
|
||||
|
|
|
@ -23,6 +23,7 @@ pub fn target() -> Target {
|
|||
target_pointer_width: "32".to_string(),
|
||||
arch: "arm".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
target_env: "gnueabihf".to_string(),
|
||||
|
||||
options: TargetOptions {
|
||||
features: "+v6,+vfp2".to_string(),
|
||||
|
|
|
@ -19,6 +19,7 @@ pub fn target() -> Target {
|
|||
target_pointer_width: "32".to_string(),
|
||||
arch: "arm".to_string(),
|
||||
target_os: "ios".to_string(),
|
||||
target_env: "".to_string(),
|
||||
options: TargetOptions {
|
||||
features: "+v7,+vfp3,+neon".to_string(),
|
||||
.. opts(Arch::Armv7)
|
||||
|
|
|
@ -19,6 +19,7 @@ pub fn target() -> Target {
|
|||
target_pointer_width: "32".to_string(),
|
||||
arch: "arm".to_string(),
|
||||
target_os: "ios".to_string(),
|
||||
target_env: "".to_string(),
|
||||
options: TargetOptions {
|
||||
features: "+v7,+vfp4,+neon".to_string(),
|
||||
.. opts(Arch::Armv7s)
|
||||
|
|
|
@ -23,6 +23,7 @@ pub fn target() -> Target {
|
|||
target_pointer_width: "32".to_string(),
|
||||
arch: "x86".to_string(),
|
||||
target_os: "ios".to_string(),
|
||||
target_env: "".to_string(),
|
||||
options: opts(Arch::I386)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ pub fn target() -> Target {
|
|||
target_pointer_width: "32".to_string(),
|
||||
arch: "x86".to_string(),
|
||||
target_os: "macos".to_string(),
|
||||
target_env: "".to_string(),
|
||||
options: base,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ pub fn target() -> Target {
|
|||
target_pointer_width: "32".to_string(),
|
||||
arch: "x86".to_string(),
|
||||
target_os: "windows".to_string(),
|
||||
target_env: "gnu".to_string(),
|
||||
options: options,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ pub fn target() -> Target {
|
|||
target_pointer_width: "32".to_string(),
|
||||
arch: "x86".to_string(),
|
||||
target_os: "dragonfly".to_string(),
|
||||
target_env: "".to_string(),
|
||||
options: base,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ pub fn target() -> Target {
|
|||
target_pointer_width: "32".to_string(),
|
||||
arch: "x86".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
target_env: "gnu".to_string(),
|
||||
options: base,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ pub fn target() -> Target {
|
|||
target_pointer_width: "32".to_string(),
|
||||
arch: "mips".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
target_env: "gnu".to_string(),
|
||||
options: super::linux_base::opts()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ pub fn target() -> Target {
|
|||
target_pointer_width: "32".to_string(),
|
||||
arch: "mips".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
target_env: "gnu".to_string(),
|
||||
|
||||
options: super::linux_base::opts()
|
||||
}
|
||||
|
|
|
@ -100,6 +100,8 @@ pub struct Target {
|
|||
pub target_pointer_width: String,
|
||||
/// OS name to use for conditional compilation.
|
||||
pub target_os: String,
|
||||
/// Environment name to use for conditional compilation.
|
||||
pub target_env: String,
|
||||
/// Architecture to use for ABI considerations. Valid options: "x86", "x86_64", "arm",
|
||||
/// "aarch64", "mips", and "powerpc". "mips" includes "mipsel".
|
||||
pub arch: String,
|
||||
|
@ -250,6 +252,8 @@ impl Target {
|
|||
target_pointer_width: get_req_field("target-pointer-width"),
|
||||
arch: get_req_field("arch"),
|
||||
target_os: get_req_field("os"),
|
||||
target_env: obj.find("env").and_then(|s| s.as_string())
|
||||
.map(|s| s.to_string()).unwrap_or(String::new()),
|
||||
options: Default::default(),
|
||||
};
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ pub fn target() -> Target {
|
|||
target_pointer_width: "32".to_string(),
|
||||
arch: "powerpc".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
target_env: "gnu".to_string(),
|
||||
options: base,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ pub fn target() -> Target {
|
|||
target_pointer_width: "64".to_string(),
|
||||
arch: "x86_64".to_string(),
|
||||
target_os: "macos".to_string(),
|
||||
target_env: "".to_string(),
|
||||
options: base,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ pub fn target() -> Target {
|
|||
target_pointer_width: "64".to_string(),
|
||||
arch: "x86_64".to_string(),
|
||||
target_os: "ios".to_string(),
|
||||
target_env: "".to_string(),
|
||||
options: opts(Arch::X86_64)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ pub fn target() -> Target {
|
|||
target_pointer_width: "64".to_string(),
|
||||
arch: "x86_64".to_string(),
|
||||
target_os: "windows".to_string(),
|
||||
target_env: "gnu".to_string(),
|
||||
options: base,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ pub fn target() -> Target {
|
|||
target_pointer_width: "64".to_string(),
|
||||
arch: "x86_64".to_string(),
|
||||
target_os: "bitrig".to_string(),
|
||||
target_env: "".to_string(),
|
||||
options: base,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ pub fn target() -> Target {
|
|||
target_pointer_width: "64".to_string(),
|
||||
arch: "x86_64".to_string(),
|
||||
target_os: "dragonfly".to_string(),
|
||||
target_env: "".to_string(),
|
||||
options: base,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ pub fn target() -> Target {
|
|||
target_pointer_width: "64".to_string(),
|
||||
arch: "x86_64".to_string(),
|
||||
target_os: "freebsd".to_string(),
|
||||
target_env: "".to_string(),
|
||||
options: base,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ pub fn target() -> Target {
|
|||
target_pointer_width: "64".to_string(),
|
||||
arch: "x86_64".to_string(),
|
||||
target_os: "linux".to_string(),
|
||||
target_env: "gnu".to_string(),
|
||||
options: base,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ pub fn target() -> Target {
|
|||
target_pointer_width: "64".to_string(),
|
||||
arch: "x86_64".to_string(),
|
||||
target_os: "openbsd".to_string(),
|
||||
target_env: "".to_string(),
|
||||
options: base,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue