mini_racer 0.1.11 → 0.4.0

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
- SHA1:
3
- metadata.gz: 2ca732b2c61155dabc302651ff23710eec5ba8f2
4
- data.tar.gz: 86fbba234f3afeaffcf246b9b9b672d43ae51944
2
+ SHA256:
3
+ metadata.gz: e73ac3193df3f33b51463ba1125ac4eee312caecd47833c545e098ba91d11ece
4
+ data.tar.gz: d6d754829b36953d239ba85e84d2fc88c0af3ccbadd3f8d2e4cd9759bd24fab2
5
5
  SHA512:
6
- metadata.gz: 41c0b2636421257216148a8e1317a463e10407d73259b8ab009a2a4e2fee1770b04ee2ef0e906f84c097d909ebf11577c571ff5f66a2c15ca2530ae30025a909
7
- data.tar.gz: 68538bb4f8b85ab630027f9e5c965e03a159621505d597c8e2ef41765593d4fd8b92eb9401a71f1ed89557976da018ae694d90e4b03ce1013a7afd885319958f
6
+ metadata.gz: 52a0799d84be10bb03774789b3d12d4f0fe2d4159d310b9c6a1ae3dcf878a99cd6b7c786fae813f29754a894ecf5fcc6b7e07834c0aba994a16da5c54d75595b
7
+ data.tar.gz: bc478bdb582d7b786d28754200063d7ef185396e0da23840f006679bc1af6707f54c7a719918360afa9b24c2b4ab083ca081e2b2d6853095ecd5949a9482ecbd
data/.dockerignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ lib/mini_racer_extension.so
11
+ lib/mini_racer_loader.so
12
+ *.bundle
@@ -0,0 +1,80 @@
1
+ name: Test
2
+ on:
3
+ - push
4
+
5
+ jobs:
6
+ test-darwin:
7
+ strategy:
8
+ fail-fast: false
9
+ matrix:
10
+ os:
11
+ - '10.15'
12
+ - '11.0'
13
+ platform:
14
+ - x86_64
15
+ # arm64
16
+ name: Test (darwin)
17
+ runs-on: macos-${{ matrix.os }}
18
+ steps:
19
+ - name: Checkout
20
+ uses: actions/checkout@v2
21
+ - name: Bundle
22
+ run: bundle install
23
+ - name: Compile
24
+ run: bundle exec rake compile
25
+ - name: Test
26
+ run: bundle exec rake test
27
+ test-linux:
28
+ strategy:
29
+ fail-fast: false
30
+ matrix:
31
+ ruby:
32
+ - '2.4'
33
+ - '2.5'
34
+ - '2.6'
35
+ - '2.7'
36
+ - '3.0'
37
+ platform:
38
+ - amd64
39
+ - arm64
40
+ # arm
41
+ # ppc64le
42
+ # s390x
43
+ libc:
44
+ - gnu
45
+ - musl
46
+ name: Test (linux)
47
+ runs-on: ubuntu-20.04
48
+ steps:
49
+ - name: Enable ${{ matrix.platform }} platform
50
+ id: qemu
51
+ if: ${{ matrix.platform != 'amd64' }}
52
+ run: |
53
+ docker run --privileged --rm tonistiigi/binfmt:latest --install ${{ matrix.platform }} | tee platforms.json
54
+ echo "::set-output name=platforms::$(cat platforms.json)"
55
+ - name: Start container
56
+ id: container
57
+ run: |
58
+ case ${{ matrix.libc }} in
59
+ gnu)
60
+ echo 'ruby:${{ matrix.ruby }}'
61
+ ;;
62
+ musl)
63
+ echo 'ruby:${{ matrix.ruby }}-alpine'
64
+ ;;
65
+ esac > container_image
66
+ echo "::set-output name=image::$(cat container_image)"
67
+ docker run --rm -d -v "${PWD}":"${PWD}" -w "${PWD}" --platform linux/${{ matrix.platform }} $(cat container_image) /bin/sleep 64d | tee container_id
68
+ docker exec -w "${PWD}" $(cat container_id) uname -a
69
+ echo "::set-output name=id::$(cat container_id)"
70
+ - name: Install Alpine system dependencies
71
+ 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
73
+ - name: Checkout
74
+ uses: actions/checkout@v2
75
+ - name: Bundle
76
+ run: docker exec -w "${PWD}" ${{ steps.container.outputs.id }} bundle install
77
+ - name: Compile
78
+ run: docker exec -w "${PWD}" ${{ steps.container.outputs.id }} bundle exec rake compile
79
+ - name: Test
80
+ run: docker exec -w "${PWD}" ${{ steps.container.outputs.id }} bundle exec rake test
data/.gitignore CHANGED
@@ -8,4 +8,5 @@ Gemfile.lock
8
8
  /spec/reports/
