mini_racer 0.2.8 → 0.6.3
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 +4 -4
- data/.dockerignore +12 -0
- data/.github/workflows/ci.yml +124 -0
- data/.gitignore +2 -0
- data/CHANGELOG +111 -0
- data/Dockerfile +21 -0
- data/README.md +50 -20
- data/Rakefile +16 -3
- data/ext/mini_racer_extension/extconf.rb +41 -12
- data/ext/mini_racer_extension/mini_racer_extension.cc +577 -272
- data/ext/mini_racer_loader/extconf.rb +13 -0
- data/ext/mini_racer_loader/mini_racer_loader.c +123 -0
- data/lib/mini_racer/truffleruby.rb +353 -0
- data/lib/mini_racer/version.rb +4 -1
- data/lib/mini_racer.rb +102 -24
- data/mini_racer.gemspec +12 -7
- metadata +46 -22
- data/.travis.yml +0 -24
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4290b52d3d19c196567892c0d3eda0b47f07047afe059e63d4ac976258cb52a0
|
|
4
|
+
data.tar.gz: 55e41b4e8ab93cdfe45446ff08a5b3c42323356e36b79d91f2e564c43a7715fe
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c0e0cca11803ffa6ba38998810ccb82413257145947a637f3800252f4a0d47bd47fde425786c09f1eedf6c28b1bb584d34914b111effffef908ff182e79c5329
|
|
7
|
+
data.tar.gz: 05dbfe34c140fedf6fbd33f5eee62f6cc6880579d238039f2e351a0279fa9267575b46ae7890f9c7d19ebd43bf1020e9bb57d445ad4e6ac8f89440ac3e2744d3
|
data/.dockerignore
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
name: Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
push:
|
|
6
|
+
branches:
|
|
7
|
+
- master
|
|
8
|
+
|
|
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
|
+
|
|
40
|
+
test-darwin:
|
|
41
|
+
strategy:
|
|
42
|
+
fail-fast: false
|
|
43
|
+
matrix:
|
|
44
|
+
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
|
+
|
|
56
|
+
steps:
|
|
57
|
+
- uses: actions/checkout@v3
|
|
58
|
+
- uses: ruby/setup-ruby@v1
|
|
59
|
+
with:
|
|
60
|
+
ruby-version: ${{ matrix.ruby }}
|
|
61
|
+
bundler-cache: true
|
|
62
|
+
- name: Compile
|
|
63
|
+
run: bundle exec rake compile
|
|
64
|
+
- name: Test
|
|
65
|
+
run: bundle exec rake test
|
|
66
|
+
|
|
67
|
+
test-linux:
|
|
68
|
+
strategy:
|
|
69
|
+
fail-fast: false
|
|
70
|
+
matrix:
|
|
71
|
+
ruby:
|
|
72
|
+
- "2.6"
|
|
73
|
+
- "2.7"
|
|
74
|
+
- "3.0"
|
|
75
|
+
- "3.1"
|
|
76
|
+
platform:
|
|
77
|
+
- "amd64"
|
|
78
|
+
- "arm64"
|
|
79
|
+
libc:
|
|
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 }}
|
|
88
|
+
runs-on: ubuntu-20.04
|
|
89
|
+
|
|
90
|
+
steps:
|
|
91
|
+
- name: Enable ${{ matrix.platform }} platform
|
|
92
|
+
id: qemu
|
|
93
|
+
if: ${{ matrix.platform != 'amd64' }}
|
|
94
|
+
run: |
|
|
95
|
+
docker run --privileged --rm tonistiigi/binfmt:latest --install ${{ matrix.platform }} | tee platforms.json
|
|
96
|
+
echo "::set-output name=platforms::$(cat platforms.json)"
|
|
97
|
+
- name: Start container
|
|
98
|
+
id: container
|
|
99
|
+
run: |
|
|
100
|
+
case ${{ matrix.libc }} in
|
|
101
|
+
gnu)
|
|
102
|
+
echo 'ruby:${{ matrix.ruby }}'
|
|
103
|
+
;;
|
|
104
|
+
musl)
|
|
105
|
+
echo 'ruby:${{ matrix.ruby }}-alpine'
|
|
106
|
+
;;
|
|
107
|
+
esac > container_image
|
|
108
|
+
echo "::set-output name=image::$(cat container_image)"
|
|
109
|
+
docker run --rm -d -v "${PWD}":"${PWD}" -w "${PWD}" --platform linux/${{ matrix.platform }} $(cat container_image) /bin/sleep 64d | tee container_id
|
|
110
|
+
docker exec -w "${PWD}" $(cat container_id) uname -a
|
|
111
|
+
echo "::set-output name=id::$(cat container_id)"
|
|
112
|
+
- name: Install Alpine system dependencies
|
|
113
|
+
if: ${{ matrix.libc == 'musl' }}
|
|
114
|
+
run: docker exec -w "${PWD}" ${{ steps.container.outputs.id }} apk add --no-cache build-base bash git
|
|
115
|
+
- name: Checkout
|
|
116
|
+
uses: actions/checkout@v3
|
|
117
|
+
- name: Update Rubygems
|
|
118
|
+
run: docker exec -w "${PWD}" ${{ steps.container.outputs.id }} gem update --system
|
|
119
|
+
- name: Bundle
|
|
120
|
+
run: docker exec -w "${PWD}" ${{ steps.container.outputs.id }} bundle install
|
|
121
|
+
- name: Compile
|
|
122
|
+
run: docker exec -w "${PWD}" ${{ steps.container.outputs.id }} bundle exec rake compile
|
|
123
|
+
- name: Test
|
|
124
|
+
run: docker exec -w "${PWD}" ${{ steps.container.outputs.id }} bundle exec rake test
|
data/.gitignore
CHANGED
data/CHANGELOG
CHANGED
|
@@ -1,3 +1,114 @@
|
|
|
1
|
+
- 16-08-2022
|
|
2
|
+
|
|
3
|
+
- 0.6.3
|
|
4
|
+
|
|
5
|
+
- Truffle ruby support! Thanks to Brandon Fish and the truffle team
|
|
6
|
+
- Hide libv8 symbols on ELF targets
|
|
7
|
+
- Slightly shrunk binary size
|
|
8
|
+
- Simplified timeout implementation
|
|
9
|
+
- Some stability fixes
|
|
10
|
+
|
|
11
|
+
- 17-01-2022
|
|
12
|
+
|
|
13
|
+
- 0.6.2
|
|
14
|
+
|
|
15
|
+
- Fix support for compilation on 2.6, llvm compiles
|
|
16
|
+
- Stability patches to handle rare memory leaks
|
|
17
|
+
- Corrected re-raising of exceptions to support strings
|
|
18
|
+
- During early termination of context under certain conditions MiniRacer could crash
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
- 31-12-2021
|
|
22
|
+
|
|
23
|
+
- 0.6.1
|
|
24
|
+
|
|
25
|
+
- Added support for single threaded platform: `MiniRacer::Platform.set_flags! :single_threaded`
|
|
26
|
+
must be called prior to booting ANY MiniRacer::Context
|
|
27
|
+
|
|
28
|
+
- 0.6.0
|
|
29
|
+
|
|
30
|
+
- Ruby 3.1 support
|
|
31
|
+
- Fixes memory leak in heap snapshotting
|
|
32
|
+
- Improved compilation ergonomics in clang
|
|
33
|
+
- Migrated internal storage in c extension to TypedData
|
|
34
|
+
|
|
35
|
+
- 11-04-2021
|
|
36
|
+
|
|
37
|
+
- 0.5.0
|
|
38
|
+
- Fixes issues on aarch (Apple M1)
|
|
39
|
+
- Update to use libv8-node 16.x (#210) [Loic Nageleisen]
|
|
40
|
+
- FEATURE: Configurable max marshal stack depth (#202) [seanmakesgames]
|
|
41
|
+
- Ruby 2.3 and 2.4 are EOL, we no longer support them
|
|
42
|
+
|
|
43
|
+
- 0.4.0
|
|
44
|
+
|
|
45
|
+
- FEATURE: upgrade to libv8 node 15.14.0 (v8 8.6.395.17)
|
|
46
|
+
- Promote 0.4.0.beta1 to release, using libv8-node release path
|
|
47
|
+
|
|
48
|
+
- 08-04-2021
|
|
49
|
+
|
|
50
|
+
- 0.4.0.beta1
|
|
51
|
+
|
|
52
|
+
- FIX: on downgrade mkmf was picking the wrong version of libv8, this fix will correct future issues
|
|
53
|
+
- FEATURE: upgraded libv8 to use node libv8 build which supports M1 and various ARM builds v8 moved to (8.6.395.17)
|
|
54
|
+
|
|
55
|
+
- 23-07-2020
|
|
56
|
+
|
|
57
|
+
- 0.3.1
|
|
58
|
+
|
|
59
|
+
- FIX: specify that libv8 must be larger than 8.4.255 but smaller than 8.5, this avoids issues going forward
|
|
60
|
+
|
|
61
|
+
- 22-07-2020
|
|
62
|
+
|
|
63
|
+
- 0.3.0
|
|
64
|
+
|
|
65
|
+
- FEATURE: upgraded to libv8 version 8.4.255.0
|
|
66
|
+
|
|
67
|
+
- 29-06-2020
|
|
68
|
+
|
|
69
|
+
- 0.2.15
|
|
70
|
+
|
|
71
|
+
- FEATURE: basic wasm support via pump_message_loop
|
|
72
|
+
|
|
73
|
+
- 15-05-2020
|
|
74
|
+
|
|
75
|
+
- 0.2.14
|
|
76
|
+
|
|
77
|
+
- FIX: ensure_gc_after_idle should take in milliseconds like the rest of the APIs not seconds
|
|
78
|
+
- FEATURE: strict params on MiniRacer::Context.new
|
|
79
|
+
|
|
80
|
+
- 15-05-2020
|
|
81
|
+
|
|
82
|
+
- 0.2.13
|
|
83
|
+
|
|
84
|
+
- FIX: edge case around ensure_gc_after_idle possibly firing when context is not idle
|
|
85
|
+
|
|
86
|
+
- 15-05-2020
|
|
87
|
+
|
|
88
|
+
- 0.2.12
|
|
89
|
+
|
|
90
|
+
- FEATURE: isolate.low_memory_notification which can force a full GC
|
|
91
|
+
- FEATURE: MiniRacer::Context.new(ensure_gc_after_idle: 2) - to force full GC 2 seconds after context is idle, this allows you to conserve memory on isolates
|
|
92
|
+
|
|
93
|
+
- 14-05-2020
|
|
94
|
+
|
|
95
|
+
- 0.2.11
|
|
96
|
+
|
|
97
|
+
- FIX: dumping heap snapshots was not flushing the file leading to corrupt snapshots
|
|
98
|
+
- FIX: a use-after-free shutdown crash
|
|
99
|
+
|
|
100
|
+
- 0.2.10
|
|
101
|
+
|
|
102
|
+
- 22-04-2020
|
|
103
|
+
|
|
104
|
+
- FEATURE: memory softlimit support for nogvl_context_call
|
|
105
|
+
|
|
106
|
+
- 0.2.9
|
|
107
|
+
|
|
108
|
+
- 09-01-2020
|
|
109
|
+
|
|
110
|
+
- FIX: correct segfault when JS returns a Symbol and properly cast to ruby symbol
|
|
111
|
+
|
|
1
112
|
- 0.2.8
|
|
2
113
|
|
|
3
114
|
- 11-11-2019
|
data/Dockerfile
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
ARG RUBY_VERSION=2.7
|
|
2
|
+
FROM ruby:${RUBY_VERSION}
|
|
3
|
+
|
|
4
|
+
RUN test ! -f /etc/alpine-release || apk add --no-cache build-base git
|
|
5
|
+
|
|
6
|
+
# without this `COPY .git`, we get the following error:
|
|
7
|
+
# fatal: not a git repository (or any of the parent directories): .git
|
|
8
|
+
# but with it we need the full gem just to compile the extension because
|
|
9
|
+
# of gemspec's `git --ls-files`
|
|
10
|
+
# COPY .git /code/.git
|
|
11
|
+
COPY Gemfile mini_racer.gemspec /code/
|
|
12
|
+
COPY lib/mini_racer/version.rb /code/lib/mini_racer/version.rb
|
|
13
|
+
WORKDIR /code
|
|
14
|
+
RUN bundle install
|
|
15
|
+
|
|
16
|
+
COPY Rakefile /code/
|
|
17
|
+
COPY ext /code/ext/
|
|
18
|
+
RUN bundle exec rake compile
|
|
19
|
+
|
|
20
|
+
COPY . /code/
|
|
21
|
+
CMD bundle exec irb -rmini_racer
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# MiniRacer
|
|
2
2
|
|
|
3
|
-
[](https://github.com/rubyjs/mini_racer/actions/workflows/ci.yml)
|
|
4
4
|
|
|
5
5
|
Minimal, modern embedded V8 for Ruby.
|
|
6
6
|
|
|
@@ -12,7 +12,7 @@ MiniRacer has an adapter for [execjs](https://github.com/rails/execjs) so it can
|
|
|
12
12
|
|
|
13
13
|
### A note about Ruby version Support
|
|
14
14
|
|
|
15
|
-
MiniRacer only supports non-EOL versions of Ruby. See [Ruby](https://www.ruby-lang.org/en/downloads)
|
|
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
|
|
|
@@ -85,6 +85,19 @@ context.eval 'var a = new Array(10000); while(true) {a = a.concat(new Array(1000
|
|
|
85
85
|
# => V8OutOfMemoryError is raised
|
|
86
86
|
```
|
|
87
87
|
|
|
88
|
+
### Object marshal max stackdepth support
|
|
89
|
+
|
|
90
|
+
Contexts can specify a stack depth limit for object marshalling. Max depth is unbounded by default.
|
|
91
|
+
|
|
92
|
+
```ruby
|
|
93
|
+
# terminates script if stack depth exceeds max during marshal
|
|
94
|
+
context = MiniRacer::Context.new(marshal_stack_depth: 500)
|
|
95
|
+
context.attach("a", proc{|a| a})
|
|
96
|
+
|
|
97
|
+
context.eval("let arr = []; arr.push(arr); a(arr)")
|
|
98
|
+
# => RuntimeError is raised
|
|
99
|
+
```
|
|
100
|
+
|
|
88
101
|
### Rich debugging with "filename" support
|
|
89
102
|
|
|
90
103
|
```ruby
|
|
@@ -99,16 +112,21 @@ context.eval('bar()', filename: 'a/bar.js')
|
|
|
99
112
|
|
|
100
113
|
### Fork safety
|
|
101
114
|
|
|
102
|
-
Some Ruby web servers employ forking (for example unicorn or puma in clustered mode). V8 is not fork safe.
|
|
103
|
-
|
|
115
|
+
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).
|
|
116
|
+
|
|
117
|
+
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`:
|
|
118
|
+
|
|
119
|
+
```ruby
|
|
120
|
+
MiniRacer::Platform.set_flags!(:single_threaded)
|
|
121
|
+
```
|
|
104
122
|
|
|
105
123
|
If you want to ensure your application does not leak memory after fork either:
|
|
106
124
|
|
|
107
|
-
1. Ensure no MiniRacer::Context objects are created in the master process
|
|
125
|
+
1. Ensure no `MiniRacer::Context` objects are created in the master process
|
|
108
126
|
|
|
109
127
|
Or
|
|
110
128
|
|
|
111
|
-
2. Dispose manually of all MiniRacer::Context objects prior to forking
|
|
129
|
+
2. Dispose manually of all `MiniRacer::Context` objects prior to forking
|
|
112
130
|
|
|
113
131
|
```ruby
|
|
114
132
|
# before fork
|
|
@@ -230,12 +248,17 @@ context = MiniRacer::Context.new(isolate: isolate)
|
|
|
230
248
|
# give up to 100ms for V8 garbage collection
|
|
231
249
|
isolate.idle_notification(100)
|
|
232
250
|
|
|
251
|
+
# force V8 to perform a full GC
|
|
252
|
+
isolate.low_memory_notification
|
|
253
|
+
|
|
233
254
|
```
|
|
234
255
|
|
|
235
256
|
This can come in handy to force V8 GC runs for example in between requests if you use MiniRacer on a web application.
|
|
236
257
|
|
|
237
258
|
Note that this method maps directly to [`v8::Isolate::IdleNotification`](http://bespin.cz/~ondras/html/classv8_1_1Isolate.html#aea16cbb2e351de9a3ae7be2b7cb48297), and that in particular its return value is the same (true if there is no further garbage to collect, false otherwise) and the same caveats apply, in particular that `there is no guarantee that the [call will return] within the time limit.`
|
|
238
259
|
|
|
260
|
+
Additionally you may automate this process on a context by defining it with `MiniRacer::Content.new(ensure_gc_after_idle: 1000)`. Using this will ensure V8 will run a full GC using `context.isolate.low_memory_notification` 1 second after the last eval on the context. Low memory notification is both slower and more aggressive than an idle_notification and will ensure long living isolates use minimal amounts of memory.
|
|
261
|
+
|
|
239
262
|
### V8 Runtime flags
|
|
240
263
|
|
|
241
264
|
It is possible to set V8 Runtime flags:
|
|
@@ -244,7 +267,7 @@ It is possible to set V8 Runtime flags:
|
|
|
244
267
|
MiniRacer::Platform.set_flags! :noconcurrent_recompilation, max_inlining_levels: 10
|
|
245
268
|
```
|
|
246
269
|
|
|
247
|
-
This can come in handy if you want to use MiniRacer with Unicorn, which doesn't seem to
|
|
270
|
+
This can come in handy if you want to use MiniRacer with Unicorn, which doesn't seem to always appreciate V8's liberal use of threading:
|
|
248
271
|
```ruby
|
|
249
272
|
MiniRacer::Platform.set_flags! :noconcurrent_recompilation, :noconcurrent_sweeping
|
|
250
273
|
```
|
|
@@ -273,7 +296,7 @@ context.eval js
|
|
|
273
296
|
The same code without the harmony runtime flag results in a `MiniRacer::RuntimeError: RangeError: Maximum call stack size exceeded` exception.
|
|
274
297
|
Please refer to http://node.green/ as a reference on other harmony features.
|
|
275
298
|
|
|
276
|
-
A list of all V8 runtime flags can be found using `node --v8-options`, or else by perusing [the V8 source code for flags (make sure to use the right version of V8)](https://github.com/v8/v8/blob/master/src/flag-definitions.h).
|
|
299
|
+
A list of all V8 runtime flags can be found using `node --v8-options`, or else by perusing [the V8 source code for flags (make sure to use the right version of V8)](https://github.com/v8/v8/blob/master/src/flags/flag-definitions.h).
|
|
277
300
|
|
|
278
301
|
Note that runtime flags must be set before any other operation (e.g. creating a context, a snapshot or an isolate), otherwise an exception will be thrown.
|
|
279
302
|
|
|
@@ -310,6 +333,16 @@ context.eval("a = 2")
|
|
|
310
333
|
# nothing works on the context from now on, its a shell waiting to be disposed
|
|
311
334
|
```
|
|
312
335
|
|
|
336
|
+
A MiniRacer context can also be dumped in a heapsnapshot file using `#write_heap_snapshot(file_or_io)`
|
|
337
|
+
|
|
338
|
+
```ruby
|
|
339
|
+
context = MiniRacer::Context.new(timeout: 5)
|
|
340
|
+
context.eval("let a='testing';")
|
|
341
|
+
context.write_heap_snapshot("test.heapsnapshot")
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
This file can then be loaded in the memory tab of the chrome dev console.
|
|
345
|
+
|
|
313
346
|
### Function call
|
|
314
347
|
|
|
315
348
|
This calls the function passed as first argument:
|
|
@@ -388,21 +421,18 @@ Or install it yourself as:
|
|
|
388
421
|
$ gem install mini_racer
|
|
389
422
|
|
|
390
423
|
|
|
391
|
-
**Note** using v8.h and compiling MiniRacer requires a C++11 standard compiler, more specifically clang 3.5 (or later) or
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
## Travis-ci
|
|
424
|
+
**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).
|
|
395
425
|
|
|
396
|
-
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.
|
|
397
426
|
|
|
398
|
-
|
|
427
|
+
### Troubleshooting
|
|
399
428
|
|
|
400
|
-
|
|
429
|
+
If you have a problem installing mini_racer, please consider the following steps:
|
|
401
430
|
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
431
|
+
* make sure you try the latest released version of mini_racer
|
|
432
|
+
* make sure you have Rubygems >= 3.2.13 and bundler >= 2.2.13 installed via `gem update --system`
|
|
433
|
+
* if you are using bundler, make sure to have `PLATFORMS` set correctly in `Gemfile.lock` via `bundle lock --add-platform`
|
|
434
|
+
* make sure to recompile/reinstall `mini_racer` and `libv8-node` after system upgrades (for example via `gem uninstall --all mini_racer libv8-node`)
|
|
435
|
+
* make sure you are on the latest patch/teeny version of a supported Ruby branch
|
|
406
436
|
|
|
407
437
|
## Similar Projects
|
|
408
438
|
|
|
@@ -447,7 +477,7 @@ Add this to your .travis.yml file:
|
|
|
447
477
|
|
|
448
478
|
## Contributing
|
|
449
479
|
|
|
450
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
|
480
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/rubyjs/mini_racer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
451
481
|
|
|
452
482
|
|
|
453
483
|
## License
|
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,7 +10,21 @@ end
|
|
|
11
10
|
task :default => [:compile, :test]
|
|
12
11
|
|
|
13
12
|
gem = Gem::Specification.load( File.dirname(__FILE__) + '/mini_racer.gemspec' )
|
|
14
|
-
|
|
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
|
+
|
|
15
28
|
|
|
16
29
|
|
|
17
30
|
# via http://blog.flavorjon.es/2009/06/easily-valgrind-gdb-your-ruby-c.html
|
|
@@ -91,5 +104,5 @@ task :lint do
|
|
|
91
104
|
portability-*
|
|
92
105
|
readability-*).join(',')
|
|
93
106
|
|
|
94
|
-
sh RbConfig::expand("clang-tidy -checks='#{checks}' ext/mini_racer_extension/mini_racer_extension.cc -- #$INCFLAGS #$
|
|
107
|
+
sh RbConfig::expand("clang-tidy -checks='#{checks}' ext/mini_racer_extension/mini_racer_extension.cc -- #$INCFLAGS #$CXXFLAGS", conf)
|
|
95
108
|
end
|
|
@@ -1,20 +1,41 @@
|
|
|
1
1
|
require 'mkmf'
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
if RUBY_ENGINE == "truffleruby"
|
|
4
|
+
File.write("Makefile", dummy_makefile($srcdir).join(""))
|
|
5
|
+
return
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
require_relative '../../lib/mini_racer/version'
|
|
9
|
+
gem 'libv8-node', MiniRacer::LIBV8_NODE_VERSION
|
|
10
|
+
require 'libv8-node'
|
|
3
11
|
|
|
4
12
|
IS_DARWIN = RUBY_PLATFORM =~ /darwin/
|
|
5
13
|
|
|
6
14
|
have_library('pthread')
|
|
7
15
|
have_library('objc') if IS_DARWIN
|
|
8
|
-
$
|
|
9
|
-
$
|
|
10
|
-
$
|
|
11
|
-
$
|
|
12
|
-
$
|
|
13
|
-
$
|
|
14
|
-
|
|
15
|
-
$
|
|
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
|
|
16
35
|
|
|
17
|
-
|
|
36
|
+
# check for missing symbols at link time
|
|
37
|
+
# $LDFLAGS += " -Wl,--no-undefined " unless IS_DARWIN
|
|
38
|
+
# $LDFLAGS += " -Wl,-undefined,error " if IS_DARWIN
|
|
18
39
|
|
|
19
40
|
if ENV['CXX']
|
|
20
41
|
puts "SETTING CXX"
|
|
@@ -53,11 +74,19 @@ if enable_config('debug') || enable_config('asan')
|
|
|
53
74
|
CONFIG['debugflags'] << ' -ggdb3 -O0'
|
|
54
75
|
end
|
|
55
76
|
|
|
56
|
-
Libv8.configure_makefile
|
|
77
|
+
Libv8::Node.configure_makefile
|
|
78
|
+
|
|
79
|
+
# --exclude-libs is only for i386 PE and ELF targeted ports
|
|
80
|
+
append_ldflags("-Wl,--exclude-libs=ALL ")
|
|
57
81
|
|
|
58
82
|
if enable_config('asan')
|
|
59
|
-
$
|
|
83
|
+
$CXXFLAGS.insert(0, " -fsanitize=address ")
|
|
60
84
|
$LDFLAGS.insert(0, " -fsanitize=address ")
|
|
61
85
|
end
|
|
62
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
|
+
|
|
63
92
|
create_makefile 'mini_racer_extension'
|