Skip to content

Commit ba2380d

Browse files
committed
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.
1 parent 681fc82 commit ba2380d

26 files changed

+31
-2
lines changed

src/librustc/session/config.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,7 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
621621
let arch = &sess.target.target.arch;
622622
let wordsz = &sess.target.target.target_pointer_width;
623623
let os = &sess.target.target.target_os;
624+
let env = &sess.target.target.target_env;
624625

625626
let fam = match sess.target.target.options.is_like_windows {
626627
true => InternedString::new("windows"),
@@ -634,8 +635,8 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
634635
mk(InternedString::new("target_family"), fam),
635636
mk(InternedString::new("target_arch"), intern(arch)),
636637
mk(InternedString::new("target_endian"), intern(end)),
637-
mk(InternedString::new("target_pointer_width"),
638-
intern(wordsz))
638+
mk(InternedString::new("target_pointer_width"), intern(wordsz)),
639+
mk(InternedString::new("target_env"), intern(env)),
639640
];
640641
if sess.opts.debug_assertions {
641642
ret.push(attr::mk_word_item(InternedString::new("debug_assertions")));

src/librustc_back/target/aarch64_apple_ios.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub fn target() -> Target {
2222
target_pointer_width: "64".to_string(),
2323
arch: "aarch64".to_string(),
2424
target_os: "ios".to_string(),
25+
target_env: "".to_string(),
2526
options: TargetOptions {
2627
features: "+neon,+fp-armv8,+cyclone".to_string(),
2728
eliminate_frame_pointer: false,

src/librustc_back/target/aarch64_linux_android.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pub fn target() -> Target {
2424
target_pointer_width: "64".to_string(),
2525
arch: "aarch64".to_string(),
2626
target_os: "android".to_string(),
27+
target_env: "".to_string(),
2728
options: base,
2829
}
2930
}

src/librustc_back/target/aarch64_unknown_linux_gnu.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub fn target() -> Target {
1919
llvm_target: "aarch64-unknown-linux-gnu".to_string(),
2020
target_endian: "little".to_string(),
2121
target_pointer_width: "64".to_string(),
22+
target_env: "gnu".to_string(),
2223
arch: "aarch64".to_string(),
2324
target_os: "linux".to_string(),
2425
options: base,

src/librustc_back/target/arm_linux_androideabi.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ pub fn target() -> Target {
3131
target_pointer_width: "32".to_string(),
3232
arch: "arm".to_string(),
3333
target_os: "android".to_string(),
34+
target_env: "gnu".to_string(),
3435
options: base,
3536
}
3637
}

src/librustc_back/target/arm_unknown_linux_gnueabi.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub fn target() -> Target {
2323
target_pointer_width: "32".to_string(),
2424
arch: "arm".to_string(),
2525
target_os: "linux".to_string(),
26+
target_env: "gnueabi".to_string(),
2627

2728
options: TargetOptions {
2829
features: "+v6".to_string(),

src/librustc_back/target/arm_unknown_linux_gnueabihf.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub fn target() -> Target {
2323
target_pointer_width: "32".to_string(),
2424
arch: "arm".to_string(),
2525
target_os: "linux".to_string(),
26+
target_env: "gnueabihf".to_string(),
2627

2728
options: TargetOptions {
2829
features: "+v6,+vfp2".to_string(),

src/librustc_back/target/armv7_apple_ios.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub fn target() -> Target {
1919
target_pointer_width: "32".to_string(),
2020
arch: "arm".to_string(),
2121
target_os: "ios".to_string(),
22+
target_env: "".to_string(),
2223
options: TargetOptions {
2324
features: "+v7,+vfp3,+neon".to_string(),
2425
.. opts(Arch::Armv7)

src/librustc_back/target/armv7s_apple_ios.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub fn target() -> Target {
1919
target_pointer_width: "32".to_string(),
2020
arch: "arm".to_string(),
2121
target_os: "ios".to_string(),
22+
target_env: "".to_string(),
2223
options: TargetOptions {
2324
features: "+v7,+vfp4,+neon".to_string(),
2425
.. opts(Arch::Armv7s)

src/librustc_back/target/i386_apple_ios.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub fn target() -> Target {
2323
target_pointer_width: "32".to_string(),
2424
arch: "x86".to_string(),
2525
target_os: "ios".to_string(),
26+
target_env: "".to_string(),
2627
options: opts(Arch::I386)
2728
}
2829
}

0 commit comments

Comments
 (0)