9
9
  /tmp/
10
10
  lib/mini_racer_extension.so
11
+ lib/mini_racer_loader.so
11
12
  *.bundle
data/.travis.yml CHANGED
@@ -1,19 +1,31 @@
1
1
  language: ruby
2
+ os: linux
2
3
  rvm:
3
- - 2.1
4
- - 2.2
5
- - 2.3.3
6
- - 2.4.0
7
- matrix:
4
+ - 2.4
5
+ - 2.5
6
+ - 2.6
7
+ - 2.7
8
+ - 3.0
9
+ - ruby-head
10
+ arch:
11
+ - amd64
12
+ - arm64
13
+ jobs:
8
14
  include:
9
- - rvm: 2.4.0
15
+ - rvm: 2.5
10
16
  os: osx
11
- osx_image: xcode8.2
12
- - rvm: 2.4.0
17
+ osx_image: xcode9.4
18
+ - rvm: 2.6
13
19
  os: osx
14
- osx_image: xcode7.3
15
- dist: trusty
16
- sudo: true
20
+ osx_image: xcode11.3
21
+ - rvm: 2.6
22
+ os: osx
23
+ osx_image: xcode12.2
24
+ - rvm: 2.7
25
+ os: osx
26
+ osx_image: xcode12.2
27
+ dist: xenial
17
28
  before_install:
18
- - gem install bundler -v 1.12.0
29
+ - gem update --system
30
+ - gem install bundler -v 1.16.2
19
31
  cache: bundler
