-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
690f0d5
commit 313ed35
Showing
4 changed files
with
77 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,17 @@ name: "Build LLVM and MLIR" | |
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
force_debug_with_tmate: | ||
type: boolean | ||
description: 'Run the build with tmate session' | ||
required: false | ||
default: false | ||
debug_with_tmate: | ||
type: boolean | ||
description: 'Run the build with a tmate session ONLY in case of failure' | ||
required: false | ||
default: false | ||
pull_request: | ||
paths: | ||
- ".github/workflows/build_llvm.yml" | ||
|
@@ -43,7 +54,6 @@ jobs: | |
env: | ||
# either the PR number or `branch-N` where N always increments | ||
CACHE_KEY: ${{ matrix.name }}_clang_llvm_${{ format('{0}-{1}', github.ref_name, github.run_number) }} | ||
CACHE_DIR: ${{ github.workspace }}/.container-cache | ||
|
||
container: | ||
image: ${{ matrix.container }} | ||
|
@@ -58,10 +68,19 @@ jobs: | |
timezoneMacos: "Asia/Singapore" | ||
timezoneWindows: "Singapore Standard Time" | ||
|
||
- name: "Canonicalize workspace" | ||
id: canonicalize-workspace | ||
run: | | ||
if [[ "${{ matrix.runs-on }}" == ubuntu* ]]; then | ||
echo "workspace=$GITHUB_WORKSPACE" >> $GITHUB_OUTPUT | ||
else | ||
echo "workspace=${{ github.workspace }}" >> $GITHUB_OUTPUT | ||
fi | ||
- name: "Restore cache" | ||
uses: actions/cache/restore@v3 | ||
with: | ||
path: ${{ env.CACHE_DIR }} | ||
path: ${{ steps.canonicalize-workspace.outputs.workspace }}/.container-cache | ||
key: ${{ env.CACHE_KEY }} | ||
restore-keys: ${{ matrix.name }}_clang_llvm | ||
|
||
|
@@ -122,11 +141,14 @@ jobs: | |
echo "Python3_EXECUTABLE=$(which $python3_command)" >> $GITHUB_ENV | ||
- name: "Build LLVM and MLIR" | ||
id: build | ||
run: | | ||
export CCACHE_DIR="${{ env.CACHE_DIR }}" | ||
export CCACHE_MAXSIZE=700M | ||
export CCACHE_COMPILERCHECK="string:$($CC --version)" | ||
export CCACHE_SLOPPINESS=include_file_ctime,include_file_mtime,time_macros | ||
mkdir -p "${{ steps.canonicalize-workspace.outputs.workspace }}/.container-cache" | ||
ccache --set-config=cache_dir="${{ steps.canonicalize-workspace.outputs.workspace }}/.container-cache" | ||
ccache --set-config=max_size=700M | ||
ccache --set-config=compiler_check="string:$($CC --version | head -n 1)" | ||
ccache --set-config=sloppiness=include_file_ctime,include_file_mtime,time_macros | ||
ccache --set-config=umask=002 | ||
export CMAKE_C_COMPILER_LAUNCHER=ccache | ||
export CMAKE_CXX_COMPILER_LAUNCHER=ccache | ||
|
@@ -135,34 +157,34 @@ jobs: | |
export CMAKE_MODULE_LINKER_FLAGS_INIT="-fuse-ld=lld" | ||
export Python3_EXECUTABLE="$Python3_EXECUTABLE" | ||
export LLVM_SOURCE_DIR="$PWD/third_party/llvm-project" | ||
export LLVM_BUILD_DIR="$PWD/llvm-build" | ||
export LLVM_INSTALL_DIR="$PWD/llvm-install" | ||
export LLVM_SOURCE_DIR="${{ steps.canonicalize-workspace.outputs.workspace }}/third_party/llvm-project" | ||
export LLVM_BUILD_DIR="${{ steps.canonicalize-workspace.outputs.workspace }}/llvm-build" | ||
export LLVM_INSTALL_DIR="${{ steps.canonicalize-workspace.outputs.workspace }}/llvm-install/llvm-install" | ||
pushd $LLVM_SOURCE_DIR && llvm_sha_short=$(git rev-parse --short HEAD) && popd | ||
ccache -z | ||
build_tools/cmake/build_llvm.sh | ||
ccache -s | ||
pushd $LLVM_SOURCE_DIR && echo "llvm_sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT && popd | ||
rm -rf $LLVM_BUILD_DIR $LLVM_SOURCE_DIR | ||
tar cf llvm-dist-${{ matrix.name }}-$llvm_sha_short.tar $LLVM_INSTALL_DIR | ||
rm -rf $LLVM_INSTALL_DIR | ||
- name: "Upload dist" | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ matrix.name }}_llvm_packages | ||
path: llvm-dist-*.tar | ||
name: ${{ matrix.name }}_llvm_${{ steps.build.outputs.llvm_sha_short }} | ||
path: ${{ steps.canonicalize-workspace.outputs.workspace }}/llvm-install | ||
if-no-files-found: error | ||
|
||
- name: "Save cache" | ||
uses: actions/cache/save@v3 | ||
# if: ${{ !cancelled() && github.event_name == 'push' && github.ref_name == 'main' }} | ||
if: ${{ !cancelled() }} | ||
with: | ||
path: ${{ env.CACHE_DIR }} | ||
path: ${{ steps.canonicalize-workspace.outputs.workspace }}/.container-cache | ||
key: ${{ env.CACHE_KEY }} | ||
|
||
- name: "Setup tmate session" | ||
if: ${{ failure() }} | ||
if: ${{ (failure() && inputs.debug_with_tmate) || inputs.force_debug_with_tmate }} | ||
uses: mxschmitt/[email protected] | ||
with: | ||
limit-access-to-actor: true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters