Skip to content

Commit e58a792

Browse files
Upgrade V8 binaries for 13.1.201.19 version
- Use the v8 compilation pipeline from https://github.com/kuoruan/libv8 - Fix issues with v8go compatibility and changes in the V8 api
1 parent cee5f84 commit e58a792

File tree

112 files changed

+6845
-2189
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+6845
-2189
lines changed

.devcontainer/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FROM --platform=linux/amd64 mcr.microsoft.com/devcontainers/go:1-1.22-bookworm

.devcontainer/devcontainer.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "Go",
3+
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
4+
"dockerFile": "Dockerfile",
5+
// "image": "mcr.microsoft.com/devcontainers/go:1-1.22-bookworm",
6+
7+
// Features to add to the dev container. More info: https://containers.dev/features.
8+
// "features": {},
9+
10+
// Configure tool-specific properties.
11+
"customizations": {
12+
// Configure properties specific to VS Code.
13+
"vscode": {
14+
"settings": {},
15+
"extensions": [
16+
]
17+
}
18+
},
19+
20+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
21+
// "forwardPorts": [9000],
22+
// Use 'postCreateCommand' to run commands after the container is created.
23+
// "postCreateCommand": "go version",
24+
25+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
26+
"remoteUser": "root",
27+
"runArgs": ["--platform=linux/amd64" ]
28+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Build for Linux
2+
description: 'Build V8 for Linux'
3+
4+
inputs:
5+
target-arch:
6+
description: 'Target Architecture'
7+
default: x64
8+
required: true
9+
type: string
10+
11+
runs:
12+
using: "composite"
13+
steps:
14+
- name: Restore CCache
15+
uses: actions/cache@v4
16+
with:
17+
path: .ccache
18+
key: ${{ runner.os }}-${{ runner.arch }}:libv8:ccache:${{ github.run_number }}
19+
restore-keys: |
20+
${{ runner.os }}-${{ runner.arch }}:libv8:ccache:
21+
22+
- name: Setup Python
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: '3.8' # https://chromium.googlesource.com/chromium/tools/depot_tools.git/+/refs/heads/main/README.md
26+
27+
- name: Setup Build Tools
28+
shell: bash
29+
run: |
30+
sudo apt-get update
31+
sudo apt-get install -yq ccache
32+
sudo update-ccache-symlinks
33+
34+
echo "/usr/lib/ccache" >> "$GITHUB_PATH"
35+
36+
ccacheDir="${GITHUB_WORKSPACE}/.ccache"
37+
test -d "$ccacheDir" || mkdir "$ccacheDir"
38+
39+
echo "CCACHE_DIR=$ccacheDir" >> "$GITHUB_ENV"
40+
41+
- name: Download V8 Source
42+
shell: bash
43+
working-directory: ./deps
44+
run: ./v8_download.sh
45+
46+
- name: Prepare for arm64 cross compile
47+
shell: bash
48+
if: ${{ inputs.target-arch == 'arm64' }}
49+
working-directory: ./deps/v8
50+
run: |
51+
sudo apt-get install -yq g++-aarch64-linux-gnu
52+
build/linux/sysroot_scripts/install-sysroot.py --arch=arm64
53+
54+
- name: Compile V8
55+
shell: bash
56+
working-directory: ./deps
57+
run: ./v8_compile.sh ${{ inputs.target-arch }}
58+
59+
- name: Show CCache Status
60+
shell: bash
61+
working-directory: ./deps
62+
run: ccache -s
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Build for macOS
2+
description: 'Build V8 for macOS'
3+
4+
inputs:
5+
target-arch:
6+
description: 'Target Architecture'
7+
default: x64
8+
required: true
9+
type: string
10+
11+
runs:
12+
using: "composite"
13+
steps:
14+
- name: Restore CCache
15+
uses: actions/cache@v4
16+
with:
17+
path: .ccache
18+
key: ${{ runner.os }}-${{ runner.arch }}:libv8:ccache:${{ github.run_number }}
19+
restore-keys: |
20+
${{ runner.os }}-${{ runner.arch }}:libv8:ccache:
21+
22+
- name: Setup Python
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: '3.8' # https://chromium.googlesource.com/chromium/tools/depot_tools.git/+/refs/heads/main/README.md
26+
27+
- name: Setup Build Tools
28+
shell: bash
29+
run: |
30+
brew install ccache
31+
32+
echo "$(brew --prefix ccache)/libexec" >> "$GITHUB_PATH"
33+
echo "CCACHE_CPP2=yes" >> "$GITHUB_ENV"
34+
echo "CCACHE_SLOPPINESS=time_macros" >> "$GITHUB_ENV"
35+
36+
ccacheDir="${GITHUB_WORKSPACE}/.ccache"
37+
test -d "$ccacheDir" || mkdir "$ccacheDir"
38+
39+
echo "CCACHE_DIR=$ccacheDir" >> "$GITHUB_ENV"
40+
41+
- name: Download V8 Source
42+
shell: bash
43+
working-directory: ./deps
44+
run: ./v8_download.sh
45+
46+
- name: Compile V8
47+
shell: bash
48+
working-directory: ./deps
49+
run: ./v8_compile.sh ${{ inputs.target-arch }}
50+
51+
- name: Show CCache Status
52+
shell: bash
53+
working-directory: ./deps
54+
run: ccache -s

