Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🦃 Use sccache in CI with GHA storage, mac & wasi included #127376

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
I can haz sccache for WASI CI?
  • Loading branch information
gpshead committed Nov 28, 2024
commit 21af49bbc79121cf09b36495fb96047c035a966e
10 changes: 3 additions & 7 deletions .github/workflows/reusable-wasi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
WASI_SDK_PATH: /opt/wasi-sdk
CROSS_BUILD_PYTHON: cross-build/build
CROSS_BUILD_WASI: cross-build/wasm32-wasip1
SCCACHE_GHA_ENABLED: "true"
steps:
- uses: actions/checkout@v4
# No problem resolver registered as one doesn't currently exist for Clang.
Expand All @@ -37,13 +38,8 @@ jobs:
mkdir ${{ env.WASI_SDK_PATH }} && \
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 | \
tar --strip-components 1 --directory ${{ env.WASI_SDK_PATH }} --extract --gunzip
- name: "Configure ccache action"
uses: hendrikmuhs/ccache-action@v1.2
with:
save: ${{ github.event_name == 'push' }}
max-size: "200M"
- name: "Add ccache to PATH"
run: echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV"
- name: Start sccache-cache
uses: mozilla-actions/sccache-action@v0.0.6
- name: "Install Python"
uses: actions/setup-python@v5
with:
Expand Down
13 changes: 12 additions & 1 deletion Tools/wasm/wasi.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,23 @@ def wasi_sdk_env(context):
env = {"CC": "clang", "CPP": "clang-cpp", "CXX": "clang++",
"AR": "llvm-ar", "RANLIB": "ranlib"}

# sccache available? wire it up!
# used in GHA CI via .github/workflows/reusable-wasi.yaml
if subprocess.call(["sccache", "--version"], stderr=subprocess.DEVNULL) == 0:
env["CC"] = f'sccache {env["CC"]}'
env["CPP"] = f'sccache {env["CPP"]}'
env["CXX"] = f'sccache {env["CXX"]}'

for env_var, binary_name in list(env.items()):
env[env_var] = os.fsdecode(wasi_sdk_path / "bin" / binary_name)

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

env["PKG_CONFIG_PATH"] = ""
env["PKG_CONFIG_LIBDIR"] = os.pathsep.join(
Expand Down
Loading