|
5 | 5 | # This source code is licensed under the BSD-style license found in the |
6 | 6 | # LICENSE file in the root directory of this source tree. |
7 | 7 |
|
| 8 | +# Vendor Dawn (Tint) + SwiftShader for the WebGPU backend CI WITHOUT hosting a |
| 9 | +# private prebuilt: |
| 10 | +# * Dawn : Google's official nightly prebuilt, downloaded directly from |
| 11 | +# github.com/google/dawn/releases (pinned tag+rev+sha256) -- the same |
| 12 | +# "fetch upstream's published binary" pattern as setup-wgpu-native.sh. |
| 13 | +# * SwiftShader : reuse the prebuilt ALREADY on the ossci-android bucket (the one |
| 14 | +# setup-vulkan-linux-deps.sh uses). No new S3 uploads anywhere. |
| 15 | +# Dawn (Chrome's WebGPU impl; its WGSL compiler Tint is the spec reference) on |
| 16 | +# SwiftShader gives a headless, deterministic, spec-faithful CLI backend. |
| 17 | +# |
| 18 | +# Exports Dawn_DIR / VK_ICD_FILENAMES / LD_LIBRARY_PATH for the cmake build+run. |
| 19 | +# Local/rig override: set DAWN_PREBUILT_DIR=<dir containing lib64/cmake/Dawn> to |
| 20 | +# skip the Dawn download. |
8 | 21 | set -ex |
9 | 22 |
|
10 | | -# SwiftShader: software Vulkan adapter for GPU-less CI (LunarG SDK not needed). |
11 | | -install_swiftshader() { |
12 | | - _https_amazon_aws=https://ossci-android.s3.amazonaws.com |
13 | | - _swiftshader_archive=swiftshader-abe07b943-prebuilt.tar.gz |
14 | | - _swiftshader_dir=/tmp/swiftshader |
15 | | - mkdir -p $_swiftshader_dir |
| 23 | +# --- pinned versions (bump rev+sha together when upgrading Dawn) -------------- |
| 24 | +DAWN_TAG="${DAWN_TAG:-v20260423.175430}" |
| 25 | +DAWN_REV="${DAWN_REV:-31e25af254ab572c77054edec4946d2244e184dd}" |
| 26 | +DAWN_SHA256="${DAWN_SHA256:-ac76fac090162dc1ecea5ed0f28a557bb8f49efc47faab01886105ace82b7b64}" |
| 27 | +SWIFTSHADER_ARCHIVE="${SWIFTSHADER_ARCHIVE:-swiftshader-abe07b943-prebuilt.tar.gz}" |
16 | 28 |
|
17 | | - _tmp_archive="/tmp/${_swiftshader_archive}" |
| 29 | +_dawn_dir="${DAWN_PREBUILT_DIR:-/tmp/dawn-ci}" |
| 30 | +_ss_dir=/tmp/swiftshader |
18 | 31 |
|
19 | | - curl --silent --show-error --location --fail --retry 3 --retry-all-errors \ |
20 | | - --output "${_tmp_archive}" "$_https_amazon_aws/${_swiftshader_archive}" |
| 32 | +# --- toolchain prereqs -------------------------------------------------------- |
| 33 | +# Dawn dlopens the system Vulkan loader at runtime (libvulkan1). And the |
| 34 | +# ubuntu-latest prebuilt is built with a bleeding-edge GCC: it references |
| 35 | +# libstdc++ symbols newer than ubuntu-22.04's default (e.g. _M_replace_cold, |
| 36 | +# GCC 13+), so the static .a won't link against the stock runtime. Pull a current |
| 37 | +# libstdc++ from the ubuntu-toolchain-r PPA when the symbol floor isn't met. All |
| 38 | +# of this is scoped to the WebGPU CI job; newer libstdc++ is backward-compatible. |
| 39 | +if command -v apt-get >/dev/null 2>&1; then |
| 40 | + _SUDO=""; command -v sudo >/dev/null 2>&1 && _SUDO="sudo" |
| 41 | + ${_SUDO} apt-get update -y || true |
| 42 | + ${_SUDO} apt-get install -y libvulkan1 software-properties-common || true |
| 43 | + if ! strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 2>/dev/null \ |
| 44 | + | grep -q "GLIBCXX_3.4.32"; then |
| 45 | + ${_SUDO} add-apt-repository -y ppa:ubuntu-toolchain-r/test || true |
| 46 | + ${_SUDO} apt-get update -y || true |
| 47 | + ${_SUDO} apt-get install -y libstdc++6 || true # newest GCC runtime |
| 48 | + fi |
| 49 | +fi |
21 | 50 |
|
22 | | - tar -C "${_swiftshader_dir}" -xzf "${_tmp_archive}" |
| 51 | +# --- Dawn: official prebuilt from GitHub (no S3) ------------------------------ |
| 52 | +mkdir -p "${_dawn_dir}" |
| 53 | +if [[ ! -d "${_dawn_dir}/lib64/cmake/Dawn" ]]; then |
| 54 | + _dawn_tar="/tmp/Dawn-${DAWN_REV}-ubuntu-latest-Release.tar.gz" |
| 55 | + curl --silent --show-error --location --fail --retry 3 --retry-all-errors \ |
| 56 | + --output "${_dawn_tar}" \ |
| 57 | + "https://github.com/google/dawn/releases/download/${DAWN_TAG}/Dawn-${DAWN_REV}-ubuntu-latest-Release.tar.gz" |
| 58 | + echo "${DAWN_SHA256} ${_dawn_tar}" | sha256sum -c - |
| 59 | + # archive top dir is Dawn-<rev>-ubuntu-latest-Release/{lib64,include,bin} |
| 60 | + tar -C "${_dawn_dir}" --strip-components=1 -xzf "${_dawn_tar}" |
| 61 | +fi |
23 | 62 |
|
24 | | - export VK_ICD_FILENAMES="${_swiftshader_dir}/swiftshader/build/Linux/vk_swiftshader_icd.json" |
25 | | - export LD_LIBRARY_PATH="${_swiftshader_dir}/swiftshader/build/Linux/:${LD_LIBRARY_PATH}" |
26 | | - export ETVK_USING_SWIFTSHADER=1 |
27 | | -} |
| 63 | +# --- SwiftShader: reuse the existing ossci prebuilt (no new upload) ----------- |
| 64 | +if [[ ! -f "${_ss_dir}/swiftshader/build/Linux/vk_swiftshader_icd.json" ]]; then |
| 65 | + _ss_aws=https://ossci-android.s3.amazonaws.com |
| 66 | + mkdir -p "${_ss_dir}" |
| 67 | + curl --silent --show-error --location --fail --retry 3 --retry-all-errors \ |
| 68 | + --output "/tmp/${SWIFTSHADER_ARCHIVE}" "${_ss_aws}/${SWIFTSHADER_ARCHIVE}" |
| 69 | + tar -C "${_ss_dir}" -xzf "/tmp/${SWIFTSHADER_ARCHIVE}" |
| 70 | +fi |
28 | 71 |
|
29 | | -install_swiftshader |
30 | | -bash backends/webgpu/scripts/setup-wgpu-native.sh |
| 72 | +export Dawn_DIR="${_dawn_dir}/lib64/cmake/Dawn" |
| 73 | +export VK_ICD_FILENAMES="${_ss_dir}/swiftshader/build/Linux/vk_swiftshader_icd.json" |
| 74 | +export LD_LIBRARY_PATH="${_ss_dir}/swiftshader/build/Linux/:${LD_LIBRARY_PATH:-}" |
| 75 | +export WEBGPU_USING_SWIFTSHADER=1 |
0 commit comments