mini_racer 0.4.0 → 0.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e73ac3193df3f33b51463ba1125ac4eee312caecd47833c545e098ba91d11ece
4
- data.tar.gz: d6d754829b36953d239ba85e84d2fc88c0af3ccbadd3f8d2e4cd9759bd24fab2
3
+ metadata.gz: 2d643f2cd1fb220fc7ac49d502671334d2e9390cd6eac47b62cdecfc39f2dd82
4
+ data.tar.gz: 2c1cbb7cb254dddefdeac0c7bd246d62e2f08dfb9df24c91680ef0e6016ea483
5
5
  SHA512:
6
- metadata.gz: 52a0799d84be10bb03774789b3d12d4f0fe2d4159d310b9c6a1ae3dcf878a99cd6b7c786fae813f29754a894ecf5fcc6b7e07834c0aba994a16da5c54d75595b
7
- data.tar.gz: bc478bdb582d7b786d28754200063d7ef185396e0da23840f006679bc1af6707f54c7a719918360afa9b24c2b4ab083ca081e2b2d6853095ecd5949a9482ecbd
6
+ metadata.gz: be7c745abba5a2bd5caf0e30f066601a58d00f847092bde4865d3faf7b79987af5bfe0c6cd9c2783f0ab7a7edc1e39b6a53afa489ce4e5dde0713981e26dfc51
7
+ data.tar.gz: e6128f7619cdb105b04f5a7abb0ed2c0964a2b2b353c3a4eecc79dfa3d329d88695f9885c7250d2d6615ff9bc93c22cf111d24bca54d9e57fbaa02672998879c
@@ -1,50 +1,92 @@
1
- name: Test
1
+ name: Tests
2
+
2
3
  on:
3
- - push
4
+ pull_request:
5
+ push:
6
+ branches:
7
+ - master
4
8
 
5
9
  jobs:
10
+ test-truffleruby:
11
+ strategy:
12
+ fail-fast: false
13
+ matrix:
14
+ os:
15
+ - "macos-11"
16
+ - "macos-12"
17
+ - "ubuntu-20.04"
18
+ ruby:
19
+ - "truffleruby+graalvm-head"
20
+
21
+ name: ${{ matrix.os }} - ${{ matrix.ruby }}
22
+ runs-on: ${{ matrix.os }}
23
+
24
+ env:
25
+ TRUFFLERUBYOPT: "--jvm --polyglot"
26
+
27
+ steps:
28
+ - uses: actions/checkout@v3
29
+ - uses: ruby/setup-ruby@v1
30
+ with:
31
+ ruby-version: ${{ matrix.ruby }}
32
+ bundler-cache: true
33
+ - name: Install GraalVM JS component
34
+ run: gu install js
35
+ - name: Compile
36
+ run: bundle exec rake compile
37
+ - name: Test
38
+ run: bundle exec rake test
39
+
6
40
  test-darwin:
7
41
  strategy:
8
42
  fail-fast: false
9
43
  matrix:
10
44
  os:
11
- - '10.15'
12
- - '11.0'
13
- platform:
14
- - x86_64
15
- # arm64
16
- name: Test (darwin)
17
- runs-on: macos-${{ matrix.os }}
45
+ - "macos-11"
46
+ - "macos-12"
47
+ ruby:
48
+ - "ruby-2.6"
49
+ - "ruby-2.7"
50
+ - "ruby-3.0"
51
+ - "ruby-3.1"
52
+
53
+ name: ${{ matrix.os }} - ${{ matrix.ruby }}
54
+ runs-on: ${{ matrix.os }}
55
+
18
56
  steps:
19
- - name: Checkout
20
- uses: actions/checkout@v2
21
- - name: Bundle
22
- run: bundle install
57
+ - uses: actions/checkout@v3
58
+ - uses: ruby/setup-ruby@v1
59
+ with:
60
+ ruby-version: ${{ matrix.ruby }}
61
+ bundler-cache: true
23
62
  - name: Compile
