Skip to content

Commit 9ccb947

Browse files
authored
V8 build fixes for x86 (#91)
Pointer compression, etc. cannot be on for x86 builds when targeting V8. V8 compile will currently fail if pointer compression is turned on: > Pointer compression can be enabled only for 64-bit architectures See https://github.com/v8/v8/blob/main/include/v8-internal.h#L165-L167 This change just makes it such that the macros are defined only for x64.
1 parent 5c06ce7 commit 9ccb947

File tree

5 files changed

+28
-20
lines changed

5 files changed

+28
-20
lines changed

Core/AppRuntime/V8Inspector/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ target_include_directories(v8inspector
1919
PRIVATE "${llhttp_SOURCE_DIR}/include")
2020

2121
target_compile_definitions(v8inspector
22-
PRIVATE ASIO_STANDALONE)
22+
PRIVATE ASIO_STANDALONE
23+
PRIVATE NOMINMAX)
2324

2425
target_link_libraries(v8inspector
2526
PRIVATE asio

Core/AppRuntime/V8Inspector/Include/V8Inc.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
#pragma once
22

3-
// Enable V8 Pointer Compression
4-
// https://v8.dev/blog/pointer-compression
5-
// https://stackoverflow.com/q/62921373
3+
#include <stdint.h>
4+
5+
#if INTPTR_MAX == INT64_MAX
66
#ifndef V8_COMPRESS_POINTERS
77
#define V8_COMPRESS_POINTERS 1
88
#endif
9-
10-
// Enable V8 Sandbox
11-
// https://v8.dev/blog/sandbox
9+
#ifndef V8_31BIT_SMIS_ON_64BIT_ARCH
10+
#define V8_31BIT_SMIS_ON_64BIT_ARCH 1
11+
#endif
1212
#ifndef V8_ENABLE_SANDBOX
1313
#define V8_ENABLE_SANDBOX 1
1414
#endif
15+
#endif
1516

1617
#ifdef _MSC_VER
1718
#pragma warning(push)

Core/Node-API/Include/Engine/V8/napi/env.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@
22

33
#include <napi/napi.h>
44

5-
// Enable V8 Pointer Compression
6-
// https://v8.dev/blog/pointer-compression
7-
// https://stackoverflow.com/q/62921373
5+
#include <stdint.h>
6+
7+
#if INTPTR_MAX == INT64_MAX
88
#ifndef V8_COMPRESS_POINTERS
99
#define V8_COMPRESS_POINTERS 1
1010
#endif
11-
12-
// Enable V8 Sandbox
13-
// https://v8.dev/blog/sandbox
11+
#ifndef V8_31BIT_SMIS_ON_64BIT_ARCH
12+
#define V8_31BIT_SMIS_ON_64BIT_ARCH 1
13+
#endif
1414
#ifndef V8_ENABLE_SANDBOX
1515
#define V8_ENABLE_SANDBOX 1
1616
#endif
17+
#endif
1718

1819
#ifdef __clang__
1920
#pragma clang diagnostic push

Core/Node-API/Source/js_native_api_v8_internals.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,21 @@
1313
// are bridged to remove references to the `node` namespace. `node_version.h`,
1414
// included below, defines `NAPI_VERSION`.
1515

16-
// [BABYLON-NATIVE-ADDITION]: Enable V8 Pointer Compression
17-
// https://v8.dev/blog/pointer-compression
18-
// https://stackoverflow.com/q/62921373
16+
// [BABYLON-NATIVE-ADDITION]: For INTPTR_MAX and INT64_MAX
17+
#include <stdint.h>
18+
19+
// [BABYLON-NATIVE-ADDITION]: Enable V8 Pointer Compression and Sandbox for 64-bit architecture
20+
#if INTPTR_MAX == INT64_MAX
1921
#ifndef V8_COMPRESS_POINTERS
2022
#define V8_COMPRESS_POINTERS 1
2123
#endif
22-
23-
// [BABYLON-NATIVE-ADDITION]: Enable V8 Sandbox
24-
// https://v8.dev/blog/sandbox
24+
#ifndef V8_31BIT_SMIS_ON_64BIT_ARCH
25+
#define V8_31BIT_SMIS_ON_64BIT_ARCH 1
26+
#endif
2527
#ifndef V8_ENABLE_SANDBOX
2628
#define V8_ENABLE_SANDBOX 1
2729
#endif
30+
#endif
2831

2932
#include <v8.h>
3033
#include <cassert>

Tests/UnitTests/Android/gradle.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,6 @@ android.useAndroidX=true
1818
# Enables namespacing of each library's R class so that its R class includes only the
1919
# resources declared in the library itself and none from the library's dependencies,
2020
# thereby reducing the size of the R class for that library
21-
android.nonTransitiveRClass=true
21+
android.nonTransitiveRClass=true
22+
# Select the JavaScript engine to use
23+
#jsEngine=JavaScriptCore

0 commit comments

Comments
 (0)