data/CHANGELOG CHANGED
@@ -1,3 +1,164 @@
1
+ - 11-04-2021
2
+
3
+ - 0.4.0
4
+
5
+ - FEATURE: upgrade to libv8 node 15.14.0 (v8 8.6.395.17)
6
+ - Promote 0.4.0.beta1 to release, using libv8-node release path
7
+
8
+ - 08-04-2021
9
+
10
+ - 0.4.0.beta1
11
+
12
+ - FIX: on downgrade mkmf was picking the wrong version of libv8, this fix will correct future issues
13
+ - FEATURE: upgraded libv8 to use node libv8 build which supports M1 and various ARM builds v8 moved to (8.6.395.17)
14
+
15
+ - 23-07-2020
16
+
17
+ - 0.3.1
18
+
19
+ - FIX: specify that libv8 must be larger than 8.4.255 but smaller than 8.5, this avoids issues going forward
20
+
21
+ - 22-07-2020
22
+
23
+ - 0.3.0
24
+
25
+ - FEATURE: upgraded to libv8 version 8.4.255.0
26
+
27
+ - 29-06-2020
28
+
29
+ - 0.2.15
30
+
31
+ - FEATURE: basic wasm support via pump_message_loop
32
+
33
+ - 15-05-2020
34
+
35
+ - 0.2.14
36
+
37
+ - FIX: ensure_gc_after_idle should take in milliseconds like the rest of the APIs not seconds
38
+ - FEATURE: strict params on MiniRacer::Context.new
39
+
40
+ - 15-05-2020
41
+
42
+ - 0.2.13
43
+
44
+ - FIX: edge case around ensure_gc_after_idle possibly firing when context is not idle
45
+
46
+ - 15-05-2020
47
+
48
+ - 0.2.12
49
+
50
+ - FEATURE: isolate.low_memory_notification which can force a full GC
51
+ - 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
52
+
53
+ - 14-05-2020
54
+
55
+ - 0.2.11
56
+
57
+ - FIX: dumping heap snapshots was not flushing the file leading to corrupt snapshots
58
+ - FIX: a use-after-free shutdown crash
59
+
60
+ - 0.2.10
61
+
62
+ - 22-04-2020
63
+
64
+ - FEATURE: memory softlimit support for nogvl_context_call
65
+
66
+ - 0.2.9
67
+
68
+ - 09-01-2020
69
+
70
+ - FIX: correct segfault when JS returns a Symbol and properly cast to ruby symbol
71
+
72
+ - 0.2.8
73
+
74
+ - 11-11-2019
75
+
76
+ - FIX: ensure thread live cycle is properly accounter for following file descriptor fix
77
+
78
+ - 0.2.7
79
+
80
+ - 11-11-2019
81
+
82
+ - FIX: release the file descriptor for timeout pipe earlier (this avoids holding too many files open in Ruby 2.7)
83
+
84
+ - 14-05-2019
85
+
86
+ - 0.2.6
87
+
88
+ - FEATURE: add support for write_heap_snapshot which helps you analyze memory
89
+
90
+ - 25-04-2019
91
+
92
+ - 0.2.5
93
+
94
+ - FIX: Compatiblity fixes for V8 7 and above @ignisf
95
+ - FIX: Memory leak in gc_callback @messense
96
+ - IMPROVEMENT: Added example of sourcemap support @ianks
97
+ - URGENT: you will need this release for latest version of libv8 to work
98
+
99
+ - 02-11-2018
100
+
101
+ - 0.2.4
102
+
103
+ - FIX: deadlock releasing context when shared isolates are used
104
+ - FEATURE: include js backtrace when snapshots do not compile
105
+
106
+ - 28-09-2018
107
+
108
+ - 0.2.3
109
+
110
+ - Drop all conditional logic from Mini Racer compilation for clang, always
111
+ rely on MacOS being High Sierra or up
112
+
113
+ - 26-09-2018
114
+
115
+ - 0.2.2
116
+
117
+ - WORKAROUND: RUBY_PLATFORM is hardcoded on Ruby compile and can not be
118
+ trusted for feature detection, use a different technique when checking for
119
+ macOS Mojave
120
+
121
+ - 25-09-2018
122
+
123
+ - 0.2.1
124
+
125
+ - FEATURE: Mojave macOS support
126
+
127
+ - 06-07-2018
128
+
129
+ - 0.2.0
130
+ - FEATURE: context#call to allow for cheaper invocation of functions
131
+ - FIX: rare memory leak when terminating a long running attached function
132
+ - FIX: rare segfault when terminating a long running attached function
133
+ - FIX: Reimplement Isolate#idle_notification using idle_notification_deadline, API remains the same @ignisf
134
+ - Account for changes in the upstream V8 API @ignisf
135
+ - Support for libv8 6.7
136
+
137
+ 23-08-2017
138
+
139
+ - 0.1.15
140
+
141
+ - bump dependency of libv8 to 6.3
142
+
143
+ 23-08-2017
144
+
145
+ - 0.1.14
146
+
147
+ - libv8 erronuously bumped to beta, reverted change
148
+
149
+ 23-08-2017
150
+
151
+ - 0.1.13
152
+
153
+ - Fix: amend array buffer allocator to use v8 6.0 compatible allocator @ignisf
154
+
155
+ 18-07-2017
156
+
157
+ - 0.1.12
158
+
159
+ - Feature: upgrade libv8 to 5.9
160
+ - Fix: warning when runnin with ruby warnings enabled (missed @disposed initialize)
161
+
1
162
  18-07-2017
2
163
 
