0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-09-08 00:25:19 +00:00

auto-detect V8 sandbox and call InitializeSandbox if needed

This commit is contained in:
Stefan Siegl 2022-06-27 18:00:49 +02:00
parent 32d8dd8dec
commit 26de750e8e
2 changed files with 19 additions and 1 deletions

View File

@ -177,6 +177,24 @@ int main ()
V8_SEARCH_BLOB([snapshot_blob.bin], [PHP_V8_SNAPSHOT_BLOB_PATH])
dnl
dnl Check for v8::V8::InitializeSandbox
dnl
AC_CACHE_CHECK([for v8::V8::InitializeSandbox], ac_cv_has_initialize_sandbox, [
AC_LINK_IFELSE([AC_LANG_PROGRAM([
#define V8_ENABLE_SANDBOX 1
#include <v8.h>
], [ v8::V8::InitializeSandbox(); ])], [
ac_cv_has_initialize_sandbox=yes
], [
ac_cv_has_initialize_sandbox=no
])
])
if test "x$ac_cv_has_initialize_sandbox" = "xyes"; then
AC_DEFINE([V8_HAS_INITIALIZE_SANDBOX], [1],
[Define if V8::InitializeSandbox must be called.])
fi
dnl
dnl Check for v8::ArrayBuffer::Allocator::NewDefaultAllocator
dnl

View File

@ -71,7 +71,7 @@ void v8js_v8_init() /* {{{ */
v8js_process_globals.v8_platform = v8::platform::NewDefaultPlatform();
v8::V8::InitializePlatform(v8js_process_globals.v8_platform.get());
#ifdef V8_ENABLE_SANDBOX
#ifdef V8_HAS_INITIALIZE_SANDBOX
v8::V8::InitializeSandbox();
#endif