spirv: drive capability and extension emission from target features

- Emitting `OpCapability` and `OpExtension` from assembly is no longer allowed (tbh it never was because we silently ignored them).
  They now `fail` with a message pointing users at `-mcpu`.

- `tools/gen_spirv_spec.zig` now also emits `Extension` and the `Capability.dependencies()`.
  Also To keep the feature set a reasonable size, the generator filters to an allowlist of `KHR` and `EXT` entries.
  We can decide which vendors to allow later if a use-case is found.

- `tools/update_cpu_features.zig` now uses the generated `spec.zig` and emits a  feature for every
  capability and extension, with the capability's `.deps` populated from `Capability.dependencies()`.

- `Module.finalize`, `Module.entryPoints`, `Module.addCapability`, `Module.addExtension`
  and `sections.capabilities`/`sections.extensions` are deleted.

- Linker now verifies that an `.spv` object declares the `Linkage` capability
This commit is contained in:
Ali Cheraghi authored and Ali Cheraghi committed 2026-06-20 09:38:20 +02:00
1 parent f4462c0cd7
commit 3a48f4bb40
9 files changed
+4472 -1511

No files matched your search

+20
View File
@@ -70,6 +70,23 @@ pub fn build(b: *std.Build) !void {
b.getInstallStep().dependOn(&install_std_docs.step);
}
const update_cpu_features = b.addExecutable(.{
.name = "update-cpu-features",
.root_module = b.createModule(.{
.root_source_file = b.path("tools/update_cpu_features.zig"),
.target = b.graph.host,
.imports = &.{.{
.name = "spirv_spec",
.module = b.createModule(.{
.root_source_file = b.path("src/codegen/spirv/spec.zig"),
.target = b.graph.host,
}),
}},
}),
});
const run_update_cpu_features = b.addRunArtifact(update_cpu_features);
run_update_cpu_features.addPassthruArgs();
if (flat) {
b.installFile("LICENSE", "LICENSE");
b.installFile("README.md", "README.md");
@@ -85,6 +102,9 @@ pub fn build(b: *std.Build) !void {
docs_step.dependOn(langref_step);
docs_step.dependOn(std_docs_step);
const update_cpu_features_step = b.step("update-cpu-features", "Update CPU Features");
update_cpu_features_step.dependOn(&run_update_cpu_features.step);
const no_matrix = b.option(bool, "no-matrix", "Limit test matrix to exactly one target configuration") orelse false;
const fuzz_only = b.option(bool, "fuzz-only", "Limit test matrix to one target suitable for fuzzing") orelse false;
const skip_debug = b.option(bool, "skip-debug", "Main test suite skips debug builds") orelse false;