about summary refs log tree commit diff
path: root/src/build_helper
diff options
context:
space:
mode:
authorJieyou Xu <jieyouxu@outlook.com>2025-06-10 22:10:10 +0800
committerJieyou Xu <jieyouxu@outlook.com>2025-06-10 22:10:10 +0800
commit8ef8062d65055f2b54bd030487ae0e3388aa827a (patch)
treea64ad7f3c994d9a242be6d0b8295c39da93f3453 /src/build_helper
parent7c10378e1fee5ddc6573b916aeb884ab10e0de17 (diff)
downloadrust-8ef8062d65055f2b54bd030487ae0e3388aa827a.tar.gz
rust-8ef8062d65055f2b54bd030487ae0e3388aa827a.zip
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.
Diffstat (limited to 'src/build_helper')
-rw-r--r--src/build_helper/src/lib.rs1
-rw-r--r--src/build_helper/src/targets.rs11
2 files changed, 12 insertions, 0 deletions
diff --git a/src/build_helper/src/lib.rs b/src/build_helper/src/lib.rs
index 1f5cf723641..05de8fd2d42 100644
--- a/src/build_helper/src/lib.rs
+++ b/src/build_helper/src/lib.rs
@@ -6,6 +6,7 @@ pub mod fs;
 pub mod git;
 pub mod metrics;
 pub mod stage0_parser;
+pub mod targets;
 pub mod util;
 
 /// The default set of crates for opt-dist to collect LLVM profiles.
diff --git a/src/build_helper/src/targets.rs b/src/build_helper/src/targets.rs
new file mode 100644
index 00000000000..cccc413368b
--- /dev/null
+++ b/src/build_helper/src/targets.rs
@@ -0,0 +1,11 @@
+// FIXME(#142296): this hack is because there is no reliable way (yet) to determine whether a given
+// target supports std. In the long-term, we should try to implement a way to *reliably* determine
+// target (std) metadata.
+//
+// NOTE: this is pulled out to `build_helpers` to share this hack between `bootstrap` and
+// `compiletest`.
+pub fn target_supports_std(target_tuple: &str) -> bool {
+    !(target_tuple.contains("-none")
+        || target_tuple.contains("nvptx")
+        || target_tuple.contains("switch"))
+}