Skip to content

Commit

Permalink
Caching for LLVM build in github actions (buddy-compiler#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtemSkrebkov authored Jul 18, 2022
1 parent dee7ee9 commit 7307f76
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 16 deletions.
24 changes: 19 additions & 5 deletions .github/workflows/TestBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,29 @@ name: test build process
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:

runs-on: ubuntu-latest

# ToDo : Cache llvm build to reduce execution time on each run of virtual instance.
steps:
- uses: actions/checkout@v2
- uses: seanmiddleditch/gha-setup-ninja@master
- name: test build
run: bash ./tests/Actions/TestBuild.sh
- name: Checkout
uses: actions/checkout@v3
with:
submodules: 'true'
- name: Set up ninja
uses: seanmiddleditch/gha-setup-ninja@master
- name: Prepare llvm build directory name
id: llvm-build-dir
run: |
echo "::set-output name=commit::$(git submodule status | awk '{print $1;}')"
- name: Cache llvm build directory
uses: actions/cache@v3
with:
path: llvm
key: build-${{ steps.llvm-build-dir.outputs.commit }}
- name: Test build
run: bash ./tests/Actions/TestBuild.sh llvm/build-${{ steps.llvm-build-dir.outputs.commit }}
36 changes: 25 additions & 11 deletions tests/Actions/TestBuild.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
git submodule update --init
mkdir llvm/build
cd llvm/build
cmake -G Ninja ../llvm \
-DLLVM_ENABLE_PROJECTS="mlir" \
-DLLVM_TARGETS_TO_BUILD="host;RISCV" \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DCMAKE_BUILD_TYPE=RELEASE
ninja
if [ -z "$1" ]
then
llvm_build_dir="llvm/build"
else
llvm_build_dir="$1"
fi
if [ ! -d $llvm_build_dir ]
then
mkdir $llvm_build_dir
fi

cd $llvm_build_dir
# assuming if there is something in llvm_build_dir, it is a valid build,
# so we won't build llvm
if [ -z "$(ls -A ./)" ]
then
cmake -G Ninja ../llvm \
-DLLVM_ENABLE_PROJECTS="mlir" \
-DLLVM_TARGETS_TO_BUILD="host;RISCV" \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DCMAKE_BUILD_TYPE=RELEASE
ninja
fi
cd ../..
mkdir build
cd build
cmake -G Ninja .. \
-DMLIR_DIR=$PWD/../llvm/build/lib/cmake/mlir \
-DLLVM_DIR=$PWD/../llvm/build/lib/cmake/llvm \
-DMLIR_DIR=$PWD/../$llvm_build_dir/lib/cmake/mlir \
-DLLVM_DIR=$PWD/../$llvm_build_dir/lib/cmake/llvm \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DCMAKE_BUILD_TYPE=RELEASE
ninja check-buddy

0 comments on commit 7307f76

Please sign in to comment.