Skip to content

Commit

Permalink
Upgrade V8 binaries for 13.1.201.19 version
Browse files Browse the repository at this point in the history
- Use the v8 compilation pipeline from https://github.com/kuoruan/libv8
- Fix issues with v8go compatibility and changes in the V8 api
  • Loading branch information
FerdinandvHagen committed Jan 3, 2025
1 parent cee5f84 commit e58a792
Show file tree
Hide file tree
Showing 112 changed files with 6,845 additions and 2,189 deletions.
1 change: 1 addition & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM --platform=linux/amd64 mcr.microsoft.com/devcontainers/go:1-1.22-bookworm
28 changes: 28 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "Go",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"dockerFile": "Dockerfile",
// "image": "mcr.microsoft.com/devcontainers/go:1-1.22-bookworm",

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
"settings": {},
"extensions": [
]
}
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [9000],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "go version",

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
"remoteUser": "root",
"runArgs": ["--platform=linux/amd64" ]
}
62 changes: 62 additions & 0 deletions .github/actions/build-linux/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Build for Linux
description: 'Build V8 for Linux'

inputs:
target-arch:
description: 'Target Architecture'
default: x64
required: true
type: string

runs:
using: "composite"
steps:
- name: Restore CCache
uses: actions/cache@v4
with:
path: .ccache
key: ${{ runner.os }}-${{ runner.arch }}:libv8:ccache:${{ github.run_number }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}:libv8:ccache:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.8' # https://chromium.googlesource.com/chromium/tools/depot_tools.git/+/refs/heads/main/README.md

- name: Setup Build Tools
shell: bash
run: |
sudo apt-get update
sudo apt-get install -yq ccache
sudo update-ccache-symlinks
echo "/usr/lib/ccache" >> "$GITHUB_PATH"
ccacheDir="${GITHUB_WORKSPACE}/.ccache"
test -d "$ccacheDir" || mkdir "$ccacheDir"
echo "CCACHE_DIR=$ccacheDir" >> "$GITHUB_ENV"
- name: Download V8 Source
shell: bash
working-directory: ./deps
run: ./v8_download.sh

- name: Prepare for arm64 cross compile
shell: bash
if: ${{ inputs.target-arch == 'arm64' }}
working-directory: ./deps/v8
run: |
sudo apt-get install -yq g++-aarch64-linux-gnu
build/linux/sysroot_scripts/install-sysroot.py --arch=arm64
- name: Compile V8
shell: bash
working-directory: ./deps
run: ./v8_compile.sh ${{ inputs.target-arch }}

- name: Show CCache Status
shell: bash
working-directory: ./deps
run: ccache -s
54 changes: 54 additions & 0 deletions .github/actions/build-macos/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build for macOS
description: 'Build V8 for macOS'

inputs:
target-arch:
description: 'Target Architecture'
default: x64
required: true
type: string

runs:
using: "composite"
steps:
- name: Restore CCache
uses: actions/cache@v4
with:
path: .ccache
key: ${{ runner.os }}-${{ runner.arch }}:libv8:ccache:${{ github.run_number }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}:libv8:ccache:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.8' # https://chromium.googlesource.com/chromium/tools/depot_tools.git/+/refs/heads/main/README.md

- name: Setup Build Tools
shell: bash
run: |
brew install ccache
echo "$(brew --prefix ccache)/libexec" >> "$GITHUB_PATH"
echo "CCACHE_CPP2=yes" >> "$GITHUB_ENV"
echo "CCACHE_SLOPPINESS=time_macros" >> "$GITHUB_ENV"
ccacheDir="${GITHUB_WORKSPACE}/.ccache"
test -d "$ccacheDir" || mkdir "$ccacheDir"
echo "CCACHE_DIR=$ccacheDir" >> "$GITHUB_ENV"
- name: Download V8 Source
shell: bash
working-directory: ./deps
run: ./v8_download.sh

- name: Compile V8
shell: bash
working-directory: ./deps
run: ./v8_compile.sh ${{ inputs.target-arch }}

- name: Show CCache Status
shell: bash
working-directory: ./deps
run: ccache -s
2 changes: 1 addition & 1 deletion .github/workflows/fmt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- run: go fmt
- name: go generate (clang-format)
run: go generate
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/leakcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.17.2
go-version: 1.22.10

- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Go Test
env:
CC: clang
CXX: clang++
run: |
go test -c --tags leakcheck
./v8go.test
11 changes: 8 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
name: Tests on ${{ matrix.go-version }} ${{ matrix.platform }}
strategy:
matrix:
go-version: [1.18.10, 1.19.5]
go-version: [1.22.10, 1.23.4]
platform: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.platform }}

