Skip to content

Commit af68cdf

Browse files
committed
rustc: Add target_vendor for target triples
This adds a new target property, `target_vendor` which can be used as a matcher for conditional compilation. The vendor is part of the autoconf target triple: <arch><sub>-<vendor>-<os>-<env> The default value for `target_vendor` is "unknown". Matching against the `target_vendor` with `#[cfg]` is currently feature gated as `cfg_target_vendor`.
1 parent afae2ff commit af68cdf

36 files changed

+95
-3
lines changed

src/doc/reference.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2092,6 +2092,8 @@ The following configurations must be defined by the implementation:
20922092
* `target_pointer_width = "..."` - Target pointer width in bits. This is set
20932093
to `"32"` for targets with 32-bit pointers, and likewise set to `"64"` for
20942094
64-bit pointers.
2095+
* `target_vendor = "..."` - Vendor of the target, for example `apple`, `pc`, or
2096+
simply `"unknown"`.
20952097
* `test` - Enabled when compiling the test harness (using the `--test` flag).
20962098
* `unix` - See `target_family`.
20972099
* `windows` - See `target_family`.
@@ -2268,7 +2270,7 @@ The currently implemented features of the reference compiler are:
22682270
* `advanced_slice_patterns` - See the [match expressions](#match-expressions)
22692271
section for discussion; the exact semantics of
22702272
slice patterns are subject to change, so some types
2271-
are still unstable.
2273+
are still unstable.
22722274

22732275
* `slice_patterns` - OK, actually, slice patterns are just scary and
22742276
completely unstable.
@@ -2289,6 +2291,9 @@ The currently implemented features of the reference compiler are:
22892291
* `box_syntax` - Allows use of `box` expressions, the exact semantics of which
22902292
is subject to change.
22912293

2294+
* `cfg_target_vendor` - Allows conditional compilation using the `target_vendor`
2295+
matcher which is subject to change.
2296+
22922297
* `concat_idents` - Allows use of the `concat_idents` macro, which is in many
22932298
ways insufficient for concatenating identifiers, and may be
22942299
removed entirely for something more wholesome.

src/librustc/session/config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,7 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
617617
let wordsz = &sess.target.target.target_pointer_width;
618618
let os = &sess.target.target.target_os;
619619
let env = &sess.target.target.target_env;
620+
let vendor = &sess.target.target.target_vendor;
620621

621622
let fam = match sess.target.target.options.is_like_windows {
622623
true => InternedString::new("windows"),
@@ -632,6 +633,7 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
632633
mk(InternedString::new("target_endian"), intern(end)),
633634
mk(InternedString::new("target_pointer_width"), intern(wordsz)),
634635
mk(InternedString::new("target_env"), intern(env)),
636+
mk(InternedString::new("target_vendor"), intern(vendor)),
635637
];
636638
if sess.opts.debug_assertions {
637639
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
@@ -19,6 +19,7 @@ pub fn target() -> Target {
1919
arch: "aarch64".to_string(),
2020
target_os: "ios".to_string(),
2121
target_env: "".to_string(),
22+
target_vendor: "apple".to_string(),
2223
options: TargetOptions {
2324
features: "+neon,+fp-armv8,+cyclone".to_string(),
2425
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
@@ -18,6 +18,7 @@ pub fn target() -> Target {
1818
arch: "aarch64".to_string(),
1919
target_os: "android".to_string(),
2020
target_env: "".to_string(),
21+
target_vendor: "linux".to_string(),
2122
options: super::android_base::opts(),
2223
}
2324
}

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
target_env: "gnu".to_string(),
2020
arch: "aarch64".to_string(),
2121
target_os: "linux".to_string(),
22+
target_vendor: "unknown".to_string(),
2223
options: base,
2324
}
2425
}

src/librustc_back/target/arm_linux_androideabi.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub fn target() -> Target {
2121
arch: "arm".to_string(),
2222
target_os: "android".to_string(),
2323
target_env: "gnu".to_string(),
24+
target_vendor: "linux".to_string(),
2425
options: base,
2526
}
2627
}

src/librustc_back/target/arm_unknown_linux_gnueabi.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub fn target() -> Target {
1919
arch: "arm".to_string(),
2020
target_os: "linux".to_string(),
2121
target_env: "gnueabi".to_string(),
22+
target_vendor: "unknown".to_string(),
2223

2324
options: TargetOptions {
2425
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
@@ -19,6 +19,7 @@ pub fn target() -> Target {
1919
arch: "arm".to_string(),
2020
target_os: "linux".to_string(),
2121
target_env: "gnueabihf".to_string(),
22+
target_vendor: "unknown".to_string(),
2223

2324
options: TargetOptions {
2425
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
arch: "arm".to_string(),
2020
target_os: "ios".to_string(),
2121
target_env: "".to_string(),
22+
target_vendor: "apple".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
arch: "arm".to_string(),
2020
target_os: "ios".to_string(),
2121
target_env: "".to_string(),
22+
target_vendor: "apple".to_string(),
2223
options: TargetOptions {
2324
features: "+v7,+vfp4,+neon".to_string(),
2425
.. opts(Arch::Armv7s)

0 commit comments

Comments
 (0)