Skip to content

Commit

Permalink
[wip] add eudsl-tblgen
Browse files Browse the repository at this point in the history
  • Loading branch information
makslevental committed Nov 13, 2024
1 parent 05ba987 commit 21d9c6b
Show file tree
Hide file tree
Showing 35 changed files with 22,442 additions and 2 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/build_llvm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ jobs:
echo "*********************** SMOKE TEST *********************************"
pushd $LLVM_SOURCE_DIR && LLVM_SHA_SHORT=$(git rev-parse --short HEAD) && popd
tar -czf mlir_${{ matrix.name }}_$LLVM_SHA_SHORT.tar.gz "$LLVM_INSTALL_DIR"
tar -czf mlir_${{ matrix.name }}_$LLVM_SHA_SHORT.tar.gz -C "$LLVM_INSTALL_DIR/.." llvm-install
rm -rf "$LLVM_BUILD_DIR" "$LLVM_SOURCE_DIR"
- name: Upload artifacts
Expand All @@ -205,7 +205,8 @@ jobs:
if-no-files-found: warn

- name: Release current commit
if: ${{ !cancelled() && github.event_name == 'push' && github.ref_name == 'main' }}
# if: ${{ !cancelled() && github.event_name == 'push' && github.ref_name == 'main' }}
if: ${{ !cancelled() }}
uses: ncipollo/[email protected]
with:
artifacts: "*.tar.gz"
Expand Down
208 changes: 208 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
name: "Test"

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:
merge_group:
push:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.sha }}
cancel-in-progress: true

jobs:
test-eudsl-tblgen:

strategy:
fail-fast: false
matrix:
include:
- name: "manylinux_x86_64"
runs-on: "ubuntu-22.04"
- name: "windows_x86_64"
runs-on: "windows-2019"
- name: "macos_arm64"
runs-on: "macos-14"
- name: "macos_x86_64"
runs-on: "macos-13"

runs-on: ${{ matrix.runs-on }}

name: ${{ matrix.name }}

defaults:
run:
shell: bash

permissions:
id-token: write
contents: write

env:
# either the PR number or `branch-N` where N always increments
CACHE_KEY: test_${{ matrix.name }}_clang_${{ format('{0}-{1}', github.ref_name, github.run_number) }}
CACHE_DIR: ${{ github.workspace }}/.container-cache

steps:

- name: "Set unified TZ"
uses: szenius/[email protected]
with:
# this is an arbitrary choice
timezoneLinux: "Asia/Singapore"
timezoneMacos: "Asia/Singapore"
timezoneWindows: "Singapore Standard Time"

- name: "Restore cache"
uses: actions/cache/restore@v3
with:
path: ${{ env.CACHE_DIR }}
key: ${{ env.CACHE_KEY }}
restore-keys: test_${{ matrix.name }}_clang

- name: "Check out repository"
uses: actions/[email protected]
with:
submodules: false

- name: "Install OS deps"
run: |
if [[ "${{ matrix.runs-on }}" == macos* ]]; then
brew install ccache ninja curl
fi
- name: "Install Python"
uses: actions/setup-python@v4
if: ${{ startsWith(matrix.runs-on, 'macos') || startsWith(matrix.runs-on, 'windows') }}
with:
python-version: '3.12'

- name: "Setup compiler/toolchain"
uses: aminya/setup-cpp@v1
if: ${{ startsWith(matrix.runs-on, 'ubuntu') || startsWith(matrix.runs-on, 'windows') }}
with:
compiler: llvm-18
cmake: true
ninja: true
ccache: true
vcvarsall: ${{ startsWith(matrix.runs-on, 'windows') }}