Expand All @@ -21,12 +21,15 @@ jobs:
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}

- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Go Test
env:
CGO_CXXFLAGS: "-Werror"
run: go test -v -coverprofile c.out ./...
run: go test -v -coverprofile c.out $(go list ./... | grep -v v8/third_party)

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
env:
Expand All @@ -35,8 +38,10 @@ jobs:
with:
files: ./c.out
env_vars: OS,GO

- name: Add GOPATH to GITHUB_ENV
run: echo "GOPATH=$(go env GOPATH)" >>"$GITHUB_ENV"

- name: Scan and upload FOSSA data (Linux/Mac)
if: env.FOSSA_API_KEY != '' && github.ref == 'refs/heads/master'
run: |
Expand Down
143 changes: 143 additions & 0 deletions .github/workflows/v8_upgrade.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
name: V8 Upgrade

on:
workflow_dispatch:
schedule:
- cron: '0 3 * * *' # Run every day

permissions:
pull-requests: write
contents: write

jobs:
upgrade:
name: Upgrade V8
runs-on: ubuntu-22.04
outputs:
v8_version: ${{ steps.check_version.outputs.NEW_V8_VERSION }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: false
fetch-depth: 0

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

- name: Run upgrade script
id: check_version
working-directory: ./deps
run: ./v8_upgrade.sh

build:
name: Build V8 for ${{ matrix.platform }} ${{ matrix.arch }}
runs-on: ${{ matrix.platform }}
needs: upgrade
if: needs.upgrade.outputs.v8_version != '0'
strategy:
fail-fast: true
matrix:
platform: [ubuntu-22.04, macos-latest]
arch: [x64, arm64]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
clean: true
fetch-depth: 1

- name: Update version file
shell: bash
run: echo -n "${{ needs.upgrade.outputs.v8_version }}" > deps/VERSION

- name: Build Release for Linux
if: startsWith(matrix.platform, 'ubuntu')
uses: ./.github/actions/build-linux
with:
target-arch: ${{ matrix.arch }}

- name: Build Release for macOS
if: startsWith(matrix.platform, 'macos')
uses: ./.github/actions/build-macos
with:
target-arch: ${{ matrix.arch }}

- name: Set v8 build name
working-directory: ./deps
shell: bash
run: |
target_arch="$1"
os=$(echo "$(uname -s)" | tr '[:upper:]' '[:lower:]')
archive_name="v8_${os}_${{ matrix.arch }}"
echo "Using Archive Name: $archive_name"
echo "ARCHIVE_NAME=$archive_name" >> "$GITHUB_ENV"
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARCHIVE_NAME }}
path: deps/v8/out/release/obj/libv8_monolith.a
retention-days: 1

release:
name: Release V8
runs-on: ubuntu-22.04
needs:
- upgrade
- build
if: needs.upgrade.outputs.v8_version != '0'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
clean: true
fetch-depth: 1

- name: Download Archives
uses: actions/download-artifact@v4
with:
path: artifact

- name: Display Downloads
run: ls -lhR artifact

- name: Copy artifacts to correct folders
shell: bash
run: |
rm deps/darwin_x86_64/libv8.a
rm deps/darwin_arm64/libv8.a
rm deps/linux_x86_64/libv8.a
rm deps/linux_arm64/libv8.a
cp artifact/v8_darwin_x64/libv8_monolith.a deps/darwin_x86_64/libv8.a
cp artifact/v8_darwin_arm64/libv8_monolith.a deps/darwin_arm64/libv8.a
cp artifact/v8_linux_x64/libv8_monolith.a deps/linux_x86_64/libv8.a
cp artifact/v8_linux_arm64/libv8_monolith.a deps/linux_arm64/libv8.a
rm -rf artifact
- name: Update version file
shell: bash
run: echo -n "${{ needs.upgrade.outputs.v8_version }}" > deps/VERSION

- name: Download V8 Source
shell: bash
working-directory: ./deps
run: ./v8_download.sh

- name: Ensure includes and files are up to date
shell: bash
run: ./deps/v8_upgrade.py ${{ needs.upgrade.outputs.v8_version }}

- name: Create PR
uses: peter-evans/create-pull-request@v7
with:
commit-message: "Upgrade V8 binaries for ${{ needs.upgrade.outputs.v8_version }} version"
branch: "v8_${{ needs.upgrade.outputs.v8_version }}_upgrade"
delete-branch: true
title: "Upgrade V8 binaries for ${{ needs.upgrade.outputs.v8_version }} version"
body: "Auto-generated pull request to upgrade V8 binary for ${{ needs.upgrade.outputs.v8_version }} version"
Loading

0 comments on commit e58a792

Please sign in to comment.