Skip to content

Commit e96418f

Browse files
authored
Update spirv-tools (#1127)
* Update to spirv-tools 0.10.0 * Use pre-built binaries from spirv-tools-rs * Oops * Target != host for android * Use non-ancient ubuntu * Oh right * Update expected output * Address feedback * Oops * Cancel actions when new commits are pushed * Update CHANGELOG * Fixup
1 parent 3bd121e commit e96418f

File tree

9 files changed

+153
-54
lines changed

9 files changed

+153
-54
lines changed
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# We make this tool its own workspace as it doesn't share dependencies with the
2+
# rest of the workspace, and it shouldn't be built normally, only as a helper
3+
# for CI so it would just slow down local development for no reason
4+
[workspace]
5+
6+
[package]
7+
name = "install-spirv-tools"
8+
edition = "2021"
9+
version = "0.1.0"
10+
publish = false
11+
12+
[dependencies]
13+
tar = "0.4"
14+
zstd = "0.13"
+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
use std::{env, fs, io::Write as _, process::Command};
2+
3+
struct Group(bool);
4+
5+
impl Group {
6+
fn new(group: &str) -> Self {
7+
let is_gh = env::var_os("CI").is_some();
8+
if is_gh {
9+
println!("::group::{group}");
10+
} else {
11+
println!("{group}");
12+
}
13+
Self(is_gh)
14+
}
15+
}
16+
17+
impl Drop for Group {
18+
fn drop(&mut self) {
19+
if self.0 {
20+
println!("::endgroup::");
21+
}
22+
}
23+
}
24+
25+
fn main() {
26+
let (triple, release, td) = {
27+
let mut args = env::args().skip(1);
28+
let triple = args.next().expect("expected target triple");
29+
let release = args.next().expect("expected release tag name");
30+
let td = args.next().expect("expected output directory");
31+
32+
(triple, release, td)
33+
};
34+
35+
let compressed = {
36+
let _s = Group::new(&format!("downloading {triple} tarball"));
37+
let mut cmd = Command::new("curl");
38+
cmd.args(["-f", "-L"])
39+
.arg(format!("https://github.com/EmbarkStudios/spirv-tools-rs/releases/download/{release}/{triple}.tar.zst"))
40+
.stdout(std::process::Stdio::piped());
41+
42+
let output = cmd
43+
.spawn()
44+
.expect("curl is not installed")
45+
.wait_with_output()
46+
.expect("failed to wait for curl");
47+
48+
if !output.status.success() {
49+
panic!("failed to download tarball via curl");
50+
}
51+
52+
output.stdout
53+
};
54+
55+
let decoded = {
56+
let _s = Group::new(&format!("decompressing {triple} tarball"));
57+
// All archives are <8MiB decompressed
58+
let uncompressed = Vec::with_capacity(8 * 1024 * 1024);
59+
let mut decoder =
60+
zstd::stream::write::Decoder::new(uncompressed).expect("failed to create decoder");
61+
decoder
62+
.write_all(&compressed)
63+
.expect("failed to decompress");
64+
decoder.flush().expect("failed to flush decompress stream");
65+
66+
decoder.into_inner()
67+
};
68+
69+
{
70+
let _s = Group::new(&format!("untarring {triple} tarball"));
71+
{
72+
let mut tar = tar::Archive::new(std::io::Cursor::new(&decoded));
73+
74+
if tar
75+
.entries()
76+
.expect("failed to retrieve entries")
77+
.filter(|ent| ent.is_ok())
78+
.count()
79+
== 0
80+
{
81+
panic!("no valid entries found in tarball");
82+
}
83+
}
84+
85+
let mut tar = tar::Archive::new(std::io::Cursor::new(decoded));
86+
tar.unpack(&td).expect("failed to untar files");
87+
}
88+
89+
if let Some(gh_path) = env::var_os("GITHUB_PATH") {
90+
let _s = Group::new(&format!("adding '{td}' to $GITHUB_PATH ({gh_path:?})"));
91+
92+
// emulate >> for both empty and non-empty files
93+
let has_contents = fs::metadata(&gh_path).map_or(false, |md| md.len() > 0);
94+
95+
let mut file = fs::OpenOptions::new()
96+
.append(true)
97+
.open(gh_path)
98+
.expect("failed to open $GITHUB_PATH");
99+
100+
let td = if has_contents {
101+
format!("\n{td}\n")
102+
} else {
103+
td
104+
};
105+
106+
file.write_all(td.as_bytes())
107+
.expect("failed to write to $GITHUB_PATH");
108+
}
109+
}

.github/workflows/ci.yaml

+19-47
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ on:
66

77
name: CI
88

9+
# Cancel PR actions on new commits
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
12+
cancel-in-progress: true
13+
914
jobs:
1015
test:
1116
name: Test
@@ -20,52 +25,22 @@ jobs:
2025
target: x86_64-apple-darwin
2126
- os: ubuntu-20.04-16core
2227
target: aarch64-linux-android
28+
host: x86_64-unknown-linux-gnu
2329
runs-on: ${{ matrix.os }}
2430
env:
25-
# Get platform-specific download links from https://github.com/KhronosGroup/SPIRV-Tools/blob/master/docs/downloads.md
26-
# which will point to the `spirv-tools` Google Cloud Storage Bucket - if
27-
# you need to manually look around, you can search for `spirv_tools_version`
28-
# (which should be in the `YYYYMMDD` format and appear in paths) in these
29-
# listings (NB: they're limited to 1000 results and may need adjustment):
30-
# https://storage.googleapis.com/spirv-tools/?list-type=2&start-after=artifacts/prod/graphics_shader_compiler/spirv-tools/linux-clang-release/continuous/1800
31-
# https://storage.googleapis.com/spirv-tools/?list-type=2&start-after=artifacts/prod/graphics_shader_compiler/spirv-tools/macos-clang-release/continuous/1800
32-
# https://storage.googleapis.com/spirv-tools/?list-type=2&start-after=artifacts/prod/graphics_shader_compiler/spirv-tools/windows-msvc-2017-release/continuous/1800
33-
spirv_tools_version: "20221024"
34-
# NOTE(eddyb) do not forget to update both the above date and below links!
35-
# FIXME(eddyb) automate this somewhat by taking advantage of the bucket APIs,
36-
# and look for the first build with the date in `spirv_tools_version`.
37-
spirv_tools_linux_url: "https://storage.googleapis.com/spirv-tools/artifacts/prod/graphics_shader_compiler/spirv-tools/linux-clang-release/continuous/1863/20221024-094528/install.tgz"
38-
spirv_tools_macos_url: "https://storage.googleapis.com/spirv-tools/artifacts/prod/graphics_shader_compiler/spirv-tools/macos-clang-release/continuous/1875/20221024-094531/install.tgz"
39-
spirv_tools_windows_url: "https://storage.googleapis.com/spirv-tools/artifacts/prod/graphics_shader_compiler/spirv-tools/windows-msvc-2017-release/continuous/1851/20221024-094908/install.zip"
4031
RUSTUP_UNPACK_RAM: "26214400"
4132
RUSTUP_IO_THREADS: "1"
4233
steps:
43-
- uses: actions/checkout@v2
44-
- if: ${{ runner.os == 'Linux' }}
45-
name: Linux - Install native dependencies and spirv-tools
46-
run: |
47-
sudo apt install libwayland-cursor0 libxkbcommon-dev libwayland-dev
48-
mkdir "${HOME}/spirv-tools"
49-
curl -fL "$spirv_tools_linux_url" | tar -xz -C "${HOME}/spirv-tools"
50-
echo "${HOME}/spirv-tools/install/bin" >> $GITHUB_PATH
51-
- if: ${{ runner.os == 'macOS' }}
52-
name: Mac - Install spirv-tools
53-
# FIXME(eddyb) deduplicate with Linux (and maybe even Windows?).
54-
run: |
55-
mkdir "${HOME}/spirv-tools"
56-
curl -fL "$spirv_tools_macos_url" | tar -xz -C "${HOME}/spirv-tools"
57-
echo "${HOME}/spirv-tools/install/bin" >> $GITHUB_PATH
58-
- if: ${{ runner.os == 'Windows' }}
59-
name: Windows - Install spirv-tools
34+
- uses: actions/checkout@v4
35+
# Install the spirv-tools binaries from tarballs hosted on each release
36+
# of spirv-tools. This downloads the tarball, decompresses it, unpacks
37+
# the binaries to the specified path, and adds them to PATH
38+
- name: Install spirv-tools binaries
6039
shell: bash
61-
run: |
62-
tmparch=$(mktemp)
63-
mkdir "${HOME}/spirv-tools"
64-
curl -fL -o "$tmparch" "$spirv_tools_windows_url"
65-
unzip "$tmparch" -d "${HOME}/spirv-tools"
66-
- if: ${{ runner.os == 'Windows' }}
67-
# Runs separately to add spir-v tools to Powershell's Path.
68-
run: echo "$HOME/spirv-tools/install/bin" >> $env:GITHUB_PATH
40+
run: cargo run --manifest-path .github/install-spirv-tools/Cargo.toml -- ${{matrix.host || matrix.target}} 0.10.0 "${{github.workspace}}/bin"
41+
- if: ${{ runner.os == 'Linux' }}
42+
name: Linux - Install native dependencies
43+
run: sudo apt install libwayland-cursor0 libxkbcommon-dev libwayland-dev
6944
# cargo version is a random command that forces the installation of rust-toolchain
7045
- name: install rust-toolchain
7146
run: cargo version
@@ -142,16 +117,13 @@ jobs:
142117
# Note that we are explicitly NOT checking out submodules, to validate
143118
# that we haven't accidentally enabled spirv-tools native compilation
144119
# and regressed CI times
145-
- uses: actions/checkout@v2
120+
- uses: actions/checkout@v4
146121
with:
147122
submodules: "false"
148123
- name: Install native dependencies
149124
run: sudo apt install libwayland-cursor0 libxkbcommon-dev libwayland-dev
150125
- name: Install spirv-tools
151-
run: |
152-
mkdir "${HOME}/spirv-tools"
153-
curl -fL https://storage.googleapis.com/spirv-tools/artifacts/prod/graphics_shader_compiler/spirv-tools/linux-clang-release/continuous/1409/20210313-175801/install.tgz | tar -xz -C "${HOME}/spirv-tools"
154-
echo "${HOME}/spirv-tools/install/bin" >> $GITHUB_PATH
126+
run: cargo run --manifest-path .github/install-spirv-tools/Cargo.toml -- x86_64-unknown-linux-gnu 0.10.0 "${{github.workspace}}/bin"
155127
- name: Install rustup components
156128
run: rustup component add rustfmt clippy
157129
# cargo version is a random command that forces the installation of rust-toolchain
@@ -173,7 +145,7 @@ jobs:
173145
run: .github/workflows/lint.sh
174146

175147
cargo-deny:
176-
runs-on: ubuntu-20.04
148+
runs-on: ubuntu-22.04
177149
steps:
178-
- uses: actions/checkout@v2
150+
- uses: actions/checkout@v4
179151
- uses: EmbarkStudios/cargo-deny-action@v1

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ target/
22
.vscode/
33
.vim/
44
tests/Cargo.lock
5+
.github/install-spirv-tools/Cargo.lock

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3030
## [Unreleased]
3131

3232
### Changed 🛠
33+
- [PR#1127](https://github.com/EmbarkStudios/rust-gpu/pull/1127) updated `spirv-tools` to `0.10.0`, which follows `vulkan-sdk-1.3.275`.
3334
- [PR#1101](https://github.com/EmbarkStudios/rust-gpu/pull/1101) Add `ignore` and `no_run` to documentation to make `cargo test` pass.
3435
- [PR#1112](https://github.com/EmbarkStudios/rust-gpu/pull/1112) updated wgpu and winit in example runners
3536
- [PR#1100](https://github.com/EmbarkStudios/rust-gpu/pull/1100) updated toolchain to `nightly-2023-09-30`

Cargo.lock

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@ license = "MIT OR Apache-2.0"
3131
repository = "https://github.com/EmbarkStudios/rust-gpu"
3232

3333
[workspace.dependencies]
34+
spirv-builder = { path = "./crates/spirv-builder", version = "=0.9.0", default-features = false }
3435
spirv-std = { path = "./crates/spirv-std", version = "=0.9.0" }
3536
spirv-std-types = { path = "./crates/spirv-std/shared", version = "=0.9.0" }
3637
spirv-std-macros = { path = "./crates/spirv-std/macros", version = "=0.9.0" }
37-
spirv-builder = { path = "./crates/spirv-builder", version = "=0.9.0", default-features = false }
38+
spirv-tools = { version = "0.10", default-features = false }
3839
rustc_codegen_spirv = { path = "./crates/rustc_codegen_spirv", version = "=0.9.0", default-features = false }
3940
rustc_codegen_spirv-types = { path = "./crates/rustc_codegen_spirv-types", version = "=0.9.0" }
4041

crates/rustc_codegen_spirv/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ ar = "0.9.0"
5151
either = "1.8.0"
5252
indexmap = "1.6.0"
5353
rspirv = "0.11"
54+
rustc_codegen_spirv-types.workspace = true
5455
rustc-demangle = "0.1.21"
5556
sanitize-filename = "0.4"
5657
serde = { version = "1.0", features = ["derive"] }
5758
serde_json = "1.0"
5859
smallvec = { version = "1.6.1", features = ["union"] }
59-
spirv-tools = { version = "0.9", default-features = false }
60-
rustc_codegen_spirv-types.workspace = true
6160
spirt = "0.3.0"
61+
spirv-tools.workspace = true
6262
lazy_static = "1.4.0"
6363
itertools = "0.10.5"
6464

tests/ui/lang/core/ref/member_ref_arg-broken.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ warning: `#[inline(never)]` function `member_ref_arg_broken::h` needs to be inli
33
warning: `#[inline(never)]` function `member_ref_arg_broken::h_newtyped` needs to be inlined because it has illegal argument or return types
44

55
error: error:0:0 - OpLoad Pointer <id> '$ID[%$ID]' is not a logical pointer.
6+
%39 = OpLoad %uint %38
67
|
78
= note: spirv-val failed
89
= note: module `$TEST_BUILD_DIR/lang/core/ref/member_ref_arg-broken.default`

0 commit comments

Comments
 (0)