Skip to content

Commit

Permalink
github.workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
makslevental committed Nov 12, 2024
1 parent 690f0d5 commit 313ed35
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 39 deletions.
54 changes: 38 additions & 16 deletions .github/workflows/build_llvm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 }}
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Embedded Universal DSL: a good DSL for us by us
# Embedded Universal DSL: a good DSL for us, by us

This repository contains the source code for `EUDSL`, a toolkit for the construction of
embedded DSLs, in arbitrary languages, for targeting [MLIR](https://mlir.llvm.org).
Expand Down
12 changes: 12 additions & 0 deletions build_tools/cmake/build_llvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
TD="$(cd $(dirname $0) && pwd)"
REPO_ROOT="$(cd $TD/../.. && pwd)"

#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:$(clang --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
export CMAKE_EXE_LINKER_FLAGS_INIT="-fuse-ld=lld"
export CMAKE_SHARED_LINKER_FLAGS_INIT="-fuse-ld=lld"
export CMAKE_MODULE_LINKER_FLAGS_INIT="-fuse-ld=lld"

LLVM_SOURCE_DIR="${LLVM_SOURCE_DIR:-${REPO_ROOT}/third_party/llvm-project}"
LLVM_BUILD_DIR="${LLVM_BUILD_DIR:-${REPO_ROOT}/llvm-build}"
LLVM_INSTALL_DIR="${LLVM_INSTALL_DIR:-${REPO_ROOT}/llvm-install}"
Expand Down
48 changes: 26 additions & 22 deletions build_tools/cmake/llvm_cache.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ set(LLVM_INCLUDE_TOOLS ON CACHE BOOL "")
set(LLVM_INSTALL_UTILS ON CACHE BOOL "")

# All the tools will use libllvm shared library
set(LLVM_BUILD_LLVM_DYLIB ON CACHE BOOL "")
set(LLVM_LINK_LLVM_DYLIB ON CACHE BOOL "")
# doesn't work on windows
if (NOT WIN32)
set(LLVM_BUILD_LLVM_DYLIB ON CACHE BOOL "")
set(LLVM_LINK_LLVM_DYLIB ON CACHE BOOL "")
endif()

# useful things
set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
Expand Down Expand Up @@ -56,25 +59,26 @@ set(LLVM_INSTALL_TOOLCHAIN_ONLY OFF CACHE BOOL "")

set(LLVM_DISTRIBUTIONS MlirDevelopment CACHE STRING "")
set(LLVM_MlirDevelopment_DISTRIBUTION_COMPONENTS
Remarks
cmake-exports
llvm-config
llvm-headers
llvm-libraries
opt
FileCheck
count
not
mlir-opt
mlir-reduce
# these are needed basically for execution engine
# check LINK_COMPONENTS there
# llvm-config
# llvm-headers
# llvm-libraries
# cmake-exports
# FileCheck
# not
# MLIRPythonModules
# MLIRPythonModules
# mlir-cmake-exports
# mlir-headers
# mlir-libraries
# mlir-opt
# mlir-python-sources
# mlir-reduce
mlir-tblgen
mlir-translate
MLIRPythonModules
mlir-python-sources
MLIRPythonModules
mlir-cmake-exports
mlir-headers
mlir-libraries
${LLVM_MLIR_TOOLS}
${LLVM_MLIR_Python_COMPONENTS}
# mlir-translate
CACHE STRING "")

if (NOT WIN32)
list(APPEND LLVM_MlirDevelopment_DISTRIBUTION_COMPONENTS LLVM)
endif()

0 comments on commit 313ed35

Please sign in to comment.