Skip to content

JIT proof of concept using stencils and tiny assembler. #400

JIT proof of concept using stencils and tiny assembler.

JIT proof of concept using stencils and tiny assembler. #400

Workflow file for this run

name: Latest Build
on:
workflow_dispatch:
inputs:
deps_rev_override:
description: 'Deps Revision Override'
type: string
default: ''
required: false
push:
branches:
- master
paths-ignore:
- '.github/**'
- '**.md'
- 'docs/hugo/**'
- '.gitattributes'
- 'examples/**.cy'
- 'examples/**/*.cy'
# Cancel previous job if it's running.
concurrency:
group: latest
cancel-in-progress: true
jobs:
build:
name: host=${{ matrix.config.host }} cmd=${{ matrix.config.cmd }} target=${{ matrix.config.target }} mode=${{ matrix.config.mode }}
runs-on: ${{ matrix.config.host }}
strategy:
fail-fast: false
matrix:
config:
- host: ubuntu-22.04
target: x86_64-linux-gnu
mode: release
cmd: cli
- host: ubuntu-22.04
target: x86_64-selinux-gnu
mode: release
cmd: cli
- host: macos-12
target: x86_64-macos-none
mode: release
cmd: cli
- host: macos-12
target: aarch64-macos-none
mode: release
cmd: cli
- host: windows-2022
target: x86_64-windows-gnu
mode: release
cmd: cli
- host: windows-2022
target: x86_64-windows-gnu
mode: release
cmd: lib
- host: ubuntu-22.04
target: wasm32-freestanding
mode: release
cmd: web-lib
- host: ubuntu-22.04
target: x86_64-linux-gnu
mode: release
cmd: lib
- host: macos-12
target: x86_64-macos-none
mode: release
cmd: lib
- host: macos-12
target: aarch64-macos-none
mode: release
cmd: lib
env:
BIN_ZIP: >-
${{ fromJson('{
"x86_64-windows-gnu": "cyber-windows-x64.zip",
"x86_64-linux-gnu": "cyber-linux-x64.tar.gz",
"x86_64-selinux-gnu": "cyber-selinux-x64.tar.gz",
"x86_64-macos-none": "cyber-macos-x64.tar.gz",
"aarch64-macos-none": "cyber-macos-arm64.tar.gz",
"wasm32-freestanding": "cyber.wasm",
}')[matrix.config.target] }}
ZIG_TARGET_FLAG: >-
${{ fromJson('{
"x86_64-windows-gnu": "-Dtarget=x86_64-windows-gnu -Dcpu=baseline",
"x86_64-linux-gnu": "-Dtarget=x86_64-linux-gnu -Dcpu=baseline",
"x86_64-selinux-gnu": "-Dtarget=x86_64-linux-gnu -Dcpu=baseline -Dselinux",
"x86_64-macos-none": "-Dtarget=x86_64-macos-none -Dcpu=baseline",
"aarch64-macos-none": "-Dtarget=aarch64-macos-none -Dcpu=baseline",
"wasm32-freestanding": "-Dtarget=wasm32-freestanding",
}')[matrix.config.target] }}
BUILD_HOST: ${{ matrix.config.host }}
BUILD_TARGET: ${{ matrix.config.target }}
BUILD_MODE: ${{ matrix.config.mode }}
BUILD_CMD: ${{ matrix.config.cmd }}
BIN_NAME: cyber
BIN_EXT: ${{ contains(matrix.config.target, 'windows') && '.exe' || '' }}
ZIG_MODE_FLAG: ${{ (matrix.config.mode == 'release' && '-Doptimize=ReleaseFast') || '' }}
ZIG_VERSION: 0.11.0
steps:
- name: Install Linux deps.
if: env.BUILD_HOST == 'ubuntu-22.04' && env.BUILD_TARGET == 'x86_64-linux-gnu'
run: |
sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu `lsb_release -sc` main universe restricted multiverse"
sudo apt-get update -y -qq
sudo apt-get install xz-utils
- name: Clone repo.
uses: actions/checkout@v2
with:
# Fetch all so commit count can be computed from tag.
fetch-depth: 0
#submodules: recursive
- name: Install zig.
if: env.BUILD_HOST == 'ubuntu-22.04'
run: |
wget -c https://ziglang.org/builds/zig-linux-x86_64-${{ env.ZIG_VERSION }}.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin
- name: Install wasm3.
if: env.BUILD_HOST == 'ubuntu-22.04' && env.BUILD_TARGET == 'wasm32-freestanding'
run: |
git clone --depth=1 https://github.com/wasm3/wasm3.git
cd wasm3
mkdir build
cd build
cmake ..
make
- name: Install zig.
if: env.BUILD_HOST == 'macos-12'
run: |
wget -c https://ziglang.org/builds/zig-macos-x86_64-${{ env.ZIG_VERSION }}.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin
xcode-select --print-path
- name: Install zig.
if: env.BUILD_HOST == 'windows-2022'
run: |
Invoke-WebRequest -Uri 'https://ziglang.org/builds/zig-windows-x86_64-${{ env.ZIG_VERSION }}.zip' -OutFile 'C:\zig.zip'
cd C:\
7z x zig.zip
Add-Content $env:GITHUB_PATH 'C:\zig-windows-x86_64-${{ env.ZIG_VERSION }}\'
- name: Setup script.
uses: actions/github-script@v5
with:
script: |
async function execCmd(name, args) {
const opts = {};
let out = '';
let err = '';
opts.listeners = {
stdout: (data) => {
out += data.toString();
},
stderr: (data) => {
process.stderr.write(data.toString());
}
};
// opt.cwd = './lib';
await exec.exec(name, args, opts);
return out;
}
const version = await execCmd('zig', ['build', 'version']);
core.exportVariable('SHORT_VERSION', version);
await execCmd('git', ['fetch', '--all', '--tags']);
const build = await execCmd('git', ['rev-list', '--count', `${version}..${context.sha}`])
core.exportVariable('BUILD', build.trim());
core.exportVariable('COMMIT', context.sha.substring(0, 7));
- name: Cache.
#if: env.BUILD_TARGET != 'x86_64-windows-gnu'
uses: actions/cache@v2
with:
path: |-
~/.cache/zig
zig-cache
~/AppData/Local/zig
key:
build-${{ env.BUILD_TARGET }}-${{ env.BUILD_MODE }}-1
restore-keys:
build-${{ env.BUILD_TARGET }}-${{ env.BUILD_MODE }}-1
- name: Run tests.
if: env.BUILD_TARGET != 'aarch64-macos-none' && env.BUILD_TARGET != 'wasm32-freestanding' && env.BUILD_CMD != 'lib'
run: zig build test ${{ env.ZIG_TARGET_FLAG }}
- name: Run tests.
if: env.BUILD_TARGET != 'aarch64-macos-none' && env.BUILD_TARGET != 'wasm32-freestanding' && env.BUILD_CMD == 'lib'
run: zig build test-lib ${{ env.ZIG_TARGET_FLAG }}
- name: Run tests.
if: env.BUILD_TARGET == 'wasm32-freestanding'
run: |
zig build build-test -Dtarget=wasm32-wasi ${{ env.ZIG_MODE_FLAG }}
wasm3/build/wasm3 zig-out/bin/test.wasm
wasm3/build/wasm3 zig-out/bin/trace_test.wasm
- name: Build.
run: zig build ${{ env.BUILD_CMD }} ${{ env.ZIG_MODE_FLAG }} ${{ env.ZIG_TARGET_FLAG }}
# Remove when zig strip is fixed.
- name: Strip (Linux)
if: env.BUILD_TARGET == 'x86_64-linux-gnu' && env.BUILD_MODE == 'release' && env.BUILD_CMD == 'cli'
run: |
strip zig-out/bin/cyber
# # Don't strip aarch64 since it was already code signed.
# # TODO: Look for way to make zig strip before doing the codesign.
# - name: Strip (macOS)
# if: env.BUILD_TARGET == 'x86_64-macos-none' && env.BUILD_MODE == 'release'
# run: |
# strip zig-out/${{ env.BUILD_TARGET }}/main/main
# # Currently just ad hoc signing.
# # aarch64 build is automatically signed by zig.
# - name: Codesign (macOS)
# if: env.BUILD_TARGET == 'x86_64-macos-none' && env.BUILD_MODE == 'release'
# run: |
# codesign --force --deep -s - zig-out/${{ env.BUILD_TARGET }}/main/main
# - name: Copy binary.
# run: cp
# zig-out/${{ env.BUILD_TARGET }}/main/main${{ env.BIN_EXT }}
# zig-out/${{ env.BUILD_TARGET }}/main/cosmic${{ env.BIN_EXT }}
- name: Zip. (linux/macos)
if: (env.BUILD_HOST == 'ubuntu-22.04' || env.BUILD_HOST == 'macos-12') && env.BUILD_TARGET != 'wasm32-freestanding' && env.BUILD_CMD == 'cli'
run: |
tar -C zig-out/bin -czvf ${{ env.BIN_ZIP }} cyber
- name: Zip. (windows)
if: env.BUILD_TARGET == 'x86_64-windows-gnu' && env.BUILD_CMD == 'cli'
shell: bash
run: |
cd zig-out/bin && 7z a ../../${{env.BIN_ZIP}} cyber.exe
- name: Move. (windows lib)
if: env.BUILD_TARGET == 'x86_64-windows-gnu' && env.BUILD_CMD == 'lib'
run: |
mv zig-out/lib/cyber.lib libcyber-windows-x64.lib
- name: Move. (linux lib)
if: env.BUILD_TARGET == 'x86_64-linux-gnu' && env.BUILD_CMD == 'lib'
run: |
mv zig-out/lib/libcyber.a libcyber-linux-x64.a
- name: Move. (macos lib)
if: env.BUILD_TARGET == 'x86_64-macos-none' && env.BUILD_CMD == 'lib'
run: |
mv zig-out/lib/libcyber.a libcyber-macos-x64.a
- name: Move. (macos lib)
if: env.BUILD_TARGET == 'aarch64-macos-none' && env.BUILD_CMD == 'lib'
run: |
mv zig-out/lib/libcyber.a libcyber-macos-arm64.a
- name: Move. (wasm)
if: env.BUILD_TARGET == 'wasm32-freestanding'
run: |
mv zig-out/lib/cyber-web.wasm ${{ env.BIN_ZIP }}
- name: Save artifact.
if: env.BUILD_CMD == 'cli'
uses: actions/upload-artifact@v2
with:
name: bin
path: |
${{ env.BIN_ZIP }}
- name: Save artifact.
if: env.BUILD_CMD == 'lib'
uses: actions/upload-artifact@v2
with:
name: bin
path: |
libcyber-windows-x64.lib
libcyber-linux-x64.a
libcyber-macos-x64.a
libcyber-macos-arm64.a
cyber-web.wasm
outputs:
short_version: ${{ env.SHORT_VERSION }}
# version: ${{ env.BUILD_VERSION }}
release:
needs: build
name: Release
runs-on: ubuntu-22.04
steps:
- uses: actions/download-artifact@v2
with:
name: bin
# Manual dispatch.
- name: Github Latest Release.
uses: marvinpinto/action-automatic-releases@latest
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
automatic_release_tag: latest
prerelease: false
title: v${{ needs.build.outputs.short_version }}-Latest
files: |
cyber-linux-x64.tar.gz
cyber-selinux-x64.tar.gz
cyber-macos-x64.tar.gz
cyber-macos-arm64.tar.gz
cyber-windows-x64.zip
libcyber-windows-x64.lib
libcyber-linux-x64.a
libcyber-macos-x64.a
libcyber-macos-arm64.a
cyber-web.wasm
# Auto dispatch.
- name: Github Release.
uses: softprops/action-gh-release@v1
# Releases for tags only.
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
cyber-linux-x64.tar.gz
cyber-selinux-x64.tar.gz
cyber-macos-x64.tar.gz
cyber-macos-arm64.tar.gz
cyber-windows-x64.zip
libcyber-windows-x64.lib
libcyber-linux-x64.a
libcyber-macos-x64.a
libcyber-macos-arm64.a
cyber-web.wasm