Skip to content

Commit 21af49b

Browse files
committed
I can haz sccache for WASI CI?
1 parent 5a9c2e4 commit 21af49b

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

.github/workflows/reusable-wasi.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
WASI_SDK_PATH: /opt/wasi-sdk
1919
CROSS_BUILD_PYTHON: cross-build/build
2020
CROSS_BUILD_WASI: cross-build/wasm32-wasip1
21+
SCCACHE_GHA_ENABLED: "true"
2122
steps:
2223
- uses: actions/checkout@v4
2324
# No problem resolver registered as one doesn't currently exist for Clang.
@@ -37,13 +38,8 @@ jobs:
3738
mkdir ${{ env.WASI_SDK_PATH }} && \
3839
curl -s -S --location https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${{ env.WASI_SDK_VERSION }}/wasi-sdk-${{ env.WASI_SDK_VERSION }}.0-x86_64-linux.tar.gz | \
3940
tar --strip-components 1 --directory ${{ env.WASI_SDK_PATH }} --extract --gunzip
40-
- name: "Configure ccache action"
41-
uses: hendrikmuhs/[email protected]
42-
with:
43-
save: ${{ github.event_name == 'push' }}
44-
max-size: "200M"
45-
- name: "Add ccache to PATH"
46-
run: echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV"
41+
- name: Start sccache-cache
42+
uses: mozilla-actions/[email protected]
4743
- name: "Install Python"
4844
uses: actions/setup-python@v5
4945
with:

Tools/wasm/wasi.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,23 @@ def wasi_sdk_env(context):
173173
env = {"CC": "clang", "CPP": "clang-cpp", "CXX": "clang++",
174174
"AR": "llvm-ar", "RANLIB": "ranlib"}
175175

176+
# sccache available? wire it up!
177+
# used in GHA CI via .github/workflows/reusable-wasi.yaml
178+
if subprocess.call(["sccache", "--version"], stderr=subprocess.DEVNULL) == 0:
179+
env["CC"] = f'sccache {env["CC"]}'
180+
env["CPP"] = f'sccache {env["CPP"]}'
181+
env["CXX"] = f'sccache {env["CXX"]}'
182+
176183
for env_var, binary_name in list(env.items()):
177184
env[env_var] = os.fsdecode(wasi_sdk_path / "bin" / binary_name)
178185

186+
compiler_env_names = ("CC", "CPP", "CXX")
179187
if wasi_sdk_path != pathlib.Path("/opt/wasi-sdk"):
180-
for compiler in ["CC", "CPP", "CXX"]:
188+
for compiler in compiler_env_names:
181189
env[compiler] += f" --sysroot={sysroot}"
190+
if subprocess.call(("sccache", "--version"), stderr=subprocess.DEVNULL) == 0:
191+
for compiler in compiler_env_names:
192+
env[compiler] = 'sccache ' + env[compiler]
182193

183194
env["PKG_CONFIG_PATH"] = ""
184195
env["PKG_CONFIG_LIBDIR"] = os.pathsep.join(

0 commit comments

Comments
 (0)