- name: "Set CC/CXX"
run: |
if [[ "${{ matrix.runs-on }}" == ubuntu* ]]; then
echo "CC=/usr/lib/llvm-18/bin/clang" >> $GITHUB_ENV
echo "CXX=/usr/lib/llvm-18/bin/clang++" >> $GITHUB_ENV
elif [[ "${{ matrix.runs-on }}" == windows* ]]; then
echo "CC=/C/Users/runneradmin/llvm/bin/clang-cl.exe" >> $GITHUB_ENV
echo "CXX=/C/Users/runneradmin/llvm/bin/clang-cl.exe" >> $GITHUB_ENV
elif [[ "${{ matrix.runs-on }}" == macos* ]]; then
echo "CC=/usr/bin/clang" >> $GITHUB_ENV
echo "CXX=/usr/bin/clang++" >> $GITHUB_ENV
fi
- name: "Python deps"
run: |
python3_command=""
if (command -v python3.12 &> /dev/null); then
python3_command="python3.12"
elif (command -v python3 &> /dev/null); then
python3_command="python3"
elif (command -v python &> /dev/null); then
python3_command="python"
fi
echo "Python3_EXECUTABLE=$(which $python3_command)" >> $GITHUB_ENV
- name: "Download MLIR"
env:
GH_TOKEN: ${{ github.token }}
run: |
export RELEASE_PREFIX="mlir_${{ matrix.name }}"
RELEASE_URL=$(gh release view latest --json assets -q '.assets |= sort_by(.createdAt) | .assets | map(select(.name | contains(env.RELEASE_PREFIX))) | .[-1] | .url')
curl -sLO $RELEASE_URL
tar xf $RELEASE_PREFIX*.tar.gz
- name: "Build eudsl-tblgen"
id: build
run: |
export CCACHE_DIR="${{ env.CACHE_DIR }}/ccache"
export CCACHE_COMPILERCHECK="string:$($CC --version)"
export CCACHE_MAXSIZE=700M
export CCACHE_SLOPPINESS=include_file_ctime,include_file_mtime,time_macros
export CCACHE_CPP2=true
export CCACHE_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"
export Python3_EXECUTABLE="$Python3_EXECUTABLE"
export CMAKE_PREFIX_PATH="$PWD/llvm-install"
export EUDSL_SRC_DIR="$PWD/projects/eudsl-tblgen"
export EUDSL_BUILD_DIR="$PWD/eudsl-build"
export EUDSL_INSTALL_DIR="$PWD/eudsl-install"
ccache -z
cmake -S "$EUDSL_SRC_DIR" \
-B "$EUDSL_BUILD_DIR" \
"-DCMAKE_PREFIX_PATH=$PWD/__w/eudsl/eudsl/llvm-install/llvm-install" \
"-DCMAKE_INSTALL_PREFIX=$EUDSL_INSTALL_DIR"
cmake --build "$EUDSL_BUILD_DIR" --target install
ccache -s
echo "*********************** SMOKE TEST *********************************"
"$EUDSL_INSTALL_DIR/bin/eudsl-tblgen" --help
echo "*********************** SMOKE TEST *********************************"
SHA_SHORT=$(git rev-parse --short HEAD)
tar -czf eudsl_tblgen_${{ matrix.name }}_$SHA_SHORT.tar.gz -C "$EUDSL_INSTALL_DIR" bin
- name: Upload artifacts
uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: eudsl_${{ matrix.name }}_artifact
path: eudsl-install/bin
if-no-files-found: warn

- name: Release current commit
if: ${{ !cancelled() && github.event_name == 'push' && github.ref_name == 'main' }}
uses: ncipollo/[email protected]
with:
artifacts: "*.tar.gz"
token: "${{ secrets.GITHUB_TOKEN }}"
tag: "latest"
name: "latest"
removeArtifacts: false
allowUpdates: true
replacesArtifacts: true
makeLatest: true

- name: "Save cache"
uses: actions/cache/save@v3
if: ${{ !cancelled() && github.event_name == 'push' && github.ref_name == 'main' }}
with:
path: ${{ env.CACHE_DIR }}
key: ${{ env.CACHE_KEY }}

- name: "Setup tmate session"
if: ${{ (failure() && inputs.debug_with_tmate) || inputs.force_debug_with_tmate }}
uses: mxschmitt/[email protected]
with:
limit-access-to-actor: true
install-dependencies: ${{ startsWith(matrix.runs-on, 'macos') || startsWith(matrix.runs-on, 'windows') }}
5 changes: 5 additions & 0 deletions build_tools/cmake/llvm_cache.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ set(LLVM_MlirDevelopment_DISTRIBUTION_COMPONENTS
not
MLIRPythonModules
MLIRPythonModules
# triggers LLVMMlirDevelopmentExports.cmake
mlirdevelopment-cmake-exports
# triggers MLIRMlirDevelopmentTargets.cmake
mlir-mlirdevelopment-cmake-exports
# triggers MLIRConfig.cmake and etc
mlir-cmake-exports
mlir-headers
mlir-libraries
Expand Down
Loading

0 comments on commit 21d9c6b

Please sign in to comment.