24
63
  run: bundle exec rake compile
25
64
  - name: Test
26
65
  run: bundle exec rake test
66
+
27
67
  test-linux:
28
68
  strategy:
29
69
  fail-fast: false
30
70
  matrix:
31
71
  ruby:
32
- - '2.4'
33
- - '2.5'
34
- - '2.6'
35
- - '2.7'
36
- - '3.0'
72
+ - "2.6"
73
+ - "2.7"
74
+ - "3.0"
75
+ - "3.1"
37
76
  platform:
38
- - amd64
39
- - arm64
40
- # arm
41
- # ppc64le
42
- # s390x
77
+ - "amd64"
78
+ - "arm64"
43
79
  libc:
44
- - gnu
45
- - musl
46
- name: Test (linux)
80
+ - "gnu"
81
+ - "musl"
82
+ exclude:
83
+ # there's no libv8-node (v16) for aarch64-linux-musl at the moment
84
+ - platform: "arm64"
85
+ libc: "musl"
86
+
87
+ name: linux-${{ matrix.platform }} - ruby-${{ matrix.ruby }} - ${{ matrix.libc }}
47
88
  runs-on: ubuntu-20.04
89
+
48
90
  steps:
49
91
  - name: Enable ${{ matrix.platform }} platform
50
92
  id: qemu
@@ -69,9 +111,11 @@ jobs:
69
111
  echo "::set-output name=id::$(cat container_id)"
70
112
  - name: Install Alpine system dependencies
71
113
  if: ${{ matrix.libc == 'musl' }}
72
- run: docker exec -w "${PWD}" ${{ steps.container.outputs.id }} apk add --no-cache build-base linux-headers bash python2 python3 git curl tar clang binutils-gold
114
+ run: docker exec -w "${PWD}" ${{ steps.container.outputs.id }} apk add --no-cache build-base bash git
73
115
  - name: Checkout
74
- uses: actions/checkout@v2
116
+ uses: actions/checkout@v3
117
+ - name: Update Rubygems
118
+ run: docker exec -w "${PWD}" ${{ steps.container.outputs.id }} gem update --system
75
119
  - name: Bundle
76
120
  run: docker exec -w "${PWD}" ${{ steps.container.outputs.id }} bundle install
77
121
  - name: Compile
data/.gitignore CHANGED
@@ -10,3 +10,4 @@ Gemfile.lock
10
10
  lib/mini_racer_extension.so
11
11
  lib/mini_racer_loader.so
12
12
  *.bundle
13
+ .vscode/
data/CHANGELOG CHANGED
@@ -1,5 +1,51 @@
1
+ - 25-05-2022
2
+
3
+ - 0.6.4
4
+
5
+ - Target Node 16.19.0.0
6
+
7
+ - 16-08-2022
8
+
9
+ - 0.6.3
10
+
11
+ - Truffle ruby support! Thanks to Brandon Fish and the truffle team
12
+ - Hide libv8 symbols on ELF targets
13
+ - Slightly shrunk binary size
14
+ - Simplified timeout implementation
15
+ - Some stability fixes
16
+
17
+ - 17-01-2022
18
+
19
+ - 0.6.2
20
+
21
+ - Fix support for compilation on 2.6, llvm compiles
22
+ - Stability patches to handle rare memory leaks
23
+ - Corrected re-raising of exceptions to support strings
24
+ - During early termination of context under certain conditions MiniRacer could crash
25
+
26
+
27
+ - 31-12-2021
28
+
29
+ - 0.6.1
30
+
31
+ - Added support for single threaded platform: `MiniRacer::Platform.set_flags! :single_threaded`
32
+ must be called prior to booting ANY MiniRacer::Context
33
+
34
+ - 0.6.0
35
+
36
+ - Ruby 3.1 support
37
+ - Fixes memory leak in heap snapshotting
38
+ - Improved compilation ergonomics in clang
39
+ - Migrated internal storage in c extension to TypedData
40
+
1
41
  - 11-04-2021
2
42
 
