Skip to content

Commit 5676ef0

Browse files
authored
Switch to node-22 source
1 parent 0f598b5 commit 5676ef0

File tree

14 files changed

+351
-466
lines changed

14 files changed

+351
-466
lines changed

.github/workflows/build.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,40 @@ name: Building V8
55

66
jobs:
77
build:
8-
runs-on: ubuntu-latest
9-
name: ${{ matrix.distro }} / v8-${{ matrix.version }}
8+
runs-on: ubuntu-24.04${{matrix.arch=='arm64' && '-arm' || ''}}
9+
name: ${{ matrix.distro }} / ${{ matrix.arch }}
1010

1111
# V8 version from node-20: https://github.com/nodejs/node/blob/v20.x-staging-backport/deps/v8/include/v8-version.h
1212

1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
distro: [ 'centos-8', 'debian-11', 'debian-11-arm', 'debian-12-libcxx', 'alpine' ]
17-
version: [ '11.9.169.7' ]
16+
distro: [ 'alpine', 'rocky-8', 'debian-11', 'debian-12-libcxx']
17+
arch: [ 'amd64', 'arm64' ]
18+
exclude:
19+
- distro: rocky-8
20+
arch: arm64
1821

1922
steps:
2023
- name: checkout
2124
uses: actions/checkout@v4
2225

2326
- name: build
2427
run: |
25-
docker build --build-arg v8_version=${{ matrix.version }} ${{ matrix.distro }} -t mybuild
28+
docker build ${{ matrix.distro }} -t mybuild
2629
2730
- name: copy
2831
run: |
2932
docker run -d --name myrun mybuild
3033
docker cp myrun:/v8-${{ matrix.version }}-static.tar.xz .
3134
docker stop myrun
32-
mv v8-${{ matrix.version }}-static.tar.xz v8-${{ matrix.version }}-${{ matrix.distro }}.tar.xz
35+
mv v8-${{ matrix.version }}-static.tar.xz v8-${{ matrix.version }}-${{ matrix.distro }}-${{ matrix.arch }}.tar.xz
3336
3437
- name: store
3538
uses: actions/upload-artifact@v4
3639
with:
37-
name: v8-${{ matrix.version }}-${{ matrix.distro }}
38-
path: v8-${{ matrix.version }}-${{ matrix.distro }}.tar.xz
40+
name: v8-${{ matrix.distro }}-${{ matrix.arch }}
41+
path: v8-${{ matrix.distro }}-${{ matrix.arch }}.tar.xz
3942

4043
release:
4144
runs-on: ubuntu-latest

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
# Building V8
22

3-
Some dockerfiles for building libv8 on various platforms. Based on Jan Marvin's [v8-static](https://github.com/JanMarvin/v8-static) script for building V8 on Arch.
3+
Some dockerfiles for building libv8 on various platforms.
44

5-
Run `docker build . -t myv8` in the source dir. If all goes well, the final image has `/v8-{version}.tar.xz` in the root. Use `docker run myv8` and then `docker cp` to copy it to your system.
5+
The releases section in this repository has binaries as built by the GitHub actions CI.
66

7-
## Important notes
7+
## How to use
88

