diff --git a/.github/workflows/runtime.yml b/.github/workflows/runtime.yml index e11614b..25280f1 100644 --- a/.github/workflows/runtime.yml +++ b/.github/workflows/runtime.yml @@ -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 @@ -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/') @@ -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 diff --git a/Makefile b/Makefile index bcba169..4e52ded 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ .SUFFIXES: debug ?= +use_sccache ?= ifdef debug release := @@ -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 @@ -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 @@ -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 && \ diff --git a/util/sccache-clang b/util/sccache-clang new file mode 100755 index 0000000..0345851 --- /dev/null +++ b/util/sccache-clang @@ -0,0 +1,3 @@ +#!/bin/sh + +sccache /opt/wasi-sdk/bin/clang "$@" \ No newline at end of file