Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 7 additions & 126 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:
- "**"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

permissions:
contents: write
Expand All @@ -16,69 +18,7 @@ env:
LP_CACHE: ".lp-cache"

jobs:
build-x86_64-linux:
env:
OS: linux
ARCH: x86_64

runs-on: ubuntu-22.04
steps:
- uses: mlugg/setup-zig@v2.0.5
with:
version: ${{ env.ZIG_VERSION }}
cache-key: ${{ env.ZIG_VERSION }}-${{ env.OS }}-${{ env.ARCH }}

- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0

- run: zig env

- run: |
sudo apt-get update
sudo apt-get install -yq libglib2.0-dev

- run: zig build -Doptimize=ReleaseSafe build-v8
- run: mv ${{ env.LP_CACHE }}/v8-${{ env.V8_REVISION }}/out/${{ env.OS }}/release/obj/zig/libc_v8.a libc_v8_${{ env.V8_REVISION }}_${{ env.OS }}_${{ env.ARCH }}.a

- name: Upload the build
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: libc_v8_${{ env.V8_REVISION }}_${{ env.OS }}_${{ env.ARCH }}.a

build-aarch64-macos:
env:
OS: macos
ARCH: aarch64

runs-on: macos-latest
steps:
- uses: mlugg/setup-zig@v2
with:
version: ${{ env.ZIG_VERSION }}
cache-key: ${{ env.ZIG_VERSION }}-${{ env.OS }}-${{ env.ARCH }}

- uses: actions/setup-python@v5
with:
python-version: '3.11'

- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0

- run: zig build -Doptimize=ReleaseSafe build-v8
- run: mv ${{ env.LP_CACHE }}/v8-${{ env.V8_REVISION }}/out/${{ env.OS }}/release/obj/zig/libc_v8.a libc_v8_${{ env.V8_REVISION }}_${{ env.OS }}_${{ env.ARCH }}.a

- name: Upload the build
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: libc_v8_${{ env.V8_REVISION }}_${{ env.OS }}_${{ env.ARCH }}.a

build-arm64-linux:
build-arm64-linux-page64k:
env:
OS: linux
ARCH: aarch64
Expand All @@ -104,71 +44,12 @@ jobs:
sudo ln -nsf /usr/lib/llvm-21/lib/clang/21/lib/linux/libclang_rt.builtins-aarch64.a /usr/lib/llvm-21/lib/clang/21/lib/linux/libclang_rt.builtins.a && \
sudo ln -nsf /usr/lib/llvm-21/lib/clang/21/lib/linux/ /usr/lib/llvm-21/lib/clang/21/lib/aarch64-unknown-linux-gnu

- run: zig build -Doptimize=ReleaseSafe build-v8
- run: mv ${{ env.LP_CACHE }}/v8-${{ env.V8_REVISION }}/out/${{ env.OS }}/release/obj/zig/libc_v8.a libc_v8_${{ env.V8_REVISION }}_${{ env.OS }}_${{ env.ARCH }}.a

- name: Upload the build
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: libc_v8_${{ env.V8_REVISION }}_${{ env.OS }}_${{ env.ARCH }}.a

build-x86_64-macos:
env:
OS: macos
ARCH: x86_64

runs-on: macos-15-large
steps:
- uses: mlugg/setup-zig@v2
with:
version: ${{ env.ZIG_VERSION }}
cache-key: ${{ env.ZIG_VERSION }}-${{ env.OS }}-${{ env.ARCH }}

- uses: actions/setup-python@v5
with:
python-version: '3.11'

- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0

- run: zig build -Doptimize=ReleaseSafe build-v8
- run: mv ${{ env.LP_CACHE }}/v8-${{ env.V8_REVISION }}/out/${{ env.OS }}/release/obj/zig/libc_v8.a libc_v8_${{ env.V8_REVISION }}_${{ env.OS }}_${{ env.ARCH }}.a

