|
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 a pinned upstream prebuilt" pattern used for other CI deps. |
| 13 | +# * SwiftShader : built from source at a pinned rev compatible with the Dawn |
| 14 | +# above (the ossci prebuilt is from 2020, too old for current Dawn). No S3. |
| 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 rev verified compatible with DAWN_REV (the old ossci prebuilt is |
| 28 | +# from 2020 and is incompatible with current Dawn -> no adapter / zero compute). |
| 29 | +SWIFTSHADER_REV="${SWIFTSHADER_REV:-9898204d91d6a60b6a08ad74fe4ac52a6913111b}" |
16 | 30 |
|
17 | | - _tmp_archive="/tmp/${_swiftshader_archive}" |
| 31 | +_dawn_dir="${DAWN_PREBUILT_DIR:-/tmp/dawn-ci}" |
| 32 | +_ss_dir=/tmp/swiftshader |
18 | 33 |
|
19 | | - curl --silent --show-error --location --fail --retry 3 --retry-all-errors \ |
20 | | - --output "${_tmp_archive}" "$_https_amazon_aws/${_swiftshader_archive}" |
| 34 | +# --- toolchain prereqs -------------------------------------------------------- |
| 35 | +# Dawn dlopens the system Vulkan loader at runtime (libvulkan1). And the |
| 36 | +# ubuntu-latest prebuilt is built with a bleeding-edge GCC: it references |
| 37 | +# libstdc++ symbols newer than ubuntu-22.04's default (e.g. _M_replace_cold, |
| 38 | +# GCC 13+), so the static .a won't link against the stock runtime. Pull a current |
| 39 | +# libstdc++ from the ubuntu-toolchain-r PPA when the symbol floor isn't met. All |
| 40 | +# of this is scoped to the WebGPU CI job; newer libstdc++ is backward-compatible. |
| 41 | +if command -v apt-get >/dev/null 2>&1; then |
| 42 | + _SUDO=""; command -v sudo >/dev/null 2>&1 && _SUDO="sudo" |
| 43 | + ${_SUDO} apt-get update -y || true |
| 44 | + ${_SUDO} apt-get install -y libvulkan1 software-properties-common || true |
| 45 | + if ! strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 2>/dev/null \ |
| 46 | + | grep -q "GLIBCXX_3.4.32"; then |
| 47 | + ${_SUDO} add-apt-repository -y ppa:ubuntu-toolchain-r/test || true |
| 48 | + ${_SUDO} apt-get update -y || true |
| 49 | + ${_SUDO} apt-get install -y libstdc++6 || true # newest GCC runtime |
| 50 | + fi |
| 51 | +fi |
21 | 52 |
|
22 | | - tar -C "${_swiftshader_dir}" -xzf "${_tmp_archive}" |
| 53 | +# The native binaries / pybind lib run INSIDE the CI conda env, whose libstdc++ |
| 54 | +# predates GLIBCXX_3.4.32 (the Dawn prebuilt's floor) -- the same wall ssjia hit |
| 55 | +# for the vulkan op tests. Upgrade the conda runtime libstdc++ so the loaded |
| 56 | +# libstdc++.so.6 (conda's, not the system one) satisfies Dawn at run time. |
| 57 | +if command -v conda >/dev/null 2>&1; then |
| 58 | + conda install -y -c conda-forge "libstdcxx-ng>=14" || true |
| 59 | +fi |
| 60 | + |
| 61 | +# --- Dawn: official prebuilt from GitHub (no S3) ------------------------------ |
| 62 | +mkdir -p "${_dawn_dir}" |
| 63 | +if [[ ! -d "${_dawn_dir}/lib64/cmake/Dawn" ]]; then |
| 64 | + _dawn_tar="/tmp/Dawn-${DAWN_REV}-ubuntu-latest-Release.tar.gz" |
| 65 | + curl --silent --show-error --location --fail --retry 3 --retry-all-errors \ |
| 66 | + --output "${_dawn_tar}" \ |
| 67 | + "https://github.com/google/dawn/releases/download/${DAWN_TAG}/Dawn-${DAWN_REV}-ubuntu-latest-Release.tar.gz" |
| 68 | + echo "${DAWN_SHA256} ${_dawn_tar}" | sha256sum -c - |
| 69 | + # archive top dir is Dawn-<rev>-ubuntu-latest-Release/{lib64,include,bin} |
| 70 | + tar -C "${_dawn_dir}" --strip-components=1 -xzf "${_dawn_tar}" |
| 71 | +fi |
23 | 72 |
|
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 | | -} |
| 73 | +# --- SwiftShader: build from source at a pinned rev (no S3) ------------------- |
| 74 | +# The old ossci prebuilt (swiftshader-abe07b943, 2020) is incompatible with the |
| 75 | +# current Dawn; build a matching modern SwiftShader instead. Self-contained |
| 76 | +# cmake build (vendored LLVM); the ICD lands under build/<OS>/. |
| 77 | +if [[ ! -d "${_ss_dir}/build" ]]; then |
| 78 | + if [[ ! -d "${_ss_dir}/.git" ]]; then |
| 79 | + git clone https://github.com/google/swiftshader "${_ss_dir}" |
| 80 | + fi |
| 81 | + git -C "${_ss_dir}" checkout "${SWIFTSHADER_REV}" |
| 82 | + # vk_swiftshader's deps are vendored in-tree; tolerate unreachable |
| 83 | + # disabled-feature submodules (angle, test-only) failing to fetch. |
| 84 | + git -C "${_ss_dir}" submodule update --init --recursive || true |
| 85 | + cmake -S "${_ss_dir}" -B "${_ss_dir}/build" -DCMAKE_BUILD_TYPE=Release \ |
| 86 | + -DSWIFTSHADER_BUILD_TESTS=OFF -DSWIFTSHADER_BUILD_PVR=OFF \ |
| 87 | + -DSWIFTSHADER_BUILD_BENCHMARKS=OFF |
| 88 | + cmake --build "${_ss_dir}/build" --parallel "$(nproc)" --target vk_swiftshader |
| 89 | +fi |
| 90 | +_ss_icd="$(find "${_ss_dir}/build" -name vk_swiftshader_icd.json 2>/dev/null | head -1)" |
| 91 | +[[ -n "${_ss_icd}" ]] || { echo "ERROR: SwiftShader ICD not found after build" >&2; exit 1; } |
28 | 92 |
|
29 | | -install_swiftshader |
30 | | -bash backends/webgpu/scripts/setup-wgpu-native.sh |
| 93 | +_ss_libdir="$(dirname "${_ss_icd}")" |
| 94 | +export Dawn_DIR="${_dawn_dir}/lib64/cmake/Dawn" |
| 95 | +export VK_ICD_FILENAMES="${_ss_icd}" |
| 96 | +export LD_LIBRARY_PATH="${_ss_libdir}:${LD_LIBRARY_PATH:-}" |
| 97 | +export WEBGPU_USING_SWIFTSHADER=1 |
0 commit comments