Skip to content

Commit 8ef8062

Browse files
committed
Extract target no-std hack to build_helpers
To centralize this hack in one place with a backlink to the issue tracking this hack, as this logic is also needed by compiletest to implement a `//@ needs-target-std` directive.
1 parent 7c10378 commit 8ef8062

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

src/bootstrap/src/core/config/toml/target.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pub struct Target {
8484
impl Target {
8585
pub fn from_triple(triple: &str) -> Self {
8686
let mut target: Self = Default::default();
87-
if triple.contains("-none") || triple.contains("nvptx") || triple.contains("switch") {
87+
if !build_helper::targets::target_supports_std(triple) {
8888
target.no_std = true;
8989
}
9090
if triple.contains("emscripten") {

src/build_helper/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pub mod fs;
66
pub mod git;
77
pub mod metrics;
88
pub mod stage0_parser;
9+
pub mod targets;
910
pub mod util;
1011

1112
/// The default set of crates for opt-dist to collect LLVM profiles.

src/build_helper/src/targets.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// FIXME(#142296): this hack is because there is no reliable way (yet) to determine whether a given
2+
// target supports std. In the long-term, we should try to implement a way to *reliably* determine
3+
// target (std) metadata.
4+
//
5+
// NOTE: this is pulled out to `build_helpers` to share this hack between `bootstrap` and
6+
// `compiletest`.
7+
pub fn target_supports_std(target_tuple: &str) -> bool {
8+
!(target_tuple.contains("-none")
9+
|| target_tuple.contains("nvptx")
10+
|| target_tuple.contains("switch"))
11+
}

0 commit comments

Comments
 (0)