Skip to content

Commit 388a7ca

Browse files
authored
Enable ccache for CI builds of LLVM (#277)
1 parent 646cac5 commit 388a7ca

File tree

5 files changed

+52
-16
lines changed

5 files changed

+52
-16
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# Our docker builds do not require the submodule sources so exclude them as
22
# they can be very big.
33
/src
4+
.git

.github/workflows/main.yml

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,35 @@ jobs:
2020
- ubuntu-latest
2121
- macos-latest
2222
steps:
23+
- uses: actions/cache@v3
24+
with:
25+
path: ~/.cache/ccache
26+
# Bump the prefix number to evict all previous caches and
27+
# enforce a clean build, in the unlikely case that some
28+
# weird build error occur and ccache becomes a potential
29+
# suspect.
30+
key: 0-cache-ubuntu-latest-${{ github.run_id }}
31+
restore-keys: |
32+
0-cache-ubuntu-latest
33+
if: matrix.os == 'ubuntu-latest'
34+
- uses: actions/cache@v3
35+
with:
36+
path: ~/Library/Caches/ccache
37+
key: 0-cache-macos-latest-${{ github.run_id }}
38+
restore-keys: |
39+
0-cache-macos-latest
40+
if: matrix.os == 'macos-latest'
2341
- uses: actions/checkout@v1
2442
with:
2543
submodules: true
26-
- name: Install ninja (macOS)
27-
run: brew install ninja
44+
- name: Install ccache, ninja (macOS)
45+
run: brew install ccache ninja
2846
if: matrix.os == 'macos-latest'
29-
- name: Install ninja (Linux)
30-
run: sudo apt install ninja-build
47+
- name: Install ccache, ninja (Linux)
48+
run: sudo apt install ccache ninja-build
3149
if: matrix.os == 'ubuntu-latest'
3250
- name: Build
33-
run: NINJA_FLAGS=-v make package
51+
run: NINJA_FLAGS=-v make package LLVM_CMAKE_FLAGS=-DLLVM_CCACHE_BUILD=ON
3452
shell: bash
3553
- name: Run the testsuite
3654
run: NINJA_FLAGS=-v make check
@@ -55,11 +73,18 @@ jobs:
5573
sys: clang32
5674
env: clang-i686
5775
steps:
76+
- uses: actions/cache@v3
77+
with:
78+
path: ~/AppData/Local/ccache
79+
key: 0-${{ format( 'cache-windows-latest-{0}', matrix.arch) }}-${{ github.run_id }}
80+
restore-keys: |
81+
0-${{ format( 'cache-windows-latest-{0}', matrix.arch) }}
5882
- uses: msys2/setup-msys2@v2
5983
with:
6084
install: >-
6185
base-devel
6286
git
87+
mingw-w64-${{ matrix.env }}-ccache
6388
mingw-w64-${{ matrix.env }}-cmake
6489
mingw-w64-${{ matrix.env }}-ninja
6590
mingw-w64-${{ matrix.env }}-toolchain
@@ -73,7 +98,7 @@ jobs:
7398
- name: Build
7499
shell: msys2 {0}
75100
run: |
76-
make package
101+
make package LLVM_CMAKE_FLAGS=-DLLVM_CCACHE_BUILD=ON
77102
make check
78103
- name: Does it work sans msys2?
79104
run: |
@@ -91,6 +116,13 @@ jobs:
91116
name: Docker Build
92117
runs-on: ubuntu-latest
93118
steps:
119+
- uses: actions/cache@v3
120+
with:
121+
path: ~/.ccache
122+
key: 0-cache-ubuntu-bionic-${{ github.run_id }}
123+
restore-keys: |
124+
0-cache-ubuntu-bionic
125+
94126
- uses: actions/checkout@v1
95127
with:
96128
submodules: true
@@ -121,7 +153,7 @@ jobs:
121153
uses: actions/upload-artifact@v1
122154
with:
123155
# Upload the dist folder. Give it a name according to the OS it was built for.
124-
name: dist-ubuntu-xenial
156+
name: dist-ubuntu-bionic
125157
path: dist
126158

127159
- name: Build and push wasi-sdk docker image

Dockerfile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ FROM ubuntu:bionic
55

66
RUN apt-get update \
77
&& apt-get install -y --no-install-recommends \
8+
ccache \
89
curl \
910
ca-certificates \
1011
build-essential \
@@ -15,9 +16,9 @@ RUN apt-get update \
1516
&& apt-get clean \
1617
&& rm -rf /var/lib/apt/lists/*
1718

18-
RUN curl -sSLO https://github.com/Kitware/CMake/releases/download/v3.20.1/cmake-3.20.1-linux-x86_64.tar.gz \
19-
&& tar xf cmake-3.20.1-linux-x86_64.tar.gz \
20-
&& rm cmake-3.20.1-linux-x86_64.tar.gz \
19+
RUN curl -sSLO https://github.com/Kitware/CMake/releases/download/v3.25.1/cmake-3.25.1-linux-x86_64.tar.gz \
20+
&& tar xf cmake-3.25.1-linux-x86_64.tar.gz \
21+
&& rm cmake-3.25.1-linux-x86_64.tar.gz \
2122
&& mkdir -p /opt \
22-
&& mv cmake-3.20.1-linux-x86_64 /opt/cmake
23+
&& mv cmake-3.25.1-linux-x86_64 /opt/cmake
2324
ENV PATH /opt/cmake/bin:$PATH

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ build/llvm.BUILT:
7373
-DDEFAULT_SYSROOT=$(PREFIX)/share/wasi-sysroot) \
7474
-DLLVM_INSTALL_BINUTILS_SYMLINKS=TRUE \
7575
-DLLVM_ENABLE_LIBXML2=OFF \
76+
$(LLVM_CMAKE_FLAGS) \
7677
$(LLVM_PROJ_DIR)/llvm
7778
DESTDIR=$(DESTDIR) ninja $(NINJA_FLAGS) -C build/llvm \
7879
install-clang \

docker_build.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
#!/usr/bin/env sh
2-
set -e
3-
echo "Building the docker"
1+
#!/bin/sh
2+
set -ex
3+
echo "Building the docker image"
44
docker build -t wasi-sdk-builder:latest .
5-
echo "Building the package in docker"
6-
docker run --mount type=bind,src=$PWD,target=/workspace -e NINJA_FLAGS=-v --workdir /workspace wasi-sdk-builder:latest make package
5+
echo "Building the package in docker image"
6+
mkdir -p ~/.ccache
7+
docker run --rm -v "$PWD":/workspace -v ~/.ccache:/root/.ccache -e NINJA_FLAGS=-v --workdir /workspace --tmpfs /tmp:exec wasi-sdk-builder:latest make package LLVM_CMAKE_FLAGS=-DLLVM_CCACHE_BUILD=ON

0 commit comments

Comments
 (0)