Skip to content

Commit c4937cd

Browse files
authored
Add macos and windows builds (#3)
1 parent 023cf93 commit c4937cd

File tree

6 files changed

+273
-195
lines changed

6 files changed

+273
-195
lines changed

.github/workflows/build_llvm.yml

Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
name: "Build LLVM and MLIR"
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
force_debug_with_tmate:
7+
type: boolean
8+
description: 'Run the build with tmate session'
9+
required: false
10+
default: false
11+
debug_with_tmate:
12+
type: boolean
13+
description: 'Run the build with a tmate session ONLY in case of failure'
14+
required: false
15+
default: false
16+
pull_request:
17+
paths:
18+
- ".github/workflows/build_llvm.yml"
19+
- "third_party/llvm-project"
20+
push:
21+
branches:
22+
main
23+
paths:
24+
- ".github/workflows/build_llvm.yml"
25+
- "third_party/llvm-project"
26+
27+
concurrency:
28+
# A PR number if a pull request and otherwise the commit hash. This cancels
29+
# queued and in-progress runs for the same PR (presubmit) or commit
30+
# (postsubmit). The workflow name is prepended to avoid conflicts between
31+
# different workflows.
32+
group: ${{ github.workflow }}-${{ github.event.number || github.sha }}
33+
cancel-in-progress: true
34+
35+
jobs:
36+
build:
37+
38+
strategy:
39+
fail-fast: false
40+
matrix:
41+
include:
42+
- name: "manylinux_x86_64"
43+
runs-on: "ubuntu-22.04"
44+
container: "quay.io/pypa/manylinux_2_28_x86_64"
45+
- name: "windows_x86_64"
46+
runs-on: "windows-2019"
47+
- name: "macos_arm64"
48+
runs-on: "macos-14"
49+
- name: "macos_x86_64"
50+
runs-on: "macos-13"
51+
52+
runs-on: ${{ matrix.runs-on }}
53+
54+
name: ${{ matrix.name }}
55+
56+
defaults:
57+
run:
58+
shell: bash
59+
60+
permissions:
61+
id-token: write
62+
contents: write
63+
64+
env:
65+
# either the PR number or `branch-N` where N always increments
66+
CACHE_KEY: mlir_${{ matrix.name }}_clang_${{ format('{0}-{1}', github.ref_name, github.run_number) }}
67+
68+
container:
69+
image: ${{ matrix.container }}
70+
71+
steps:
72+
73+
- name: "Set unified TZ"
74+
uses: szenius/[email protected]
75+
with:
76+
# this is an arbitrary choice
77+
timezoneLinux: "Asia/Singapore"
78+
timezoneMacos: "Asia/Singapore"
79+
timezoneWindows: "Singapore Standard Time"
80+
81+
# notes for next time i bash my head against this:
82+
# 1. github.workspace and $GITHUB_WORKSPACE are different between container actions and non-container actions
83+
# 2. action/save-restore claims it expands ~ but that's a lie
84+
# 3. macos root (/) is read only
85+
# 4. you have to use windows style paths on windows even though we set shell: bash because
86+
# `with: path: ....` is not executed in our chosen shell (and so findind the dir will fail)
87+
# 5. action/save-restore will tell you there's no cache matching the key when the paths differ
88+
# (even if the cache key does exist)
89+
- name: "Canonicalize cache dir"
90+
id: canonicalize-cache-dir
91+
run: |
92+
if [[ "${{ matrix.runs-on }}" == ubuntu* ]]; then
93+
echo "CACHE_DIR=/tmp/.container-cache" >> $GITHUB_OUTPUT
94+
elif [[ "${{ matrix.runs-on }}" == macos* ]]; then
95+
echo "CACHE_DIR=/tmp/.container-cache" >> $GITHUB_OUTPUT
96+
elif [[ "${{ matrix.runs-on }}" == windows* ]]; then
97+
echo "CACHE_DIR=D:\a\.container-cache" >> $GITHUB_OUTPUT
98+
fi
99+
100+
- name: "Restore cache"
101+
uses: actions/cache/restore@v3
102+
with:
103+
path: ${{ steps.canonicalize-cache-dir.outputs.CACHE_DIR }}
104+
key: ${{ env.CACHE_KEY }}
105+
restore-keys: mlir_${{ matrix.name }}_clang
106+
107+
- name: "Check out repository"
108+
uses: actions/[email protected]
109+
with:
110+
submodules: true
111+
112+
- name: "Install OS deps"
113+
run: |
114+
if [[ "${{ matrix.runs-on }}" == ubuntu* ]]; then
115+
dnf install -y epel-release
116+
dnf install -y sudo ncurses-compat-libs tmate python3-pip
117+
elif [[ "${{ matrix.runs-on }}" == macos* ]]; then
118+
brew install ccache ninja
119+
fi
120+
121+
- name: "Install Python"
122+
uses: actions/setup-python@v4
123+
if: ${{ startsWith(matrix.runs-on, 'macos') || startsWith(matrix.runs-on, 'windows') }}
124+
with:
125+
python-version: '3.12'
126+
127+
- name: "Setup compiler/toolchain"
128+
uses: aminya/setup-cpp@v1
129+
if: ${{ startsWith(matrix.runs-on, 'ubuntu') || startsWith(matrix.runs-on, 'windows') }}
130+
with:
131+
compiler: llvm-18
132+
cmake: true
133+
ninja: true
134+
ccache: true
135+
vcvarsall: ${{ startsWith(matrix.runs-on, 'windows') }}
136+
137+
- name: "Set CC/CXX"
138+
run: |
139+
if [[ "${{ matrix.runs-on }}" == ubuntu* ]]; then
140+
echo "CC=/github/home/llvm/bin/clang" >> $GITHUB_ENV
141+
echo "CXX=/github/home/llvm/bin/clang++" >> $GITHUB_ENV
142+
elif [[ "${{ matrix.runs-on }}" == windows* ]]; then
143+
echo "CC=/C/Users/runneradmin/llvm/bin/clang-cl.exe" >> $GITHUB_ENV
144+
echo "CXX=/C/Users/runneradmin/llvm/bin/clang-cl.exe" >> $GITHUB_ENV
145+
elif [[ "${{ matrix.runs-on }}" == macos* ]]; then
146+
echo "CC=/usr/bin/clang" >> $GITHUB_ENV
147+
echo "CXX=/usr/bin/clang++" >> $GITHUB_ENV
148+
fi
149+
150+
- name: "Python deps"
151+
run: |
152+
python3_command=""
153+
if (command -v python3.12 &> /dev/null); then
154+
python3_command="python3.12"
155+
elif (command -v python3 &> /dev/null); then
156+
python3_command="python3"
157+
elif (command -v python &> /dev/null); then
158+
python3_command="python"
159+
fi
160+
$python3_command -m pip install -r third_party/llvm-project/mlir/python/requirements.txt
161+
echo "Python3_EXECUTABLE=$(which $python3_command)" >> $GITHUB_ENV
162+
163+
- name: "Build LLVM and MLIR"
164+
id: build
165+
run: |
166+
export CCACHE_DIR="${{ steps.canonicalize-cache-dir.outputs.CACHE_DIR }}/ccache"
167+
export CCACHE_COMPILERCHECK="string:$($CC --version)"
168+
export CCACHE_MAXSIZE=700M
169+
export CCACHE_SLOPPINESS=include_file_ctime,include_file_mtime,time_macros
170+
export CCACHE_CPP2=true
171+
export CCACHE_UMASK=002
172+
173+
export CMAKE_C_COMPILER_LAUNCHER=ccache
174+
export CMAKE_CXX_COMPILER_LAUNCHER=ccache
175+
export CMAKE_EXE_LINKER_FLAGS_INIT="-fuse-ld=lld"
176+
export CMAKE_SHARED_LINKER_FLAGS_INIT="-fuse-ld=lld"
177+
export CMAKE_MODULE_LINKER_FLAGS_INIT="-fuse-ld=lld"
178+
export Python3_EXECUTABLE="$Python3_EXECUTABLE"
179+
180+
export LLVM_SOURCE_DIR="$PWD/third_party/llvm-project"
181+
export LLVM_BUILD_DIR="$PWD/llvm-build"
182+
# double nested so that upload artifacts uploads a folder
183+
export LLVM_INSTALL_DIR="$PWD/llvm-install/llvm-install"
184+
185+
ccache -z
186+
build_tools/cmake/build_llvm.sh
187+
ccache -s
188+
189+
echo "*********************** SMOKE TEST *********************************"
190+
"$LLVM_INSTALL_DIR/bin/mlir-tblgen" --version
191+
echo "*********************** SMOKE TEST *********************************"
192+
193+
pushd $LLVM_SOURCE_DIR && LLVM_SHA_SHORT=$(git rev-parse --short HEAD) && popd
194+
tar -czf mlir_${{ matrix.name }}_$LLVM_SHA_SHORT.tar.gz "$LLVM_INSTALL_DIR"
195+
rm -rf "$LLVM_BUILD_DIR" "$LLVM_SOURCE_DIR"
196+
197+
- name: Upload artifacts
198+
uses: actions/upload-artifact@v4
199+
if: ${{ !cancelled() }}
200+
with:
201+
name: mlir_${{ matrix.name }}_artifact
202+
path: llvm-install
203+
if-no-files-found: warn
204+
205+
- name: Release current commit
206+
if: ${{ !cancelled() && github.event_name == 'push' && github.ref_name == 'main' }}
207+
uses: ncipollo/[email protected]
208+
with:
209+
artifacts: "*.tar.gz"
210+
token: "${{ secrets.GITHUB_TOKEN }}"
211+
tag: "latest"
212+
name: "latest"
213+
removeArtifacts: false
214+
allowUpdates: true
215+
replacesArtifacts: true
216+
makeLatest: true
217+
218+
- name: "Save cache"
219+
uses: actions/cache/save@v3
220+
if: ${{ !cancelled() && github.event_name == 'push' && github.ref_name == 'main' }}
221+
with:
222+
path: ${{ steps.canonicalize-cache-dir.outputs.CACHE_DIR }}
223+
key: ${{ env.CACHE_KEY }}
224+
225+
- name: "Setup tmate session"
226+
if: ${{ (failure() && inputs.debug_with_tmate) || inputs.force_debug_with_tmate }}
227+
uses: mxschmitt/[email protected]
228+
with:
229+
limit-access-to-actor: true
230+
install-dependencies: ${{ startsWith(matrix.runs-on, 'macos') || startsWith(matrix.runs-on, 'windows') }}

.github/workflows/ci_manylinux_x86_64_clang_llvm.yml

Lines changed: 0 additions & 118 deletions
This file was deleted.

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# Embedded Universal DSL: a good DSL for us by us
1+
<p align="center">
2+
<img width="300" alt="image" src="https://raw.githubusercontent.com/llvm/eudsl/refs/heads/main/docs/images/eudslpurple.svg">
3+
</p>
4+
5+
# Embedded Universal DSL: a good DSL for us, by us
26

37
This repository contains the source code for `EUDSL`, a toolkit for the construction of
48
embedded DSLs, in arbitrary languages, for targeting [MLIR](https://mlir.llvm.org).

build_tools/cmake/build_llvm.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,4 @@ echo "CMake Options: ${cmake_options[*]}"
5252

5353
cmake "${cmake_options[@]}"
5454
cmake --build "${LLVM_BUILD_DIR}" \
55-
--target install-toolchain-distribution \
56-
--target install-development-distribution \
5755
--target install-mlirdevelopment-distribution

0 commit comments

Comments
 (0)