Skip to content

Commit 042da7e

Browse files
committed
update docs on target specs
1 parent 37e32c3 commit 042da7e

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

crates/cargo-gpu/src/target_specs.rs

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,26 @@
1-
//! Legacy target specs are spec jsons for versions before `rustc_codegen_spirv-target-specs`
2-
//! came bundled with them. Instead, cargo gpu needs to bundle these legacy spec files. Luckily,
3-
//! they are the same for all versions, as bundling target specs with the codegen backend was
4-
//! introduced before the first target spec update.
1+
//! This module deals with target specs, which are json metadata files that need to be passed to
2+
//! rustc to add foreign targets such as `spirv_unknown_vulkan1.2`.
3+
//!
4+
//! There are 4 version ranges of `rustc_codegen_spirv` and they all need different handling of
5+
//! their target specs:
6+
//! * "ancient" versions such as 0.9.0 or earlier do not need target specs, just passing the target
7+
//! string (`spirv-unknown-vulkan1.2`) directly is sufficient. We still prep target-specs for them
8+
//! like the "legacy" variant below, spirv-builder
9+
//! [will just ignore it](https://github.com/Rust-GPU/rust-gpu/blob/369122e1703c0c32d3d46f46fa11ccf12667af03/crates/spirv-builder/src/lib.rs#L987)
10+
//! * "legacy" versions require target specs to compile, which is a requirement introduced by some
11+
//! rustc version. Back then it was decided that cargo gpu would ship them, as they'd probably
12+
//! never change, right? So now we're stuck with having to ship these "legacy" target specs with
13+
//! cargo gpu *forever*. These are the symbol `legacy_target_specs::TARGET_SPECS`, with
14+
//! `legacy_target_specs` being a **fixed** version of `rustc_codegen_spirv-target-specs`,
15+
//! which must **never** update.
16+
//! * As of [PR 256](https://github.com/Rust-GPU/rust-gpu/pull/256), `rustc_codegen_spirv` now has
17+
//! a direct dependency on `rustc_codegen_spirv-target-specs`, allowing cargo gpu to pull the
18+
//! required target specs directly from that dependency. At this point, the target specs are
19+
//! still the same as the legacy target specs.
20+
//! * The [edition 2024 PR](https://github.com/Rust-GPU/rust-gpu/pull/249) must update the
21+
//! target specs to comply with newly added validation within rustc. This is why the new system
22+
//! was implemented, so we can support both old and new target specs without having to worry
23+
//! which version of cargo gpu you are using. It'll "just work".
524
625
use crate::cache_dir;
726
use crate::spirv_source::{FindPackage as _, SpirvSource};

0 commit comments

Comments
 (0)