Skip to content

add bytecode-compilers.yml workflow#44

Merged
ammarahm-ed merged 1 commit into
mainfrom
feat-bc-compiler
Jul 14, 2026
Merged

add bytecode-compilers.yml workflow#44
ammarahm-ed merged 1 commit into
mainfrom
feat-bc-compiler

Conversation

@ammarahm-ed

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings July 14, 2026 04:44
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6f2152cb-b21f-494c-9312-7ec6f1305074

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat-bc-compiler

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ammarahm-ed ammarahm-ed changed the title add bytecode-compiler.yml workflow add bytecode-compilers.yml workflow Jul 14, 2026
@ammarahm-ed ammarahm-ed merged commit 8a6cae0 into main Jul 14, 2026
5 checks passed
Comment on lines +48 to +111
name: hermes (${{ matrix.host }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- { host: linux-x64, runner: ubuntu-24.04 }
- { host: linux-arm64, runner: ubuntu-24.04-arm }
- { host: darwin-x64, runner: macos-13 }
- { host: darwin-arm64, runner: macos-14 }
- { host: win32-x64, runner: windows-2022 }
- { host: win32-arm64, runner: windows-11-arm }
steps:
- name: Install toolchain (Linux)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y cmake ninja-build build-essential python3
- name: Install toolchain (macOS)
if: runner.os == 'macOS'
run: brew install cmake ninja
- name: Install toolchain (Windows)
if: runner.os == 'Windows'
run: choco install ninja -y

- name: Clone Hermes
shell: bash
run: git clone --depth 1 --branch "${{ github.event.inputs.hermes_ref || 'master' }}" "$HERMES_REPO" hermes

- name: Build hermesc (Unix)
if: runner.os != 'Windows'
shell: bash
run: |
set -euxo pipefail
cmake -S hermes -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DHERMES_BUILD_APPLE_FRAMEWORK=OFF
cmake --build build --target hermesc

- name: Build hermesc (Windows)
if: runner.os == 'Windows'
shell: bash
run: |
set -euxo pipefail
# Use the default (Visual Studio) generator; Ninja+MSVC also works if the
# VS dev environment is on PATH.
cmake -S hermes -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --target hermesc --config Release

- name: Stage binary
shell: bash
run: |
set -euxo pipefail
mkdir -p "out/hermes/${{ matrix.host }}"
bin="$(find build -type f \( -name hermesc -o -name hermesc.exe \) | head -n1)"
test -n "$bin"
cp "$bin" "out/hermes/${{ matrix.host }}/"

- uses: actions/upload-artifact@v4
with:
name: bytecode-compiler-hermes-${{ matrix.host }}
path: out/hermes/${{ matrix.host }}
if-no-files-found: error

# ---------------------------------------------------------------------------
# QuickJS (bellard) — build the engine lib, then our blob-emitting shim.
# ---------------------------------------------------------------------------
quickjs:
Comment on lines +112 to +163
name: quickjs (${{ matrix.host }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- { host: linux-x64, runner: ubuntu-24.04 }
- { host: linux-arm64, runner: ubuntu-24.04-arm }
- { host: darwin-x64, runner: macos-13 }
- { host: darwin-arm64, runner: macos-14 }
- { host: win32-x64, runner: windows-2022 }
- { host: win32-arm64, runner: windows-11-arm }
steps:
- uses: actions/checkout@v4
- name: Install toolchain (Linux)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y build-essential
- name: Install toolchain (Windows)
if: runner.os == 'Windows'
run: choco install llvm -y

- name: Clone QuickJS
shell: bash
run: git clone --depth 1 --branch "${{ github.event.inputs.quickjs_ref || 'master' }}" "$QUICKJS_REPO" quickjs

- name: Build shim
shell: bash
env:
SHIM: ${{ github.workspace }}/tools/bytecode-compiler/native/qjs-compile.c
run: |
set -euxo pipefail
cd quickjs
CC="cc"; [ "${{ runner.os }}" = "Windows" ] && CC="clang"
# Compile the lib sources directly (avoids qjs/qjsc main() collisions).
# If bellard changes the source set, adjust this list.
libsrc="quickjs.c cutils.c libregexp.c libunicode.c"
[ -f dtoa.c ] && libsrc="$libsrc dtoa.c"
out="../out/quickjs/${{ matrix.host }}"; mkdir -p "$out"
bin="$out/nsbc-quickjs"; [ "${{ runner.os }}" = "Windows" ] && bin="$bin.exe"
$CC -O2 -DNSBC_MAGIC='"NSBCQJS"' -I. -o "$bin" "$SHIM" $libsrc -lm
"$bin" || true # usage line (exit 2) proves it links & runs

- uses: actions/upload-artifact@v4
with:
name: bytecode-compiler-quickjs-${{ matrix.host }}
path: out/quickjs/${{ matrix.host }}
if-no-files-found: error

# ---------------------------------------------------------------------------
# QuickJS-NG — CMake build of libqjs, then our shim (same JS_* API).
# ---------------------------------------------------------------------------
quickjs-ng:
Comment on lines +164 to +221
name: quickjs-ng (${{ matrix.host }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- { host: linux-x64, runner: ubuntu-24.04 }
- { host: linux-arm64, runner: ubuntu-24.04-arm }
- { host: darwin-x64, runner: macos-13 }
- { host: darwin-arm64, runner: macos-14 }
- { host: win32-x64, runner: windows-2022 }
- { host: win32-arm64, runner: windows-11-arm }
steps:
- uses: actions/checkout@v4
- name: Install toolchain (Linux)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y cmake ninja-build build-essential
- name: Install toolchain (macOS)
if: runner.os == 'macOS'
run: brew install cmake ninja
- name: Install toolchain (Windows)
if: runner.os == 'Windows'
run: choco install ninja llvm -y

- name: Clone QuickJS-NG
shell: bash
run: git clone --depth 1 --branch "${{ github.event.inputs.quickjs_ng_ref || 'master' }}" "$QUICKJS_NG_REPO" quickjs-ng

- name: Build lib + shim
shell: bash
env:
SHIM: ${{ github.workspace }}/tools/bytecode-compiler/native/qjs-compile.c
run: |
set -euxo pipefail
cmake -S quickjs-ng -B quickjs-ng/build -DCMAKE_BUILD_TYPE=Release -DBUILD_QJS_LIBC=OFF
cmake --build quickjs-ng/build --config Release
lib="$(find quickjs-ng/build -type f \( -name 'libqjs.a' -o -name 'qjs.lib' \) | head -n1)"
test -n "$lib"
CC="cc"; [ "${{ runner.os }}" = "Windows" ] && CC="clang"
out="out/quickjs-ng/${{ matrix.host }}"; mkdir -p "$out"
bin="$out/nsbc-quickjs-ng"; [ "${{ runner.os }}" = "Windows" ] && bin="$bin.exe"
$CC -O2 -DNSBC_MAGIC='"NSBCNGS"' -I quickjs-ng -o "$bin" "$SHIM" "$lib" -lm
"$bin" || true

- uses: actions/upload-artifact@v4
with:
name: bytecode-compiler-quickjs-ng-${{ matrix.host }}
path: out/quickjs-ng/${{ matrix.host }}
if-no-files-found: error

# ---------------------------------------------------------------------------
# PrimJS — build the engine, then our LEPUS_* shim.
# NOTE: PrimJS's build system is nonstandard; the steps below are best-effort
# and will very likely need adjustment against lynx-family/primjs@develop
# (its actual CMake targets / include + lib paths). Treat the first CI run as
# the source of truth and pin once green.
# ---------------------------------------------------------------------------
primjs:
Comment on lines +222 to +277
name: primjs (${{ matrix.host }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- { host: linux-x64, runner: ubuntu-24.04 }
- { host: linux-arm64, runner: ubuntu-24.04-arm }
- { host: darwin-x64, runner: macos-13 }
- { host: darwin-arm64, runner: macos-14 }
- { host: win32-x64, runner: windows-2022 }
- { host: win32-arm64, runner: windows-11-arm }
steps:
- uses: actions/checkout@v4
- name: Install toolchain (Linux)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y cmake ninja-build build-essential python3
- name: Install toolchain (macOS)
if: runner.os == 'macOS'
run: brew install cmake ninja
- name: Install toolchain (Windows)
if: runner.os == 'Windows'
run: choco install ninja llvm -y

- name: Clone PrimJS
shell: bash
run: |
git clone --depth 1 --branch "${{ github.event.inputs.primjs_ref || 'develop' }}" "$PRIMJS_REPO" primjs
# PrimJS vendors deps via a script in some layouts; run it if present.
if [ -f primjs/tools/hooks/generate_gni.py ]; then python3 primjs/tools/hooks/generate_gni.py || true; fi

- name: Build engine + shim
shell: bash
env:
SHIM: ${{ github.workspace }}/tools/bytecode-compiler/native/primjs-compile.c
run: |
set -euxo pipefail
# Best-effort CMake build of the PrimJS/quickjs static lib. Adjust the
# target and include/lib paths to match the repo once observed in CI.
cmake -S primjs -B primjs/build -DCMAKE_BUILD_TYPE=Release || {
echo "::warning::PrimJS cmake configure needs adjustment for this repo layout"; exit 1; }
cmake --build primjs/build --config Release
lib="$(find primjs/build -type f \( -name 'libquick*.a' -o -name 'libprimjs*.a' -o -name '*.lib' \) | head -n1)"
inc="$(dirname "$(find primjs -name quickjs.h | head -n1)")"
test -n "$lib" && test -n "$inc"
CC="cc"; [ "${{ runner.os }}" = "Windows" ] && CC="clang"
out="out/primjs/${{ matrix.host }}"; mkdir -p "$out"
bin="$out/nsbc-primjs"; [ "${{ runner.os }}" = "Windows" ] && bin="$bin.exe"
$CC -O2 -I"$inc" -o "$bin" "$SHIM" "$lib" -lm
"$bin" || true

- uses: actions/upload-artifact@v4
with:
name: bytecode-compiler-primjs-${{ matrix.host }}
path: out/primjs/${{ matrix.host }}
if-no-files-found: error

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new GitHub Actions workflow intended to build and publish per-host bytecode compiler CLI artifacts for multiple JS engines (Hermes, QuickJS, QuickJS-NG, PrimJS), to support ahead-of-time bytecode generation compatible with the runtime’s shipped engine libraries.

Changes:

  • Introduces .github/workflows/bytecode-compilers.yml with a multi-engine, multi-host build matrix.
  • Clones upstream engine repositories and builds/packaging artifacts via actions/upload-artifact@v4.
  • Defines workflow-dispatch inputs to pin engine revisions for bytecode compatibility.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +137 to +141
- name: Build shim
shell: bash
env:
SHIM: ${{ github.workspace }}/tools/bytecode-compiler/native/qjs-compile.c
run: |
Comment on lines +192 to +196
- name: Build lib + shim
shell: bash
env:
SHIM: ${{ github.workspace }}/tools/bytecode-compiler/native/qjs-compile.c
run: |
Comment on lines +253 to +257
- name: Build engine + shim
shell: bash
env:
SHIM: ${{ github.workspace }}/tools/bytecode-compiler/native/primjs-compile.c
run: |

- name: Clone Hermes
shell: bash
run: git clone --depth 1 --branch "${{ github.event.inputs.hermes_ref || 'master' }}" "$HERMES_REPO" hermes

- name: Clone QuickJS
shell: bash
run: git clone --depth 1 --branch "${{ github.event.inputs.quickjs_ref || 'master' }}" "$QUICKJS_REPO" quickjs
- uses: actions/upload-artifact@v4
with:
name: bytecode-compiler-quickjs-ng-${{ matrix.host }}
path: out/quickjs-ng/${{ matrix.host }}
- uses: actions/upload-artifact@v4
with:
name: bytecode-compiler-primjs-${{ matrix.host }}
path: out/primjs/${{ matrix.host }}
[ -f dtoa.c ] && libsrc="$libsrc dtoa.c"
out="../out/quickjs/${{ matrix.host }}"; mkdir -p "$out"
bin="$out/nsbc-quickjs"; [ "${{ runner.os }}" = "Windows" ] && bin="$bin.exe"
$CC -O2 -DNSBC_MAGIC='"NSBCQJS"' -I. -o "$bin" "$SHIM" $libsrc -lm
CC="cc"; [ "${{ runner.os }}" = "Windows" ] && CC="clang"
out="out/quickjs-ng/${{ matrix.host }}"; mkdir -p "$out"
bin="$out/nsbc-quickjs-ng"; [ "${{ runner.os }}" = "Windows" ] && bin="$bin.exe"
$CC -O2 -DNSBC_MAGIC='"NSBCNGS"' -I quickjs-ng -o "$bin" "$SHIM" "$lib" -lm
CC="cc"; [ "${{ runner.os }}" = "Windows" ] && CC="clang"
out="out/primjs/${{ matrix.host }}"; mkdir -p "$out"
bin="$out/nsbc-primjs"; [ "${{ runner.os }}" = "Windows" ] && bin="$bin.exe"
$CC -O2 -I"$inc" -o "$bin" "$SHIM" "$lib" -lm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants