-
Notifications
You must be signed in to change notification settings - Fork 19
82 lines (78 loc) · 3.33 KB
/
dep_build_wasm_examples.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
# See README.md in this directory for more information about workflow_call
name: Build Wasm Examples
on:
workflow_call:
inputs:
docs_only:
description: Skip building if docs only
required: false
type: string
default: "false"
permissions:
packages: write
contents: read
jobs:
build-wasm-examples:
if: ${{ inputs.docs_only == 'false' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Remove default clang
run: sudo rm /usr/bin/clang
- name: Hyperlight setup workflow
uses: hyperlight-dev/[email protected]
with:
rust-toolchain: "1.82.0"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull wasm-clang-builder
continue-on-error: true
run: |
docker pull ghcr.io/${{ github.repository_owner }}/wasm-clang-builder:latest
- name: Set up Docker image metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ github.repository_owner }}/wasm-clang-builder
- name: Build and push wasm-clang-builder
# depedabot does not have push access to update the wasm-clang-builder image
if: github.actor != 'dependabot[bot]'
uses: docker/build-push-action@v6
with:
context: src/wasmsamples
file: src/wasmsamples/dockerfile
load: true
push: true
build-args: |
WASI_SDK_VERSION_FULL=20.0
GCC_VERSION=12
tags: ghcr.io/${{ github.repository_owner }}/wasm-clang-builder:latest
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/wasm-clang-builder:buildcache
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/wasm-clang-builder:buildcache,mode=max
- name: Build Modules
run: |
for FILENAME in $(find . -name '*.c')
do
echo Building ${FILENAME}
docker run --rm -i -v "${PWD}:/tmp/host" ghcr.io/${{ github.repository_owner }}/wasm-clang-builder:latest /opt/wasi-sdk/bin/clang -flto -ffunction-sections -mexec-model=reactor -O3 -z stack-size=4096 -Wl,--initial-memory=65536 -Wl,--export=__data_end -Wl,--export=__heap_base,--export=malloc,--export=free,--export=__wasm_call_ctors -Wl,--strip-all,--no-entry -Wl,--allow-undefined -Wl,--gc-sections -o /tmp/host/${FILENAME%.*}-wasi-libc.wasm /tmp/host/${FILENAME}
cargo run -p hyperlight-wasm-aot compile ${FILENAME%.*}-wasi-libc.wasm ${FILENAME%.*}.aot
cp ${FILENAME%.*}.aot ${FILENAME%.*}.wasm
done
shell: bash
working-directory: src/wasmsamples
- name: Upload Wasm Modules
uses: actions/upload-artifact@v4
with:
name: guest-modules
path: |
src/wasmsamples/*.wasm
src/wasmsamples/*.aot