43
+ - 0.5.0
44
+ - Fixes issues on aarch (Apple M1)
45
+ - Update to use libv8-node 16.x (#210) [Loic Nageleisen]
46
+ - FEATURE: Configurable max marshal stack depth (#202) [seanmakesgames]
47
+ - Ruby 2.3 and 2.4 are EOL, we no longer support them
48
+
3
49
  - 0.4.0
4
50
 
5
51
  - FEATURE: upgrade to libv8 node 15.14.0 (v8 8.6.395.17)
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MiniRacer
2
2
 
3
- [![Build Status](https://travis-ci.org/rubyjs/mini_racer.svg?branch=master)](https://travis-ci.org/rubyjs/mini_racer)
3
+ [![Test](https://github.com/rubyjs/mini_racer/actions/workflows/ci.yml/badge.svg)](https://github.com/rubyjs/mini_racer/actions/workflows/ci.yml)
4
4
 
5
5
  Minimal, modern embedded V8 for Ruby.
6
6
 
@@ -10,12 +10,14 @@ It was created as an alternative to the excellent [therubyracer](https://github.
10
10
 
11
11
  MiniRacer has an adapter for [execjs](https://github.com/rails/execjs) so it can be used directly with Rails projects to minify assets, run babel or compile CoffeeScript.
12
12
 
13
- ### A note about Ruby version Support
13
+ ### Supported Ruby Versions
14
14
 
15
- MiniRacer only supports non-EOL versions of Ruby. See [Ruby](https://www.ruby-lang.org/en/downloads) to see the list of non-EOL Rubies.
15
+ MiniRacer only supports non-EOL versions of Ruby. See [Ruby Maintenance Branches](https://www.ruby-lang.org/en/downloads/branches/) for the list of non-EOL Rubies.
16
16
 
17
17
  If you require support for older versions of Ruby install an older version of the gem.
18
18
 
19
+ MiniRacer **does not support** [Ruby built on MinGW](https://github.com/rubyjs/mini_racer/issues/252#issuecomment-1201172236, "pure windows" no Cygwin, no WSL2) (see https://github.com/rubyjs/libv8-node/issues/9).
20
+
19
21
  ## Features
20
22
 
21
23
  ### Simple eval for JavaScript
@@ -85,6 +87,19 @@ context.eval 'var a = new Array(10000); while(true) {a = a.concat(new Array(1000
85
87
  # => V8OutOfMemoryError is raised
86
88
  ```
87
89
 
90
+ ### Object marshal max stackdepth support
91
+
92
+ Contexts can specify a stack depth limit for object marshalling. Max depth is unbounded by default.
93
+
94
+ ```ruby
95
+ # terminates script if stack depth exceeds max during marshal
96
+ context = MiniRacer::Context.new(marshal_stack_depth: 500)
97
+ context.attach("a", proc{|a| a})
98
+
99
+ context.eval("let arr = []; arr.push(arr); a(arr)")
100
+ # => RuntimeError is raised
101
+ ```
102
+
88
103
  ### Rich debugging with "filename" support
89
104
 
90
105
  ```ruby
@@ -99,16 +114,21 @@ context.eval('bar()', filename: 'a/bar.js')
99
114
 
100
115
  ### Fork safety
101
116
 
102
- Some Ruby web servers employ forking (for example unicorn or puma in clustered mode). V8 is not fork safe.
103
- Sadly Ruby does not have support for fork notifications per [#5446](https://bugs.ruby-lang.org/issues/5446).
117
+ Some Ruby web servers employ forking (for example unicorn or puma in clustered mode). V8 is not fork safe by default and sadly Ruby does not have support for fork notifications per [#5446](https://bugs.ruby-lang.org/issues/5446).
118
+
119
+ Since 0.6.1 mini_racer does support V8 single threaded platform mode which should remove most forking related issues. To enable run this before using `MiniRacer::Context`:
120
+
121
+ ```ruby
122
+ MiniRacer::Platform.set_flags!(:single_threaded)
123
+ ```
104
124
 
105
125
  If you want to ensure your application does not leak memory after fork either:
106
126
 
107
- 1. Ensure no MiniRacer::Context objects are created in the master process
127
+ 1. Ensure no `MiniRacer::Context` objects are created in the master process
108
128
 
109
129
  Or
110
130
 
111
- 2. Dispose manually of all MiniRacer::Context objects prior to forking
131
+ 2. Dispose manually of all `MiniRacer::Context` objects prior to forking
112
132
 
113
133
  ```ruby
114
134
  # before fork
@@ -403,21 +423,18 @@ Or install it yourself as:
403
423
  $ gem install mini_racer
404
424
 
405
425
 
406
- **Note** using v8.h and compiling MiniRacer requires a C++11 standard compiler, more specifically clang 3.5 (or later) or gcc 4.8 (or later).
407
-
426
+ **Note** using v8.h and compiling MiniRacer requires a C++11 standard compiler, more specifically clang 3.5 (or later) or GCC 6.3 (or later).
408
427
 
409
- ## Travis-ci
410
428
 
411
- To install `mini-racer` you will need a version of gcc that supports C++11 (gcc 4.8) this is included by default in ubuntu trusty based images.
429
+ ### Troubleshooting
412
430
 
413
- Travis today ships by default with a precise based image. Precise Pangolin (12.04 LTS) was first released in August 2012. Even though you can install GCC 4.8 on precise the simpler approach is to opt for the trusty based image.
431
+ If you have a problem installing mini_racer, please consider the following steps:
414
432
 
415
- Add this to your .travis.yml file:
416
-
417
- ```
418
- - sudo: required
419
- - dist: trusty
420
- ```
433
+ * make sure you try the latest released version of mini_racer
434
+ * make sure you have Rubygems >= 3.2.13 and bundler >= 2.2.13 installed via `gem update --system`
435
+ * if you are using bundler, make sure to have `PLATFORMS` set correctly in `Gemfile.lock` via `bundle lock --add-platform`
436
+ * make sure to recompile/reinstall `mini_racer` and `libv8-node` after system upgrades (for example via `gem uninstall --all mini_racer libv8-node`)
437
+ * make sure you are on the latest patch/teeny version of a supported Ruby branch
421
438
 
422
439
  ## Similar Projects
423
440
 
data/Rakefile CHANGED
@@ -1,6 +1,5 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rake/testtask"
3
- require "rake/extensiontask"
4
3
 
5
4
  Rake::TestTask.new(:test) do |t|
6
5
  t.libs << "test"
@@ -11,8 +10,21 @@ end
11
10
  task :default => [:compile, :test]
12
11
 
13
12
  gem = Gem::Specification.load( File.dirname(__FILE__) + '/mini_racer.gemspec' )
14
- Rake::ExtensionTask.new( 'mini_racer_loader', gem )
15
- Rake::ExtensionTask.new( 'mini_racer_extension', gem )
13
+
14
+ if RUBY_ENGINE == "truffleruby"
15
+ task :compile do
16
+ # noop
17
+ end
18
+
19
+ task :clean do
20
+ # noop
21
+ end
22
+ else
23
+ require 'rake/extensiontask'
24
+ Rake::ExtensionTask.new( 'mini_racer_loader', gem )
25
+ Rake::ExtensionTask.new( 'mini_racer_extension', gem )
26
+ end
27
+
16
28
 
17
29
 
18
30
  # via http://blog.flavorjon.es/2009/06/easily-valgrind-gdb-your-ruby-c.html
@@ -92,5 +104,5 @@ task :lint do
92
104
  portability-*
93
105
  readability-*).join(',')
94
106
 
95
- sh RbConfig::expand("clang-tidy -checks='#{checks}' ext/mini_racer_extension/mini_racer_extension.cc -- #$INCFLAGS #$CPPFLAGS", conf)
107
+ sh RbConfig::expand("clang-tidy -checks='#{checks}' ext/mini_racer_extension/mini_racer_extension.cc -- #$INCFLAGS #$CXXFLAGS", conf)
96
108
  end
@@ -1,4 +1,10 @@
1
1
  require 'mkmf'
2
+
3
+ if RUBY_ENGINE == "truffleruby"
4
+ File.write("Makefile", dummy_makefile($srcdir).join(""))
5
+ return
6
+ end
7
+
2
8
  require_relative '../../lib/mini_racer/version'
3
9
  gem 'libv8-node', MiniRacer::LIBV8_NODE_VERSION
4
10
  require 'libv8-node'
@@ -7,18 +13,25 @@ IS_DARWIN = RUBY_PLATFORM =~ /darwin/
7
13
 
8
14
  have_library('pthread')
9
15
  have_library('objc') if IS_DARWIN
10
- $CPPFLAGS += " -Wall" unless $CPPFLAGS.split.include? "-Wall"
11
- $CPPFLAGS += " -g" unless $CPPFLAGS.split.include? "-g"
12
- $CPPFLAGS += " -rdynamic" unless $CPPFLAGS.split.include? "-rdynamic"
13
- $CPPFLAGS += " -fPIC" unless $CPPFLAGS.split.include? "-rdynamic" or IS_DARWIN
14
- $CPPFLAGS += " -std=c++0x"
15
- $CPPFLAGS += " -fpermissive"
16
- $CPPFLAGS += " -DV8_COMPRESS_POINTERS"
17
- $CPPFLAGS += " -fvisibility=hidden "
18
-
19
- $CPPFLAGS += " -Wno-reserved-user-defined-literal" if IS_DARWIN
20
-
21
- $LDFLAGS.insert(0, " -stdlib=libc++ ") if IS_DARWIN
16
+ $CXXFLAGS += " -Wall" unless $CXXFLAGS.split.include? "-Wall"
17
+ $CXXFLAGS += " -g" unless $CXXFLAGS.split.include? "-g"
18
+ $CXXFLAGS += " -rdynamic" unless $CXXFLAGS.split.include? "-rdynamic"
19
+ $CXXFLAGS += " -fPIC" unless $CXXFLAGS.split.include? "-rdynamic" or IS_DARWIN
20
+ $CXXFLAGS += " -std=c++14"
21
+ $CXXFLAGS += " -fpermissive"
22
+ #$CXXFLAGS += " -DV8_COMPRESS_POINTERS"
23
+ $CXXFLAGS += " -fvisibility=hidden "
24
+
25
+ # __declspec gets used by clang via ruby 3.x headers...
26
+ $CXXFLAGS += " -fms-extensions"
27
+
28
+ $CXXFLAGS += " -Wno-reserved-user-defined-literal" if IS_DARWIN
29
+
30
+ if IS_DARWIN
31
+ $LDFLAGS.insert(0, " -stdlib=libc++ ")
32
+ else
33
+ $LDFLAGS.insert(0, " -lstdc++ ")
34
+ end
22
35
 
23
36
  # check for missing symbols at link time
24
37
  # $LDFLAGS += " -Wl,--no-undefined " unless IS_DARWIN
@@ -63,9 +76,17 @@ end
63
76
 
64
77
  Libv8::Node.configure_makefile
65
78
 
79
+ # --exclude-libs is only for i386 PE and ELF targeted ports
80
+ append_ldflags("-Wl,--exclude-libs=ALL ")
81
+
66
82
  if enable_config('asan')
67
- $CPPFLAGS.insert(0, " -fsanitize=address ")
83
+ $CXXFLAGS.insert(0, " -fsanitize=address ")
68
84
  $LDFLAGS.insert(0, " -fsanitize=address ")
69
85
  end
70
86
 
87
+ # there doesn't seem to be a CPP macro for this in Ruby 2.6:
88
+ if RUBY_ENGINE == 'ruby'
89
+ $CPPFLAGS += ' -DENGINE_IS_CRUBY '
90
+ end
91
+
71
92
  create_makefile 'mini_racer_extension'