From e642c85ebd724918c972a3043c8e7260735af52b Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Wed, 7 Jan 2026 17:03:07 +0100 Subject: [PATCH 1/4] use ReleaseFast build --- .github/workflows/build.yml | 8 ++++---- Makefile | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3ef3a04f..3c45cce7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,7 +39,7 @@ jobs: mode: 'release' - name: zig build - run: zig build -Dprebuilt_v8_path=v8/libc_v8.a -Doptimize=ReleaseSafe -Dcpu=x86_64 -Dgit_commit=$(git rev-parse --short ${{ github.sha }}) + run: zig build -Dprebuilt_v8_path=v8/libc_v8.a -Doptimize=ReleaseFast -Dcpu=x86_64 -Dgit_commit=$(git rev-parse --short ${{ github.sha }}) - name: Rename binary run: mv zig-out/bin/lightpanda lightpanda-${{ env.ARCH }}-${{ env.OS }} @@ -78,7 +78,7 @@ jobs: mode: 'release' - name: zig build - run: zig build -Dprebuilt_v8_path=v8/libc_v8.a -Doptimize=ReleaseSafe -Dcpu=generic -Dgit_commit=$(git rev-parse --short ${{ github.sha }}) + run: zig build -Dprebuilt_v8_path=v8/libc_v8.a -Doptimize=ReleaseFast -Dcpu=generic -Dgit_commit=$(git rev-parse --short ${{ github.sha }}) - name: Rename binary run: mv zig-out/bin/lightpanda lightpanda-${{ env.ARCH }}-${{ env.OS }} @@ -119,7 +119,7 @@ jobs: mode: 'release' - name: zig build - run: zig build -Dprebuilt_v8_path=v8/libc_v8.a -Doptimize=ReleaseSafe -Dgit_commit=$(git rev-parse --short ${{ github.sha }}) + run: zig build -Dprebuilt_v8_path=v8/libc_v8.a -Doptimize=ReleaseFast -Dgit_commit=$(git rev-parse --short ${{ github.sha }}) - name: Rename binary run: mv zig-out/bin/lightpanda lightpanda-${{ env.ARCH }}-${{ env.OS }} @@ -158,7 +158,7 @@ jobs: mode: 'release' - name: zig build - run: zig build -Dprebuilt_v8_path=v8/libc_v8.a -Doptimize=ReleaseSafe -Dgit_commit=$(git rev-parse --short ${{ github.sha }}) + run: zig build -Dprebuilt_v8_path=v8/libc_v8.a -Doptimize=ReleaseFast -Dgit_commit=$(git rev-parse --short ${{ github.sha }}) - name: Rename binary run: mv zig-out/bin/lightpanda lightpanda-${{ env.ARCH }}-${{ env.OS }} diff --git a/Makefile b/Makefile index 7404367f..813eaffd 100644 --- a/Makefile +++ b/Makefile @@ -49,10 +49,10 @@ help: # ------------ .PHONY: build build-dev run run-release shell test bench wpt data end2end -## Build in release-safe mode +## Build in release-fast mode build: @printf "\033[36mBuilding (release safe)...\033[0m\n" - @$(ZIG) build -Doptimize=ReleaseSafe -Dgit_commit=$$(git rev-parse --short HEAD) || (printf "\033[33mBuild ERROR\033[0m\n"; exit 1;) + @$(ZIG) build -Doptimize=ReleaseFast -Dgit_commit=$$(git rev-parse --short HEAD) || (printf "\033[33mBuild ERROR\033[0m\n"; exit 1;) @printf "\033[33mBuild OK\033[0m\n" ## Build in debug mode From d5f4ca15ccdbcbe5d15b14cdfe1c210e1338bd7c Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Wed, 7 Jan 2026 17:14:15 +0100 Subject: [PATCH 2/4] add v8 snapshot in build processes --- .github/workflows/build.yml | 20 ++++++++++++++++---- Dockerfile | 10 +++++++++- Makefile | 12 +++++++++--- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3c45cce7..d940c9d6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -38,8 +38,11 @@ jobs: arch: ${{env.ARCH}} mode: 'release' + - name: v8 snapshot + run: zig build -Dprebuilt_v8_path=v8/libc_v8.a -Doptimize=ReleaseFast snapshot_creator -- src/snapshot.bin + - name: zig build - run: zig build -Dprebuilt_v8_path=v8/libc_v8.a -Doptimize=ReleaseFast -Dcpu=x86_64 -Dgit_commit=$(git rev-parse --short ${{ github.sha }}) + run: zig build -Dsnapshot_path=../../snapshot.bin -Dprebuilt_v8_path=v8/libc_v8.a -Doptimize=ReleaseFast -Dcpu=x86_64 -Dgit_commit=$(git rev-parse --short ${{ github.sha }}) - name: Rename binary run: mv zig-out/bin/lightpanda lightpanda-${{ env.ARCH }}-${{ env.OS }} @@ -77,8 +80,11 @@ jobs: arch: ${{env.ARCH}} mode: 'release' + - name: v8 snapshot + run: zig build -Dprebuilt_v8_path=v8/libc_v8.a -Doptimize=ReleaseFast snapshot_creator -- src/snapshot.bin + - name: zig build - run: zig build -Dprebuilt_v8_path=v8/libc_v8.a -Doptimize=ReleaseFast -Dcpu=generic -Dgit_commit=$(git rev-parse --short ${{ github.sha }}) + run: zig build -Dsnapshot_path=../../snapshot.bin -Dprebuilt_v8_path=v8/libc_v8.a -Doptimize=ReleaseFast -Dcpu=generic -Dgit_commit=$(git rev-parse --short ${{ github.sha }}) - name: Rename binary run: mv zig-out/bin/lightpanda lightpanda-${{ env.ARCH }}-${{ env.OS }} @@ -118,8 +124,11 @@ jobs: arch: ${{env.ARCH}} mode: 'release' + - name: v8 snapshot + run: zig build -Dprebuilt_v8_path=v8/libc_v8.a -Doptimize=ReleaseFast snapshot_creator -- src/snapshot.bin + - name: zig build - run: zig build -Dprebuilt_v8_path=v8/libc_v8.a -Doptimize=ReleaseFast -Dgit_commit=$(git rev-parse --short ${{ github.sha }}) + run: zig build -Dsnapshot_path=../../snapshot.bin -Dprebuilt_v8_path=v8/libc_v8.a -Doptimize=ReleaseFast -Dgit_commit=$(git rev-parse --short ${{ github.sha }}) - name: Rename binary run: mv zig-out/bin/lightpanda lightpanda-${{ env.ARCH }}-${{ env.OS }} @@ -157,8 +166,11 @@ jobs: arch: ${{env.ARCH}} mode: 'release' + - name: v8 snapshot + run: zig build -Dprebuilt_v8_path=v8/libc_v8.a -Doptimize=ReleaseFast snapshot_creator -- src/snapshot.bin + - name: zig build - run: zig build -Dprebuilt_v8_path=v8/libc_v8.a -Doptimize=ReleaseFast -Dgit_commit=$(git rev-parse --short ${{ github.sha }}) + run: zig build -Dsnapshot_path=../../snapshot.bin -Dprebuilt_v8_path=v8/libc_v8.a -Doptimize=ReleaseFast -Dgit_commit=$(git rev-parse --short ${{ github.sha }}) - name: Rename binary run: mv zig-out/bin/lightpanda lightpanda-${{ env.ARCH }}-${{ env.OS }} diff --git a/Dockerfile b/Dockerfile index 516c3856..e064621e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -48,8 +48,16 @@ RUN case $TARGETPLATFORM in \ mkdir -p v8/ && \ mv libc_v8.a v8/libc_v8.a +# build v8 snapshot +RUN zig build -Doptimize=ReleaseFast \ + -Dprebuilt_v8_path=v8/libc_v8.a \ + snapshot_creator -- src/snapshot.bin + # build release -RUN zig build -Doptimize=ReleaseFast -Dprebuilt_v8_path=v8/libc_v8.a -Dgit_commit=$(git rev-parse --short HEAD) +RUN zig build -Doptimize=ReleaseFast \ + -Dsnapshot_path=../../snapshot.bin \ + -Dprebuilt_v8_path=v8/libc_v8.a \ + -Dgit_commit=$(git rev-parse --short HEAD) FROM debian:stable-slim diff --git a/Makefile b/Makefile index 813eaffd..8adfa092 100644 --- a/Makefile +++ b/Makefile @@ -47,12 +47,18 @@ help: # $(ZIG) commands # ------------ -.PHONY: build build-dev run run-release shell test bench wpt data end2end +.PHONY: build build-v8-snapshot build-dev run run-release shell test bench wpt data end2end + +## Build v8 snapshot +build-v8-snapshot: + @printf "\033[36mBuilding v8 snapshot (release safe)...\033[0m\n" + @$(ZIG) build -Doptimize=ReleaseFast snapshot_creator -- src/snapshot.bin || (printf "\033[33mBuild ERROR\033[0m\n"; exit 1;) + @printf "\033[33mBuild OK\033[0m\n" ## Build in release-fast mode -build: +build: build-v8-snapshot @printf "\033[36mBuilding (release safe)...\033[0m\n" - @$(ZIG) build -Doptimize=ReleaseFast -Dgit_commit=$$(git rev-parse --short HEAD) || (printf "\033[33mBuild ERROR\033[0m\n"; exit 1;) + @$(ZIG) build -Doptimize=ReleaseFast -Dsnapshot_path=../../snapshot.bin -Dgit_commit=$$(git rev-parse --short HEAD) || (printf "\033[33mBuild ERROR\033[0m\n"; exit 1;) @printf "\033[33mBuild OK\033[0m\n" ## Build in debug mode From d4807df2e9277f3ea5aac8b982af5e114d06f912 Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Wed, 7 Jan 2026 17:21:44 +0100 Subject: [PATCH 3/4] add v8 snapshot instructions into the README --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index a854ad00..478a28ed 100644 --- a/README.md +++ b/README.md @@ -211,6 +211,23 @@ env. But you can directly use the zig command: `zig build run`. +#### Embed v8 snapshot + +Lighpanda uses v8 snapshot. By default, it is created on startup but you can +embed it by using the following commands: + +Generate the snapshot. +``` +zig build snapshot_creator -- src/snapshot.bin +``` + +Build using the snapshot binary. +``` +zig build -Dsnapshot_path=../../snapshot.bin +``` + +See [#1279](https://github.com/lightpanda-io/browser/pull/1279) for more details. + ## Test ### Unit Tests From 2abc4907322cce7fc62074de6173ddb085b38f05 Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Wed, 7 Jan 2026 21:11:20 +0100 Subject: [PATCH 4/4] ci: support build on tag push --- .github/workflows/build.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d940c9d6..d461fd82 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,8 +5,12 @@ env: AWS_SECRET_ACCESS_KEY: ${{ secrets.NIGHTLY_BUILD_AWS_SECRET_ACCESS_KEY }} AWS_BUCKET: ${{ vars.NIGHTLY_BUILD_AWS_BUCKET }} AWS_REGION: ${{ vars.NIGHTLY_BUILD_AWS_REGION }} + RELEASE: ${{ github.ref_type == 'tag' && github.ref_name || 'nightly' }} on: + push: + tags: + - '*' schedule: - cron: "2 2 * * *" @@ -57,7 +61,7 @@ jobs: with: allowUpdates: true artifacts: lightpanda-${{ env.ARCH }}-${{ env.OS }} - tag: nightly + tag: ${{ env.RELEASE }} build-linux-aarch64: env: @@ -99,7 +103,7 @@ jobs: with: allowUpdates: true artifacts: lightpanda-${{ env.ARCH }}-${{ env.OS }} - tag: nightly + tag: ${{ env.RELEASE }} build-macos-aarch64: env: @@ -143,7 +147,7 @@ jobs: with: allowUpdates: true artifacts: lightpanda-${{ env.ARCH }}-${{ env.OS }} - tag: nightly + tag: ${{ env.RELEASE }} build-macos-x86_64: env: @@ -185,4 +189,4 @@ jobs: with: allowUpdates: true artifacts: lightpanda-${{ env.ARCH }}-${{ env.OS }} - tag: nightly + tag: ${{ env.RELEASE }}