.github/workflows/fmt.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- name: Checkout
10-
uses: actions/checkout@v2
10+
uses: actions/checkout@v4
1111
- run: go fmt
1212
- name: go generate (clang-format)
1313
run: go generate

.github/workflows/leakcheck.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,12 @@ jobs:
1515
- name: Install Go
1616
uses: actions/setup-go@v2
1717
with:
18-
go-version: 1.17.2
18+
go-version: 1.22.10
19+
1920
- name: Checkout
20-
uses: actions/checkout@v2
21+
uses: actions/checkout@v4
22+
2123
- name: Go Test
22-
env:
23-
CC: clang
24-
CXX: clang++
2524
run: |
2625
go test -c --tags leakcheck
2726
./v8go.test

.github/workflows/test.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
name: Tests on ${{ matrix.go-version }} ${{ matrix.platform }}
1313
strategy:
1414
matrix:
15-
go-version: [1.18.10, 1.19.5]
15+
go-version: [1.22.10, 1.23.4]
1616
platform: [ubuntu-latest, macos-latest]
1717
runs-on: ${{ matrix.platform }}
1818

@@ -21,12 +21,15 @@ jobs:
2121
uses: actions/setup-go@v2
2222
with:
2323
go-version: ${{ matrix.go-version }}
24+
2425
- name: Checkout
25-
uses: actions/checkout@v2
26+
uses: actions/checkout@v4
27+
2628
- name: Go Test
2729
env:
2830
CGO_CXXFLAGS: "-Werror"
29-
run: go test -v -coverprofile c.out ./...
31+
run: go test -v -coverprofile c.out $(go list ./... | grep -v v8/third_party)
32+
3033
- name: Upload coverage to Codecov
3134
uses: codecov/codecov-action@v1
3235
env:
@@ -35,8 +38,10 @@ jobs:
3538
with:
3639
files: ./c.out
3740
env_vars: OS,GO
41+
3842
- name: Add GOPATH to GITHUB_ENV
3943
run: echo "GOPATH=$(go env GOPATH)" >>"$GITHUB_ENV"
44+
4045
- name: Scan and upload FOSSA data (Linux/Mac)
4146
if: env.FOSSA_API_KEY != '' && github.ref == 'refs/heads/master'
4247
run: |

