diff --git a/.circleci/config.yml b/.circleci/config.yml index 189927694f601..40b489b8ce012 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -142,6 +142,10 @@ commands: cd ~/emsdk ./emsdk install tot ./emsdk activate tot + # Write the version of clang into a file for use in the ccache key + ./upstream/bin/clang --version > clang_version.txt + echo "clang version:" + cat ~/emsdk/clang_version.txt # Remove the emsdk version of emscripten to save space in the # persistent workspace and to avoid any confusion with the version # we are trying to test. @@ -171,7 +175,7 @@ commands: command: | ./emcc --clear-cache - pip-install - - run: apt-get install -q -y ninja-build + - run: apt-get install -q -y ninja-build ccache - run: name: embuilder build ALL command: | @@ -196,6 +200,12 @@ commands: command: | ./embuilder build MINIMAL --pic --lto ./test/runner test_hello_world + - run: + name: "Ccache stats" + command: | + ccache --print-stats + ccache --zero-stats + persist: description: "Persist the emsdk, libraries, and engines" steps: @@ -209,6 +219,19 @@ commands: - vms/ - wasi-sdk/ - .jsvu/ + - when: + # Only the main branch will store its cache results, and only the non-main branches + # will use cached results. This prevents untrusted PRs from polluting caches used + # by other branches. + condition: + equal: [ "main", << pipeline.git.branch >> ] + steps: + - save_cache: + name: "Save Ccache cache" + paths: + - ~/.ccache + key: clang-{{ checksum "~/emsdk/clang_version.txt" }} + prepare-for-tests: description: "Setup emscripten tests" steps: @@ -543,6 +566,7 @@ jobs: environment: EMCC_CORES: 16 EMCC_USE_NINJA: 1 + EM_COMPILER_WRAPPER: "ccache" steps: - checkout - run: @@ -570,6 +594,14 @@ jobs: tar xvf wasi-sysroot-11.0.tar.gz -C ~/wasi-sdk/ - install-v8 - install-emsdk + - when: + condition: + not: + equal: [ "main", << pipeline.git.branch >> ] + steps: + - restore_cache: + name: "Restore Ccache cache" + key: clang-{{ checksum "~/emsdk/clang_version.txt" }} - build-libs - run: name: Clean build directory