- name: Upload the build
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: libc_v8_${{ env.V8_REVISION }}_${{ env.OS }}_${{ env.ARCH }}.a

build-aarch64-ios:
env:
OS: ios
ARCH: aarch64
TARGET_ENVIRONMENT: simulator

runs-on: macos-latest
steps:
- uses: mlugg/setup-zig@v2
with:
version: ${{ env.ZIG_VERSION }}
cache-key: ${{ env.ZIG_VERSION }}-${{ env.OS }}-${{ env.ARCH }}
- uses: actions/setup-python@v5
with:
python-version: '3.11'

- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0

- run: zig build -Doptimize=ReleaseSafe build-v8
- run: mv ${{ env.LP_CACHE }}/v8-${{ env.V8_REVISION }}/out/${{ env.OS }}/release/obj/zig/libc_v8.a libc_v8_${{ env.V8_REVISION }}_${{ env.OS }}_${{ env.ARCH }}.a
- run: zig build -Doptimize=ReleaseSafe -Dpages_64k=true build-v8
- run: mv ${{ env.LP_CACHE }}/v8-${{ env.V8_REVISION }}/out/${{ env.OS }}/release/obj/zig/libc_v8.a libc_v8_${{ env.V8_REVISION }}_${{ env.OS }}_${{ env.ARCH }}_pages64k.a

- name: Upload the build
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: libc_v8_${{ env.V8_REVISION }}_${{ env.OS }}_${{ env.TARGET_ENVIRONMENT }}_${{ env.ARCH }}.a
artifacts: libc_v8_${{ env.V8_REVISION }}_${{ env.OS }}_${{ env.ARCH }}_pages64k.a
tag: v0.2.5
18 changes: 17 additions & 1 deletion build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ pub fn build(b: *std.Build) !void {
try std.fs.cwd().makeDir(cache_root);
};

const pages_64k = b.option(bool, "pages_64k", "Enable Linux ARM 64K pages compatibility, only for Linux ARM") orelse false;

const prebuilt_v8_path = b.option([]const u8, "prebuilt_v8_path", "Path to prebuilt libc_v8.a");

const v8_dir = b.fmt("{s}/v8-{s}", .{ cache_root, V8_VERSION });
Expand All @@ -46,7 +48,9 @@ pub fn build(b: *std.Build) !void {
prepare_step.dependOn(&bootstrapped_v8.step);

// Otherwise, go through build process.
break :blk try buildV8(b, v8_dir, depot_tools_dir, bootstrapped_v8, target, optimize);
break :blk try buildV8(b, v8_dir, depot_tools_dir, bootstrapped_v8, target, optimize, .{
.pages_64k = pages_64k,
});
};

const build_step = b.step("build-v8", "Build v8");
Expand Down Expand Up @@ -322,13 +326,19 @@ fn bootstrapV8(
return create_marker;
}

const Config = struct {
// Enable build compatible with 64k page linux.
pages_64k: bool,
};

fn buildV8(
b: *std.Build,
v8_dir: []const u8,
depot_tools_dir: []const u8,
bootstrapped_v8: *std.Build.Step.Run,
target: std.Build.ResolvedTarget,
optimize: std.builtin.OptimizeMode,
config: Config,
) !*std.Build.Step.WriteFile {
const v8_dir_lazy_path: LazyPath = .{ .cwd_relative = v8_dir };

Expand Down Expand Up @@ -368,6 +378,12 @@ fn buildV8(
else => {},
}

if (config.pages_64k) {
// Works only with linux aarch64 build.
std.debug.assert(tag == .linux and arch == .aarch64);
try gn_args.appendSlice(allocator, "v8_enable_pointer_compression=false\n");
}

const out_dir = b.fmt("out/{s}/{s}", .{ @tagName(tag), if (is_debug) "debug" else "release" });

const gn_run = b.addSystemCommand(&.{
Expand Down