Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] Build and cache seprate Clang and GCC builds of LLVM #3242

Merged
merged 1 commit into from
Jun 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 42 additions & 18 deletions .github/workflows/buildAndTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ jobs:
runs-on: ubuntu-latest
container:
image: ghcr.io/circt/images/circt-ci-build:20220216182244
strategy:
matrix:
compiler:
- cc: clang
cxx: clang++
- cc: gcc
cxx: g++
steps:
# Clone the CIRCT repo and its submodules. Do shallow clone to save clone
# time.
Expand All @@ -140,22 +147,22 @@ jobs:

- name: Get workflow spec hash
id: get-workflow-hash
run: echo "::set-output name=hash::$(md5sum $GITHUB_WORKSPACE/.github/workflows/buildAndTest.yml)"
run: echo "::set-output name=hash::$(md5sum $GITHUB_WORKSPACE/.github/workflows/buildAndTest.yml | awk '{print $1}')"

# Try to fetch LLVM from the cache.
- name: Cache LLVM
- name: Cache LLVM (${{ matrix.compiler.cc }})
id: cache-llvm
uses: actions/cache@v2
with:
path: |
llvm/build
llvm/install
key: ${{ runner.os }}-llvm-${{ steps.get-llvm-hash.outputs.hash }}-${{ steps.get-workflow-hash.outputs.hash }}
key: ${{ runner.os }}-llvm-${{ steps.get-llvm-hash.outputs.hash }}-${{ steps.get-workflow-hash.outputs.hash }}-${{ matrix.compiler.cc }}-${{ matrix.compiler.cxx }}

# Build LLVM if we didn't hit in the cache.
- name: Rebuild and Install LLVM
if: steps.cache-llvm.outputs.cache-hit != 'true'
run: utils/build-llvm.sh
run: utils/build-llvm.sh build install Release ${{ matrix.compiler.cc }} ${{ matrix.compiler.cxx }}


# Installing the results into the cache is an action which is automatically
Expand Down Expand Up @@ -224,21 +231,38 @@ jobs:
run: echo "::set-output name=hash::$(md5sum $GITHUB_WORKSPACE/.github/workflows/buildAndTest.yml)"

# Try to fetch LLVM from the cache.
- name: Cache LLVM
id: cache-llvm
- name: Cache LLVM (Clang)
id: cache-llvm-clang
uses: actions/cache@v2
with:
path: |
llvm/build
llvm/install
key: ${{ runner.os }}-llvm-${{ steps.get-llvm-hash.outputs.hash }}-${{ steps.get-workflow-hash.outputs.hash }}
llvm/build-clang
llvm/install-clang
key: ${{ runner.os }}-llvm-${{ steps.get-llvm-hash.outputs.hash }}-${{ steps.get-workflow-hash.outputs.hash }}-clang

# Build LLVM if we didn't hit in the cache. Even though we build it in
# the previous job, there is a low chance that it'll have been evicted by
# the time we get here.
- name: Rebuild and Install LLVM
if: steps.cache-llvm.outputs.cache-hit != 'true'
run: utils/build-llvm.sh
- name: Rebuild and Install LLVM (Clang)
if: steps.cache-llvm-clang.outputs.cache-hit != 'true'
run: utils/build-llvm.sh build-clang install-clang Release clang clang++

# Try to fetch LLVM from the cache.
- name: Cache LLVM (GCC)
id: cache-llvm-gcc
uses: actions/cache@v2
with:
path: |
llvm/build-gcc
llvm/install-gcc
key: ${{ runner.os }}-llvm-${{ steps.get-llvm-hash.outputs.hash }}-${{ steps.get-workflow-hash.outputs.hash }}-gcc

# Build LLVM if we didn't hit in the cache. Even though we build it in
# the previous job, there is a low chance that it'll have been evicted by
# the time we get here.
- name: Rebuild and Install LLVM (GCC)
if: steps.cache-llvm-gcc.outputs.cache-hit != 'true'
run: utils/build-llvm.sh build-gcc install-gcc Release gcc g++

# --------
# Build and test CIRCT in both debug and release mode.
Expand All @@ -257,12 +281,12 @@ jobs:
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=OFF \
-DMLIR_DIR=../llvm/install/lib/cmake/mlir/ \
-DLLVM_DIR=../llvm/install/lib/cmake/llvm/ \
-DMLIR_DIR=`pwd`/../llvm/install-clang/lib/cmake/mlir \
-DLLVM_DIR=`pwd`/../llvm/install-clang/lib/cmake/llvm \
-DLLVM_USE_LINKER=lld \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DLLVM_EXTERNAL_LIT=`pwd`/../llvm/build/bin/llvm-lit \
-DLLVM_EXTERNAL_LIT=`pwd`/../llvm/build-clang/bin/llvm-lit \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
make check-circt -j$(nproc)
make circt-doc
Expand All @@ -275,12 +299,12 @@ jobs:
cmake .. \
-DCMAKE_BUILD_TYPE=Debug \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DMLIR_DIR=../llvm/install/lib/cmake/mlir/ \
-DLLVM_DIR=../llvm/install/lib/cmake/llvm/ \
-DMLIR_DIR=`pwd`/../llvm/install-gcc/lib/cmake/mlir/ \
-DLLVM_DIR=`pwd`/../llvm/install-gcc/lib/cmake/llvm/ \
-DLLVM_USE_LINKER=lld \
-DCMAKE_C_COMPILER=gcc \
-DCMAKE_CXX_COMPILER=g++ \
-DLLVM_EXTERNAL_LIT=`pwd`/../llvm/build/bin/llvm-lit
-DLLVM_EXTERNAL_LIT=`pwd`/../llvm/build-gcc/bin/llvm-lit
make check-circt -j$(nproc)
make circt-doc

Expand Down
8 changes: 5 additions & 3 deletions utils/build-llvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@
BUILD_DIR=${1:-"build"}
INSTALL_DIR=${2:-"install"}
BUILD_TYPE=${3:-"Release"}
EXTRA_ARGS=${@:4}
CC=${4:-"clang"}
CXX=${5:-"clang++"}
EXTRA_ARGS=${@:6}

mkdir -p llvm/$BUILD_DIR
mkdir -p llvm/$INSTALL_DIR
cd llvm/$BUILD_DIR
cmake ../llvm \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_C_COMPILER=$CC \
-DCMAKE_CXX_COMPILER=$CXX \
-DCMAKE_INSTALL_PREFIX=../$INSTALL_DIR \
-DLLVM_BUILD_EXAMPLES=OFF \
-DLLVM_ENABLE_ASSERTIONS=ON \
Expand Down