Skip to content

Commit

Permalink
Merge pull request #2 from bbutkovic/sccache
Browse files Browse the repository at this point in the history
Implement sccache in CI
  • Loading branch information
bbutkovic authored Mar 21, 2023
2 parents 0d7262e + b871fb4 commit e5d1448
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
13 changes: 12 additions & 1 deletion .github/workflows/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,15 @@ env:
CARGO_TERM_COLOR: always
jobs:
build:
env:
SCCACHE_GHA_ENABLED: "true"
runs-on: ubuntu-latest
steps:
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.2
with:
version: "v0.4.0"

- uses: actions/checkout@v3
with:
submodules: recursive
Expand All @@ -27,7 +34,7 @@ jobs:
echo "WASI_SDK_PATH=/opt/wasi-sdk" >> $GITHUB_ENV
- name: Build runtime
run: make all WASI_SDK_PATH=$WASI_SDK_PATH numjobs=3
run: make all use_sccache=true WASI_SDK_PATH=$WASI_SDK_PATH numjobs=3

- name: Upload runtime
if: startsWith(github.ref, 'refs/tags/')
Expand All @@ -38,6 +45,10 @@ jobs:
runtime.wasm
fastly-php-runtime.stubs.php
- name: Run sccache stat for check
shell: bash
run: ${SCCACHE_PATH} --show-stats

release:
if: startsWith(github.ref, 'refs/tags/')
needs: build
Expand Down
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.SUFFIXES:

debug ?=
use_sccache ?=

ifdef debug
release :=
Expand Down Expand Up @@ -54,6 +55,15 @@ CFLAGS :=\
-static \
--sysroot=${PHP_WASI_SDK_SYSROOT}

ifdef use_sccache
RUSTC_WRAPPER :=sccache
SCCACHE_CLANG :=${CC}
CC := $(abspath ./util/sccache-clang)
else
SCCACHE_CLANG :=
RUSTC_WRAPPER :=
endif

ifdef debug
CFLAGS := $(CFLAGS) -g
endif
Expand Down Expand Up @@ -88,6 +98,7 @@ runtime.wasm: export PHP_CONFIGURE_FROM_ENV :=true
runtime.wasm: export PHP_PHP_API :=20210902
runtime.wasm: export PHP_DEBUG_BUILD :=no
runtime.wasm: export PHP_THREAD_SAFETY :=disabled
runtime.wasm: export RUSTC_WRAPPER :=${RUSTC_WRAPPER}
runtime.wasm: deps/php/libs/libphp.a
cargo build $(release) && cp target/wasm32-wasi/$(target)/fastly-php-runtime.wasm runtime.wasm

Expand All @@ -103,6 +114,7 @@ deps/php/Makefile: export CC := ${CC}
deps/php/Makefile: export RANLIB := ${RANLIB}
deps/php/Makefile: export AR := ${AR}
deps/php/Makefile: export NM := ${NM}
deps/php/Makefile: export SCCACHE_CLANG := ${SCCACHE_CLANG}
deps/php/Makefile: | deps/php
cd deps/php && \
./buildconf --force && \
Expand Down
3 changes: 3 additions & 0 deletions util/sccache-clang
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

sccache /opt/wasi-sdk/bin/clang "$@"

0 comments on commit e5d1448

Please sign in to comment.