.github/workflows/v8_upgrade.yml

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
name: V8 Upgrade
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '0 3 * * *' # Run every day
7+
8+
permissions:
9+
pull-requests: write
10+
contents: write
11+
12+
jobs:
13+
upgrade:
14+
name: Upgrade V8
15+
runs-on: ubuntu-22.04
16+
outputs:
17+
v8_version: ${{ steps.check_version.outputs.NEW_V8_VERSION }}
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
with:
22+
submodules: false
23+
fetch-depth: 0
24+
25+
- uses: actions/setup-python@v5
26+
with:
27+
python-version: '3.8'
28+
29+
- name: Run upgrade script
30+
id: check_version
31+
working-directory: ./deps
32+
run: ./v8_upgrade.sh
33+
34+
build:
35+
name: Build V8 for ${{ matrix.platform }} ${{ matrix.arch }}
36+
runs-on: ${{ matrix.platform }}
37+
needs: upgrade
38+
if: needs.upgrade.outputs.v8_version != '0'
39+
strategy:
40+
fail-fast: true
41+
matrix:
42+
platform: [ubuntu-22.04, macos-latest]
43+
arch: [x64, arm64]
44+
steps:
45+
- name: Checkout
46+
uses: actions/checkout@v4
47+
with:
48+
submodules: true
49+
clean: true
50+
fetch-depth: 1
51+
52+
- name: Update version file
53+
shell: bash
54+
run: echo -n "${{ needs.upgrade.outputs.v8_version }}" > deps/VERSION
55+
56+
- name: Build Release for Linux
57+
if: startsWith(matrix.platform, 'ubuntu')
58+
uses: ./.github/actions/build-linux
59+
with:
60+
target-arch: ${{ matrix.arch }}
61+
62+
- name: Build Release for macOS
63+
if: startsWith(matrix.platform, 'macos')
64+
uses: ./.github/actions/build-macos
65+
with:
66+
target-arch: ${{ matrix.arch }}
67+
68+
- name: Set v8 build name
69+
working-directory: ./deps
70+
shell: bash
71+
run: |
72+
target_arch="$1"
73+
os=$(echo "$(uname -s)" | tr '[:upper:]' '[:lower:]')
74+
archive_name="v8_${os}_${{ matrix.arch }}"
75+
echo "Using Archive Name: $archive_name"
76+
echo "ARCHIVE_NAME=$archive_name" >> "$GITHUB_ENV"
77+
78+
- name: Upload Artifact
79+
uses: actions/upload-artifact@v4
80+
with:
81+
name: ${{ env.ARCHIVE_NAME }}
82+
path: deps/v8/out/release/obj/libv8_monolith.a
83+
retention-days: 1
84+
85+
release:
86+
name: Release V8
87+
runs-on: ubuntu-22.04
88+
needs:
89+
- upgrade
90+
- build
91+
if: needs.upgrade.outputs.v8_version != '0'
92+
steps:
93+
- name: Checkout
94+
uses: actions/checkout@v4
95+
with:
96+
submodules: true
97+
clean: true
98+
fetch-depth: 1
99+
100+
- name: Download Archives
101+
uses: actions/download-artifact@v4
102+
with:
103+
path: artifact
104+
105+
- name: Display Downloads
106+
run: ls -lhR artifact
107+
108+
- name: Copy artifacts to correct folders
109+
shell: bash
110+
run: |
111+
rm deps/darwin_x86_64/libv8.a
112+
rm deps/darwin_arm64/libv8.a
113+
rm deps/linux_x86_64/libv8.a
114+
rm deps/linux_arm64/libv8.a
115+
116+
cp artifact/v8_darwin_x64/libv8_monolith.a deps/darwin_x86_64/libv8.a
117+
cp artifact/v8_darwin_arm64/libv8_monolith.a deps/darwin_arm64/libv8.a
118+
cp artifact/v8_linux_x64/libv8_monolith.a deps/linux_x86_64/libv8.a
119+
cp artifact/v8_linux_arm64/libv8_monolith.a deps/linux_arm64/libv8.a
120+
121+
rm -rf artifact
122+
123+
- name: Update version file
124+
shell: bash
125+
run: echo -n "${{ needs.upgrade.outputs.v8_version }}" > deps/VERSION
126+
127+
- name: Download V8 Source
128+
shell: bash
129+
working-directory: ./deps
130+
run: ./v8_download.sh
131+
132+
- name: Ensure includes and files are up to date
133+
shell: bash
134+
run: ./deps/v8_upgrade.py ${{ needs.upgrade.outputs.v8_version }}
135+
136+
- name: Create PR
137+
uses: peter-evans/create-pull-request@v7
138+
with:
139+
commit-message: "Upgrade V8 binaries for ${{ needs.upgrade.outputs.v8_version }} version"
140+
branch: "v8_${{ needs.upgrade.outputs.v8_version }}_upgrade"
141+
delete-branch: true
142+
title: "Upgrade V8 binaries for ${{ needs.upgrade.outputs.v8_version }} version"
143+
body: "Auto-generated pull request to upgrade V8 binary for ${{ needs.upgrade.outputs.v8_version }} version"

0 commit comments

Comments
 (0)