3
164
  - 0.1.11
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/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2016 TODO: Write your name
3
+ Copyright (c) 2016-2019, the mini_racer project authors.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MiniRacer
2
2
 
3
- [![Build Status](https://travis-ci.org/discourse/mini_racer.svg?branch=master)](https://travis-ci.org/discourse/mini_racer)
3
+ [![Build Status](https://travis-ci.org/rubyjs/mini_racer.svg?branch=master)](https://travis-ci.org/rubyjs/mini_racer)
4
4
 
5
5
  Minimal, modern embedded V8 for Ruby.
6
6
 
@@ -10,6 +10,12 @@ 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
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.
16
+
17
+ If you require support for older versions of Ruby install an older version of the gem.
18
+
13
19
  ## Features
14
20
 
15
21
  ### Simple eval for JavaScript
@@ -68,6 +74,17 @@ context.eval 'while(true){}'
68
74
  # => exception is raised
69
75
  ```
70
76
 
77
+ ### Memory softlimit support
78
+
79
+ Contexts can specify a memory softlimit for scripts
80
+
81
+ ```ruby
82
+ # terminates script if heap usage exceeds 200mb after V8 garbage collection has run
83
+ context = MiniRacer::Context.new(max_memory: 200000000)
84
+ context.eval 'var a = new Array(10000); while(true) {a = a.concat(new Array(10000)); print("loop " + a.length);}'
85
+ # => V8OutOfMemoryError is raised
86
+ ```
87
+
71
88
  ### Rich debugging with "filename" support
72
89
 
73
90
  ```ruby
@@ -80,6 +97,27 @@ context.eval('bar()', filename: 'a/bar.js')
80
97
 
81
98
  ```
82
99
 
100
+ ### Fork safety
101
+
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).
104
+
105
+ If you want to ensure your application does not leak memory after fork either:
106
+
107
+ 1. Ensure no MiniRacer::Context objects are created in the master process
108
+
109
+ Or
110
+
111
+ 2. Dispose manually of all MiniRacer::Context objects prior to forking
112
+
113
+ ```ruby
114
+ # before fork
115
+
116
+ require 'objspace'
117
+ ObjectSpace.each_object(MiniRacer::Context){|c| c.dispose}
118
+
119
+ # fork here
120
+ ```
83
121
 
84
122
  ### Threadsafe
85
123
 
@@ -192,12 +230,17 @@ context = MiniRacer::Context.new(isolate: isolate)
192
230
  # give up to 100ms for V8 garbage collection
193
231
  isolate.idle_notification(100)
194
232
 
233
+ # force V8 to perform a full GC
234
+ isolate.low_memory_notification
235
+
195
236
  ```
196
237
 
197
238
  This can come in handy to force V8 GC runs for example in between requests if you use MiniRacer on a web application.
198
239
 
199
240
  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.`
200
241
 
242
+ 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.
243
+
201
244
  ### V8 Runtime flags
202
245
 
203
246
  It is possible to set V8 Runtime flags:
@@ -206,7 +249,7 @@ It is possible to set V8 Runtime flags:
206
249
  MiniRacer::Platform.set_flags! :noconcurrent_recompilation, max_inlining_levels: 10
207
250
  ```
208
251
 
209
- This can come in handy if you want to use MiniRacer with Unicorn, which doesn't seem to alwatys appreciate V8's liberal use of threading:
252
+ 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:
210
253
  ```ruby
211
254
  MiniRacer::Platform.set_flags! :noconcurrent_recompilation, :noconcurrent_sweeping
212
255
  ```
@@ -235,7 +278,7 @@ context.eval js
235
278
  The same code without the harmony runtime flag results in a `MiniRacer::RuntimeError: RangeError: Maximum call stack size exceeded` exception.
236
279
  Please refer to http://node.green/ as a reference on other harmony features.
237
280
 
238
- 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).
281
+ 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).
239
282
 
240
283
  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.
241
284
 
@@ -272,6 +315,32 @@ context.eval("a = 2")
272
315
  # nothing works on the context from now on, its a shell waiting to be disposed
273
316
  ```
274
317
 
318
+ A MiniRacer context can also be dumped in a heapsnapshot file using `#write_heap_snapshot(file_or_io)`
319
+
320
+ ```ruby
321
+ context = MiniRacer::Context.new(timeout: 5)
322
+ context.eval("let a='testing';")
323
+ context.write_heap_snapshot("test.heapsnapshot")
324
+ ```
325
+
326
+ This file can then be loaded in the memory tab of the chrome dev console.
327
+
328
+ ### Function call
329
+
330
+ This calls the function passed as first argument:
331
+
332
+ ```ruby
333
+ context = MiniRacer::Context.new
334
+ context.eval('function hello(name) { return "Hello, " + name + "!" }')
335
+ context.call('hello', 'George')
336
+ # "Hello, George!"
337
+ ```
338
+
339
+ Performance is slightly better than running `eval('hello("George")')` since:
340
+
341
+ - compilation of eval'd string is avoided
342
+ - function arguments don't need to be converted to JSON
343
+
275
344
  ## Performance
276
345
 
277
346
  The `bench` folder contains benchmark.
@@ -313,6 +382,10 @@ Note how the global interpreter lock release leads to 2 threads doing the same w
313
382
 
314
383
  As a rule MiniRacer strives to always support and depend on the latest stable version of libv8.
315
384
 
385
+ ## Source Maps
386
+
387
+ MiniRacer can fully support source maps but must be configured correctly to do so. [Check out this example](./examples/source-map-support/) for a working implementation.
388
+
316
389
  ## Installation
317
390
 
318
391
  Add this line to your application's Gemfile:
@@ -389,7 +462,7 @@ Add this to your .travis.yml file:
389
462
 
390
463
  ## Contributing
391
464
 
392
- Bug reports and pull requests are welcome on GitHub at https://github.com/discourse/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.
465
+ 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.
393
466
 
394
467
 
395
468
  ## License
data/Rakefile CHANGED
@@ -11,11 +11,28 @@ end
11
11
  task :default => [:compile, :test]
12
12
 
13
13
  gem = Gem::Specification.load( File.dirname(__FILE__) + '/mini_racer.gemspec' )
14
+ Rake::ExtensionTask.new( 'mini_racer_loader', gem )
14
15
  Rake::ExtensionTask.new( 'mini_racer_extension', gem )
15
16
 
16
17
 
17
18
  # via http://blog.flavorjon.es/2009/06/easily-valgrind-gdb-your-ruby-c.html
18
19
  namespace :test do
20
+ desc "run test suite with Address Sanitizer"
21
+ task :asan do
22
+ ENV["CONFIGURE_ARGS"] = [ENV["CONFIGURE_ARGS"], '--enable-asan'].compact.join(' ')
23
+ Rake::Task['compile'].invoke
24
+
25
+ asan_path = `ldconfig -N -p |grep libasan | grep -v 32 | sed 's/.* => \\(.*\\)$/\\1/'`.chomp.split("\n")[-1]
26
+
27
+
28
+ cmdline = "env LD_PRELOAD=\"#{asan_path}\" ruby test/test_leak.rb"
29
+ puts cmdline
30
+ system cmdline
31
+
32
+ cmdline = "env LD_PRELOAD=\"#{asan_path}\" rake test"
33
+ puts cmdline
34
+ system cmdline
35
+ end
19
36
  # partial-loads-ok and undef-value-errors necessary to ignore
20
37
  # spurious (and eminently ignorable) warnings from the ruby
21
38
  # interpreter
@@ -52,3 +69,28 @@ namespace :test do
52
69
  end
53
70
  end
54
71
  end
72
+
73
+ desc 'run clang-tidy linter on mini_racer_extension.cc'
74
+ task :lint do
75
+ require 'mkmf'
76
+ require 'libv8'
77
+
78
+ Libv8.configure_makefile
79
+
80
+ conf = RbConfig::CONFIG.merge('hdrdir' => $hdrdir.quote, 'srcdir' => $srcdir.quote,
81
+ 'arch_hdrdir' => $arch_hdrdir.quote,
82
+ 'top_srcdir' => $top_srcdir.quote)
83
+ if $universal and (arch_flag = conf['ARCH_FLAG']) and !arch_flag.empty?
84
+ conf['ARCH_FLAG'] = arch_flag.gsub(/(?:\G|\s)-arch\s+\S+/, '')
85
+ end
86
+
87
+ checks = %W(bugprone-*
88
+ cert-*
89
+ cppcoreguidelines-*
90
+ clang-analyzer-*
91
+ performance-*
92
+ portability-*
93
+ readability-*).join(',')
94
+
95
+ sh RbConfig::expand("clang-tidy -checks='#{checks}' ext/mini_racer_extension/mini_racer_extension.cc -- #$INCFLAGS #$CPPFLAGS", conf)
96
+ end
@@ -1,16 +1,28 @@
1
1
  require 'mkmf'
2
- require 'libv8'
2
+ require_relative '../../lib/mini_racer/version'
3
+ gem 'libv8-node', MiniRacer::LIBV8_NODE_VERSION
4
+ require 'libv8-node'
5
+
6
+ IS_DARWIN = RUBY_PLATFORM =~ /darwin/
3
7
 
4
8
  have_library('pthread')
5
- have_library('objc') if RUBY_PLATFORM =~ /darwin/
9
+ have_library('objc') if IS_DARWIN
6
10
  $CPPFLAGS += " -Wall" unless $CPPFLAGS.split.include? "-Wall"
7
11
  $CPPFLAGS += " -g" unless $CPPFLAGS.split.include? "-g"
8
12
  $CPPFLAGS += " -rdynamic" unless $CPPFLAGS.split.include? "-rdynamic"
9
- $CPPFLAGS += " -fPIC" unless $CPPFLAGS.split.include? "-rdynamic" or RUBY_PLATFORM =~ /darwin/
13
+ $CPPFLAGS += " -fPIC" unless $CPPFLAGS.split.include? "-rdynamic" or IS_DARWIN
10
14
  $CPPFLAGS += " -std=c++0x"
11
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
12
22
 
13
- $LDFLAGS.insert 0, " -stdlib=libstdc++ " if RUBY_PLATFORM =~ /darwin/
23
+ # check for missing symbols at link time
24
+ # $LDFLAGS += " -Wl,--no-undefined " unless IS_DARWIN
25
+ # $LDFLAGS += " -Wl,-undefined,error " if IS_DARWIN
14
26
 
15
27
  if ENV['CXX']
16
28
  puts "SETTING CXX"
@@ -39,16 +51,21 @@ installing GCC 4.8. See mini_racer's README.md for more information.
39
51
  EOS
40
52
  end
41
53
 
42
- CONFIG['LDSHARED'] = '$(CXX) -shared' unless RUBY_PLATFORM =~ /darwin/
54
+ CONFIG['LDSHARED'] = '$(CXX) -shared' unless IS_DARWIN
43
55
  if CONFIG['warnflags']
44
56
  CONFIG['warnflags'].gsub!('-Wdeclaration-after-statement', '')
45
57
  CONFIG['warnflags'].gsub!('-Wimplicit-function-declaration', '')
46
58
  end
47
59
 
48
- if enable_config('debug')
60
+ if enable_config('debug') || enable_config('asan')
49
61
  CONFIG['debugflags'] << ' -ggdb3 -O0'
50
62
  end
51
63
 
52
- Libv8.configure_makefile
64
+ Libv8::Node.configure_makefile
65
+
66
+ if enable_config('asan')
67
+ $CPPFLAGS.insert(0, " -fsanitize=address ")
68
+ $LDFLAGS.insert(0, " -fsanitize=address ")
69
+ end
53
70
 
54
71
  create_makefile 'mini_racer_extension'