Skip to content

Commit e0a8f22

Browse files
committed
rustc_target: Make sure that in-tree targets follow conventions for os and vendor values
1 parent 1def24c commit e0a8f22

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

compiler/rustc_target/src/spec/tests/tests_impl.rs

+13
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,18 @@ impl Target {
3636
&& self.post_link_objects_fallback.is_empty())
3737
|| self.crt_objects_fallback.is_some()
3838
);
39+
// Keep the default "unknown" vendor instead.
40+
assert_ne!(self.vendor, "");
41+
if !self.can_use_os_unknown() {
42+
// Keep the default "none" for bare metal targets instead.
43+
assert_ne!(self.os, "unknown");
44+
}
45+
}
46+
47+
// Add your target to the whitelist if it has `std` library
48+
// and you certainly want "unknown" for the OS name.
49+
fn can_use_os_unknown(&self) -> bool {
50+
self.llvm_target == "wasm32-unknown-unknown"
51+
|| (self.env == "sgx" && self.vendor == "fortanix")
3952
}
4053
}

0 commit comments

Comments
 (0)