diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c2119c3..4e3dee4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,12 +1,13 @@ name: Build on: + - pull_request - push jobs: rubocop: name: Lint (Rubocop) runs-on: ubuntu-20.04 - container: ruby:2.7 + container: ruby:3.1 steps: - name: Checkout uses: actions/checkout@v2 @@ -30,7 +31,7 @@ jobs: outputs: GEM_VERSION: ${{ steps.set-metadata.outputs.GEM_VERSION }} runs-on: ubuntu-20.04 - container: ruby:2.7 + container: ruby:3.1 steps: - name: Update Rubygems and Bundler run: | @@ -290,18 +291,6 @@ jobs: - amd64 # other platforms would need emulation, which is way too slow container: - - image: ruby:2.7 - version: '2.7' - libc: gnu - - image: ruby:2.7-alpine - version: '2.7' - libc: musl - - image: ruby:3.0 - version: '3.0' - libc: gnu - - image: ruby:3.0-alpine - version: '3.0' - libc: musl - image: ruby:3.1 version: '3.1' libc: gnu @@ -314,6 +303,12 @@ jobs: - image: ruby:3.2-alpine version: '3.2' libc: musl + - image: ruby:3.3 + version: '3.3' + libc: gnu + - image: ruby:3.3-alpine + version: '3.3' + libc: musl name: Test (ruby) (${{ matrix.container.version }}, ${{ matrix.platform }}, ${{ matrix.container.libc }}) needs: build-ruby runs-on: ubuntu-20.04 @@ -393,10 +388,9 @@ jobs: fail-fast: false matrix: version: - - '2.7' - - '3.0' - '3.1' - '3.2' + - '3.3' platform: - amd64 # arm64 @@ -407,18 +401,15 @@ jobs: - gnu - musl include: - - version: '2.7' - platform: 'arm64' - libc: 'gnu' - - version: '3.0' - platform: 'arm64' - libc: 'gnu' - version: '3.1' platform: 'arm64' libc: 'gnu' - version: '3.2' platform: 'arm64' libc: 'gnu' + - version: '3.3' + platform: 'arm64' + libc: 'gnu' name: Test (linux) needs: build-linux runs-on: ubuntu-20.04 diff --git a/Dockerfile b/Dockerfile index f44ba8f..f625509 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ ARG RUBY_VERSION=2.7 FROM ruby:${RUBY_VERSION} RUN test ! -f /etc/alpine-release || apk add --no-cache build-base bash python3 git curl tar ccache clang -RUN test -f /etc/alpine-release || (apt-get update && apt-get install -y ccache clang) +RUN test -f /etc/alpine-release || (apt-get update && apt-get install -y ccache) ENV CCACHE_DIR=/ccache RUN gem update --system 3.3.26 && gem install bundler -v '~> 2.3.26' diff --git a/Makefile.docker b/Makefile.docker index 87aeb3c..0532ea4 100644 --- a/Makefile.docker +++ b/Makefile.docker @@ -38,28 +38,28 @@ pkg/libv8-node-$(VERSION)-aarch64-linux-musl.gem: test/x86_64-linux: pkg/libv8-node-$(VERSION)-x86_64-linux.gem test -d test/mini_racer || git clone https://github.com/rubyjs/mini_racer.git test/mini_racer --depth 1 - cd test/mini_racer && git fetch origin refs/pull/299/head && git checkout FETCH_HEAD && git reset --hard && git clean -f -d -x + cd test/mini_racer ruby -i -ne '$$_ =~ /^\s+LIBV8_NODE_VERSION/ ? print(" LIBV8_NODE_VERSION = \"$(VERSION)\"\n") : print' test/mini_racer/lib/mini_racer/version.rb ruby -i -ne '$$_ =~ /spec.required_ruby_version/ ? "" : print' test/mini_racer/mini_racer.gemspec docker run --platform linux/amd64 --rm -it -v "$(PWD)/test:/code/test" -w "/code/test/mini_racer" libv8-node:$(VERSION)-gnu sh -c 'gem install ../../$< && bundle install && bundle exec rake compile && bundle exec rake test' test/x86_64-linux-musl: pkg/libv8-node-$(VERSION)-x86_64-linux-musl.gem test -d test/mini_racer || git clone https://github.com/rubyjs/mini_racer.git test/mini_racer --depth 1 - cd test/mini_racer && git fetch origin refs/pull/299/head && git checkout FETCH_HEAD && git reset --hard && git clean -f -d -x + cd test/mini_racer ruby -i -ne '$$_ =~ /^\s+LIBV8_NODE_VERSION/ ? print(" LIBV8_NODE_VERSION = \"$(VERSION)\"\n") : print' test/mini_racer/lib/mini_racer/version.rb ruby -i -ne '$$_ =~ /spec.required_ruby_version/ ? "" : print' test/mini_racer/mini_racer.gemspec docker run --platform linux/amd64 --rm -it -v "$(PWD)/test:/code/test" -w "/code/test/mini_racer" libv8-node:$(VERSION)-musl sh -c 'gem install ../../$< && bundle install && bundle exec rake compile && bundle exec rake test' test/aarch64-linux: pkg/libv8-node-$(VERSION)-aarch64-linux.gem test -d test/mini_racer || git clone https://github.com/rubyjs/mini_racer.git test/mini_racer --depth 1 - cd test/mini_racer && git fetch origin refs/pull/299/head && git checkout FETCH_HEAD && git reset --hard && git clean -f -d -x + cd test/mini_racer ruby -i -ne '$$_ =~ /^\s+LIBV8_NODE_VERSION/ ? print(" LIBV8_NODE_VERSION = \"$(VERSION)\"\n") : print' test/mini_racer/lib/mini_racer/version.rb ruby -i -ne '$$_ =~ /spec.required_ruby_version/ ? "" : print' test/mini_racer/mini_racer.gemspec docker run --platform linux/arm64 --rm -it -v "$(PWD)/test:/code/test" -w "/code/test/mini_racer" libv8-node:$(VERSION)-gnu sh -c 'gem install ../../$< && bundle install && bundle exec rake compile && bundle exec rake test' test/aarch64-linux-musl: pkg/libv8-node-$(VERSION)-aarch64-linux-musl.gem test -d test/mini_racer || git clone https://github.com/rubyjs/mini_racer.git test/mini_racer --depth 1 - cd test/mini_racer && git fetch origin refs/pull/299/head && git checkout FETCH_HEAD && git reset --hard && git clean -f -d -x + cd test/mini_racer ruby -i -ne '$$_ =~ /^\s+LIBV8_NODE_VERSION/ ? print(" LIBV8_NODE_VERSION = \"$(VERSION)\"\n") : print' test/mini_racer/lib/mini_racer/version.rb ruby -i -ne '$$_ =~ /spec.required_ruby_version/ ? "" : print' test/mini_racer/mini_racer.gemspec docker run --platform linux/arm64 --rm -it -v "$(PWD)/test:/code/test" -w "/code/test/mini_racer" libv8-node:$(VERSION)-musl sh -c 'gem install ../../$< && bundle install && bundle exec rake compile && bundle exec rake test' diff --git a/lib/libv8/node/version.rb b/lib/libv8/node/version.rb index 5c9859d..ee03597 100644 --- a/lib/libv8/node/version.rb +++ b/lib/libv8/node/version.rb @@ -1,7 +1,10 @@ -module Libv8; end +# frozen_string_literal: true + +module Libv8 +end module Libv8::Node - VERSION = '21.7.2.0'.freeze - NODE_VERSION = '21.7.2'.freeze - LIBV8_VERSION = '11.8.172.17'.freeze # from v8/include/v8-version.h + VERSION = '22.7.0.1' + NODE_VERSION = '22.7.0' + LIBV8_VERSION = '12.4.254.21' # from src/node-.../deps/v8/include/v8-version.h end diff --git a/libexec/extract-node b/libexec/extract-node index 73e6073..d2bd205 100755 --- a/libexec/extract-node +++ b/libexec/extract-node @@ -32,6 +32,9 @@ cd "${src}/node-v${version}" #patch -p1 < "${top}"/patch/gyp-libv8_monolith.patch #patch -p1 < "${top}"/patch/py2-icutrim.patch #patch -p1 < "${top}"/patch/py2-genv8constants.patch +patch -p1 < "${top}"/patch/v8-no-assert-trivially-copyable.patch +patch -p1 < "${top}"/patch/v8-disable-madv-dontfork.patch +patch -p1 < "${top}"/patch/v8-disable-pkey.patch # TODO: the following still fails on py3 so the above one forcing py2 is needed # patch -p1 < ../../py3-genv8constants.patch diff --git a/patch/v8-disable-madv-dontfork.patch b/patch/v8-disable-madv-dontfork.patch new file mode 100644 index 0000000..7e4317c --- /dev/null +++ b/patch/v8-disable-madv-dontfork.patch @@ -0,0 +1,16 @@ +diff --git a/tools/v8_gypfiles/features.gypi b/tools/v8_gypfiles/features.gypi +index 6e21dac6d7..bcf022fb28 100644 +--- a/tools/v8_gypfiles/features.gypi ++++ b/tools/v8_gypfiles/features.gypi +@@ -73,7 +73,10 @@ + }, { + 'v8_enable_etw_stack_walking': 0, + }], +- ['OS=="linux"', { ++ # Disable madvise(MADV_DONTFORK), it's a great optimization for programs ++ # that fork & exec but not for programs that fork and keep running. ++ # It makes mini_racer's test/test_forking.rb test segfault. ++ ['False and OS=="linux"', { + # Sets -dV8_ENABLE_PRIVATE_MAPPING_FORK_OPTIMIZATION. + # + # This flag speeds up the performance of fork/execve on Linux systems for diff --git a/patch/v8-disable-pkey.patch b/patch/v8-disable-pkey.patch new file mode 100644 index 0000000..f3a3718 --- /dev/null +++ b/patch/v8-disable-pkey.patch @@ -0,0 +1,17 @@ +diff --git a/deps/v8/src/base/build_config.h b/deps/v8/src/base/build_config.h +index 9ed4c8f102..dfca698506 100644 +--- a/deps/v8/src/base/build_config.h ++++ b/deps/v8/src/base/build_config.h +@@ -35,11 +35,8 @@ + #define V8_HAS_PTHREAD_JIT_WRITE_PROTECT 0 + #endif + +-#if defined(V8_OS_LINUX) && defined(V8_HOST_ARCH_X64) +-#define V8_HAS_PKU_JIT_WRITE_PROTECT 1 +-#else ++// disabled, see https://issues.chromium.org/issues/360909072 + #define V8_HAS_PKU_JIT_WRITE_PROTECT 0 +-#endif + + #if defined(V8_TARGET_ARCH_IA32) || defined(V8_TARGET_ARCH_X64) + #define V8_TARGET_ARCH_STORES_RETURN_ADDRESS_ON_STACK true diff --git a/patch/v8-no-assert-trivially-copyable.patch b/patch/v8-no-assert-trivially-copyable.patch new file mode 100644 index 0000000..2148c14 --- /dev/null +++ b/patch/v8-no-assert-trivially-copyable.patch @@ -0,0 +1,14 @@ +diff --git a/deps/v8/src/base/small-vector.h b/deps/v8/src/base/small-vector.h +index edaab3a7a6..533a536178 100644 +--- a/deps/v8/src/base/small-vector.h ++++ b/deps/v8/src/base/small-vector.h +@@ -20,9 +20,6 @@ namespace base { + // dynamic storage when it overflows. + template > + class SmallVector { +- // Currently only support trivially copyable and trivially destructible data +- // types, as it uses memcpy to copy elements and never calls destructors. +- ASSERT_TRIVIALLY_COPYABLE(T); + static_assert(std::is_trivially_destructible::value); + + public: diff --git a/sums/v22.5.1.sum b/sums/v22.5.1.sum new file mode 100644 index 0000000..52bbadd --- /dev/null +++ b/sums/v22.5.1.sum @@ -0,0 +1 @@ +4a1b383f6036def4bb183f18e71a10b58784db269f9953618418bbaf47692972 diff --git a/sums/v22.6.0.sum b/sums/v22.6.0.sum new file mode 100644 index 0000000..59bb42b --- /dev/null +++ b/sums/v22.6.0.sum @@ -0,0 +1 @@ +af4a8747651385515163db5da0d2e217da15cf7c832672b234128ed5118f086d diff --git a/sums/v22.7.0.sum b/sums/v22.7.0.sum new file mode 100644 index 0000000..9d6cc21 --- /dev/null +++ b/sums/v22.7.0.sum @@ -0,0 +1 @@ +7a7c99282d59866d971b2da12c99596cb15782b9c3efe2e2146390c14f4d490e diff --git a/test/gtest/CMakeLists.txt b/test/gtest/CMakeLists.txt index 915947c..289bd41 100644 --- a/test/gtest/CMakeLists.txt +++ b/test/gtest/CMakeLists.txt @@ -1,8 +1,8 @@ cmake_minimum_required(VERSION 3.14) project(gtest) -# GoogleTest requires at least C++14 -set(CMAKE_CXX_STANDARD 14) +# V8 requires at least C++17 +set(CMAKE_CXX_STANDARD 17) include(FetchContent) FetchContent_Declare( diff --git a/test/gtest/Framework.h b/test/gtest/Framework.h index ed54c59..59bacfe 100644 --- a/test/gtest/Framework.h +++ b/test/gtest/Framework.h @@ -16,7 +16,7 @@ struct Framework { main(); v8::V8::Dispose(); - v8::V8::ShutdownPlatform(); + v8::V8::DisposePlatform(); } inline static void runWithIsolateRaw(iso_main main) { @@ -50,4 +50,4 @@ struct Framework { main(ctx); }); } -}; \ No newline at end of file +};