9-
Because depot_tools changes all the time, this will probably only work for recent versions of V8. To build an older V8 version, you may have to add a step to checkout an older version of depot_tools. Suitable dependency versions are storted in the [DEPS](https://github.com/v8/v8/blob/master/DEPS) file in the V8 source tree for the version you are building.
9+
Run `docker build . -t myv8` in any of the source dirs. If all goes well, the final image has `/v8-{version}.tar.xz` in the root. Use `docker run myv8` and then `docker cp` to copy it to your system. Also see the [CI workflow](https://github.com/jeroen/build-v8-static/blob/HEAD/.github/workflows/build.yml) how to do this.
1010

11-
V8 pulls in a custom clang++ compiler at build time, so I think the version of g++ on your system doesn't matter. But it should still be using your system libcxx, which is what is important to use the library in your applications.
11+
## Some notes
12+
13+
Nowadays we use the V8 source code bundled with nodejs, which is more portable and already includes dependencies. However if you want to build from the upstream V8 git repository instead, have a look at the [11.9-final](https://github.com/jeroen/build-v8-static/tree/11.9-final) tag for examples how to do this.
1214

1315
This is a minimal build without internationalization which results in a single "monolith" static library. Tweak the `gn gen` command to enable other features.
1416

15-
Building V8 requires a lot of memory, if you get random failures, docker may be running out of memory or disk space.
17+
Building V8 requires a lot of memory, if you get random failures, docker may be running out of memory or disk space. In this case try chaning the build command to `ninja -j1`.

alpine/55596.diff

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
diff --git a/deps/v8/src/compiler/wasm-compiler.cc b/deps/v8/src/compiler/wasm-compiler.cc
2+
--- a/deps/v8/src/compiler/wasm-compiler.cc 2024-10-28 21:25:11.000000000 -0400
3+
+++ b/deps/v8/src/compiler/wasm-compiler.cc 2024-11-01 02:02:22.554537121 -0400
4+
@@ -8613,11 +8613,13 @@
5+
'-');
6+
7+
auto compile_with_turboshaft = [&]() {
8+
+ wasm::WrapperCompilationInfo ci;
9+
+ ci.code_kind = CodeKind::WASM_TO_JS_FUNCTION;
10+
+ ci.import_info.import_kind = kind;
11+
+ ci.import_info.expected_arity = expected_arity;
12+
+ ci.import_info.suspend = suspend;
13+
return Pipeline::GenerateCodeForWasmNativeStubFromTurboshaft(
14+
- env->module, sig,
15+
- wasm::WrapperCompilationInfo{
16+
- .code_kind = CodeKind::WASM_TO_JS_FUNCTION,
17+
- .import_info = {kind, expected_arity, suspend}},
18+
+ env->module, sig, ci,
19+
func_name, WasmStubAssemblerOptions(), nullptr);
20+
};
21+
auto compile_with_turbofan = [&]() {
22+
@@ -8774,12 +8776,14 @@
23+
base::VectorOf(name_buffer.get(), kMaxNameLen) + kNamePrefixLen, sig);
24+
25+
auto compile_with_turboshaft = [&]() {
26+
+ wasm::WrapperCompilationInfo ci;
27+
+ ci.code_kind = CodeKind::WASM_TO_JS_FUNCTION;
28+
+ ci.import_info.import_kind = kind;
29+
+ ci.import_info.expected_arity = expected_arity;
30+
+ ci.import_info.suspend = suspend;
31+
std::unique_ptr<turboshaft::TurboshaftCompilationJob> job =
32+
Pipeline::NewWasmTurboshaftWrapperCompilationJob(
33+
- isolate, sig,
34+
- wasm::WrapperCompilationInfo{
35+
- .code_kind = CodeKind::WASM_TO_JS_FUNCTION,
36+
- .import_info = {kind, expected_arity, suspend}},
37+
+ isolate, sig, ci,
38+
nullptr, std::move(name_buffer), WasmAssemblerOptions());
39+

alpine/Dockerfile

Lines changed: 55 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,71 @@
1-
# Adapted from: https://github.com/humanmade/alpine-v8
2-
ARG v8_version=11.9.169.7
3-
ARG GN_COMMIT=cc28efe62ef0c2fb32455f414a29c4a55bb7fbc4
1+
FROM alpine:3.16
2+
3+
ARG NODE_VERSION=22.18.0
4+
ARG BUILD_VERSION=bca39698b291b392f0b4336857caf929c603ada3
5+
ARG GN_VERSION=59c4bb920542ee903ee1df39097ae024e2e8226f
6+
7+
ENV GYP_GENERATORS=ninja
8+
ENV pkgdir=/package
49

5-
# STEP 1
6-
# Build GN for alpine
7-
FROM alpine:3.16 as gn-builder
8-
ARG GN_COMMIT
910
RUN \
10-
apk add --update --virtual .gn-build-dependencies alpine-sdk binutils-gold clang curl git llvm13 ninja python3 tar xz && \
11-
PATH=$PATH:/usr/lib/llvm9/bin && \
12-
cp -f /usr/bin/ld.gold /usr/bin/ld && \
13-
git clone https://gn.googlesource.com/gn /tmp/gn && \
14-
git -C /tmp/gn checkout ${GN_COMMIT} && \
15-
cd /tmp/gn && \
11+
apk add --update git alpine-sdk binutils-gold clang curl git llvm13 ninja python3 tar xz glib-dev icu-dev libstdc++ linux-headers make &&\
12+
ln -s /usr/bin/python3 /usr/bin/python
13+
14+
RUN \
15+
git clone https://gn.googlesource.com/gn && \
16+
cd gn && \
17+
git checkout ${GN_VERSION} && \
1618
python3 build/gen.py && \
1719
ninja -C out && \
18-
cp -f /tmp/gn/out/gn /usr/local/bin/gn && \
19-
apk del .gn-build-dependencies && \
20-
rm -rf /tmp/* /var/tmp/* /var/cache/apk/*
20+
cp out/gn /usr/local/bin/gn
2121

22+
RUN \
23+
curl -sSL https://github.com/nodejs/node/archive/refs/tags/v${NODE_VERSION}.tar.gz -o node.tar.gz && \
24+
mkdir -p /v8 &&\
25+
tar xf node.tar.gz -C /v8 --strip-components=3 node-22.18.0/deps/v8
2226

23-
# STEP 2
24-
# Use depot_tools to fetch the V8 source and dependencies
25-
# This requires glibc so we use debian tools
26-
FROM debian:10 as source
27-
ARG v8_version
2827
RUN \
29-
set -x && \
30-
sed -i.bak 's@http://deb.debian.org@http://archive.debian.org@g' /etc/apt/sources.list && \
31-
apt-get update && \
32-
apt-get install -y git curl python3 && \
33-
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git /tmp/depot_tools && \
34-
PATH=$PATH:/tmp/depot_tools && \
35-
cd /tmp && \
36-
fetch --nohooks v8 && \
37-
cd /tmp/v8 && \
38-
gclient sync --nohooks -D --force --reset && \
39-
gclient sync --revision ${v8_version} && \
40-
apt-get remove --purge -y git curl python3 && \
41-
apt-get autoremove -y && \
42-
rm -rf /var/lib/apt/lists/*
28+
git clone https://chromium.googlesource.com/chromium/src/build.git /build &&\
29+
git -C /build checkout ${BUILD_VERSION} &&\
30+
rm -Rf /v8/build &&\
31+
ln -sf /build /v8/build
4332

33+
RUN \
34+
echo "checkout_google_benchmark = false" > /v8/build/config/gclient_args.gni
4435

45-
# STEP 3
46-
# Build V8 for alpine
47-
FROM alpine:3.16 as v8
48-
COPY --from=source /tmp/v8 /tmp/v8
49-
COPY --from=gn-builder /usr/local/bin/gn /tmp/v8/buildtools/linux64/gn
5036
RUN \
51-
apk add --update --virtual .v8-build-dependencies curl g++ gcc glib-dev icu-dev libstdc++ linux-headers make ninja python3 tar xz && \
52-
ln -s /usr/bin/python3 /usr/bin/python && \
53-
cd /tmp/v8 && \
54-
./tools/dev/v8gen.py x64.release -- \
55-
binutils_path=\"/usr/bin\" \
56-
target_os=\"linux\" \
57-
target_cpu=\"x64\" \
58-
v8_target_cpu=\"x64\" \
59-
v8_enable_future=true \
60-
is_official_build=false \
61-
is_cfi=false \
62-
is_clang=false \
63-
is_debug=false \
64-
use_custom_libcxx=false \
65-
use_sysroot=false \
66-
use_gold=false \
67-
use_allocator_shim=false \
68-
treat_warnings_as_errors=false \
69-
symbol_level=0 \
70-
strip_debug_info=true \
71-
v8_monolithic=true \
72-
v8_use_external_startup_data=false \
73-
v8_enable_i18n_support=false \
74-
v8_enable_gdbjit=false \
75-
v8_static_library=true \
76-
v8_experimental_extra_library_files=[] \
77-
v8_extra_library_files=[] && \
78-
ninja -C out.gn/x64.release -j $(getconf _NPROCESSORS_ONLN) "v8_monolith" "d8" && \
79-
find /tmp/v8/out.gn/x64.release -name '*.a'
37+
cd /usr/bin &&\
38+
ln -s g++ $(uname -m)-linux-gnu-g++ &&\
39+
ln -s gcc $(uname -m)-linux-gnu-gcc &&\
40+
ln -s ar $(uname -m)-linux-gnu-ar
41+
42+
# Patch from https://github.com/nodejs/node/issues/55596
43+
COPY 55596.diff /tmp/55596.diff
44+
RUN patch -p2 -i /tmp/55596.diff
45+
46+
RUN cd /v8 &&\
47+
gn gen v8.static -vv --fail-on-unused-args \
48+
--args='v8_monolithic=true \
49+
v8_static_library=true \
50+
v8_enable_sandbox=false \
51+
is_clang=false \
52+
is_asan=false \
53+
use_gold=false \
54+
is_debug=false \
55+
is_official_build=false \
56+
treat_warnings_as_errors=false \
57+
clang_use_chrome_plugins=false \
58+
v8_enable_i18n_support=false \
59+
v8_use_external_startup_data=false \
60+
use_custom_libcxx=false \
61+
use_sysroot=false'
62+
63+
RUN cd /v8 && ninja -C v8.static -j2 "v8_monolith" "d8"
8064

81-
# STEP 4
82-
# Create package archive
83-
ARG v8_version
84-
ENV pkgdir /package
85-
RUN cd /tmp/v8 && \
65+
RUN cd /v8 &&\
8666
install -d ${pkgdir}v8 && \
8767
install -d ${pkgdir}/v8/lib && \
88-
install -Dm755 out.gn/x64.release/obj/libv8_monolith.a ${pkgdir}/v8/lib/libv8_monolith.a && \
68+
install -Dm755 v8.static/obj/libv8_monolith.a ${pkgdir}/v8/lib/libv8_monolith.a && \
8969
install -d ${pkgdir}/v8/include && \
9070
install -Dm644 include/*.h ${pkgdir}/v8/include && \
9171
install -d ${pkgdir}/v8/include/cppgc && \

centos-8/Dockerfile

Lines changed: 0 additions & 56 deletions
This file was deleted.

debian-11-arm/Dockerfile

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)