How to InitializePlatform() using only stable APIs

52 views
Skip to first unread message

Jeroen Ooms

unread,
Jun 25, 2021, 12:08:25 PM6/25/21
to v8-users
Hello,

I maintain V8 bindings for the R programming language: https://github.com/jeroen/V8/blob/master/src/bindings.cpp 

On most Linux distros such as Debian, Ubuntu, and Fedora, the version of libv8 from the distro is actually an LTS version provided by nodejs, which has worked great for several years. However as of node-16 earlier this year, they now only ships a limited set of V8 API headers which are considered 'stable'; effectively only the top level v8-*.h headers, see: https://github.com/nodejs/node/pull/37570

This is causing a problem for bindings like ours, because the libplatform/libplatform.h header is not part of those headers. But as I understand it, the only way to initiate V8 is by calling v8::V8::InitializePlatform() and passing an argument obtained from v8::platform::NewDefaultPlatform(). However the latter is only exposed in libplatform.h.

Would there be an alternative way to initiate V8 that does not require any API calls from libplatform/libplatform.h? Or alternatively, would it be possible to expose the NewDefaultPlatform() API in v8.h alongside v8::V8::InitializePlatform() ? Or perhaps yet another option: could InitializePlatform() be modified such that it can be called without arguments, in which case it will internally call NewDefaultPlatform() and return that?

Another simper to phrase this question: how can we modify the V8 hello-world.cc in a way that it does not need libplatform.h? https://chromium.googlesource.com/v8/v8/+/refs/heads/main/samples/hello-world.cc

Jeroen




Reply all
Reply to author
Forward
0 new messages