Skip to content

Commit 9dd737d

Browse files
committed
target-spec: add support for rust-gpu before rustc 1.85
1 parent 0b0d5d8 commit 9dd737d

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

crates/rustc_codegen_spirv-types/src/target_spec.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ use std::path::Path;
99
#[allow(non_camel_case_types)]
1010
#[derive(Copy, Clone, Debug)]
1111
pub enum TargetSpecVersion {
12+
/// Introduced in `489c3ee6fd63da3ca7cf2b15e1ee709d8e078aab` in the old v2 target spec way, later ported to here.
13+
/// remove `os: unknown`, add `crt-static-respected: true`
14+
Rustc_1_85_0,
1215
/// rustc 1.76 has been tested to correctly parse modern target spec jsons.
1316
/// Some later version requires them.
1417
/// Some earlier version fails with them (notably our 0.9.0 release).
@@ -36,7 +39,9 @@ impl TargetSpecVersion {
3639
/// Returns the version of the target spec required for a certain rustc version. May return `None` if the version
3740
/// is old enough to not need target specs.
3841
pub fn from_rustc_version(rustc_version: Version) -> Option<Self> {
39-
if rustc_version >= Version::new(1, 76, 0) {
42+
if rustc_version >= Version::new(1, 85, 0) {
43+
Some(Self::Rustc_1_85_0)
44+
} else if rustc_version >= Version::new(1, 76, 0) {
4045
Some(Self::Rustc_1_76_0)
4146
} else {
4247
None
@@ -46,15 +51,16 @@ impl TargetSpecVersion {
4651
/// format the target spec json
4752
pub fn format_spec(&self, target: &Target) -> String {
4853
let target_env = target.target_env();
49-
match self {
50-
TargetSpecVersion::Rustc_1_76_0 => {
51-
format!(
52-
r#"{{
54+
let extra = match self {
55+
TargetSpecVersion::Rustc_1_85_0 => r#""crt-static-respected": true,"#,
56+
TargetSpecVersion::Rustc_1_76_0 => r#""os": "unknown","#,
57+
};
58+
format!(
59+
r#"{{
5360
"allows-weak-linkage": false,
5461
"arch": "spirv",
5562
"crt-objects-fallback": "false",
5663
"crt-static-allows-dylibs": true,
57-
"crt-static-respected": true,
5864
"data-layout": "e-m:e-p:32:32:32-i64:64-n8:16:32:64",
5965
"dll-prefix": "",
6066
"dll-suffix": ".spv.json",
@@ -71,12 +77,11 @@ impl TargetSpecVersion {
7177
"std": null,
7278
"tier": null
7379
}},
80+
{extra}
7481
"panic-strategy": "abort",
7582
"simd-types-indirect": false,
7683
"target-pointer-width": "32"
7784
}}"#
78-
)
79-
}
80-
}
85+
)
8186
}
8287
}

0 commit comments

Comments
 (0)