-
Notifications
You must be signed in to change notification settings - Fork 15k
/
do_not_export_private_v8_symbols_on_windows.patch
52 lines (45 loc) · 1.69 KB
/
do_not_export_private_v8_symbols_on_windows.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Tomas Rycl <torycl@microsoft.com>
Date: Mon, 13 May 2019 15:48:48 +0200
Subject: Do not export private V8 symbols on Windows
This change stops private V8 symbols and internal crt methods being exported.
It fixes an issue where native node modules can import
incorrect CRT methods and crash on Windows.
It also reduces size of node.lib by 75%.
This patch can be safely removed if, when it is removed, `node.lib` does not
contain any standard C++ library exports (e.g. `std::ostringstream`).
diff --git a/BUILD.gn b/BUILD.gn
index da035d3afac94617d163197156dc2871be6c4be3..07fd11838469c4296f50d21a5f7941570293cd58 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -411,6 +411,10 @@ config("internal_config") {
":v8_header_features",
]
+ if (!is_component_build && is_electron_build) {
+ defines += [ "HIDE_PRIVATE_SYMBOLS" ]
+ }
+
if (is_component_build || is_electron_build) {
defines += [ "BUILDING_V8_SHARED" ]
}
diff --git a/src/base/macros.h b/src/base/macros.h
index 37cab78f08fcbc859d549a3188afe234d1e03ad5..a7b628cae296c7c97e58b46502bafebe92963597 100644
--- a/src/base/macros.h
+++ b/src/base/macros.h
@@ -396,13 +396,17 @@ bool is_inbounds(float_t v) {
#ifdef V8_OS_WIN
// Setup for Windows shared library export.
+#if defined(HIDE_PRIVATE_SYMBOLS)
+#define V8_EXPORT_PRIVATE
+#else //if !defined(HIDE_PRIVATE_SYMBOLS)
#ifdef BUILDING_V8_SHARED
#define V8_EXPORT_PRIVATE __declspec(dllexport)
#elif USING_V8_SHARED
#define V8_EXPORT_PRIVATE __declspec(dllimport)
-#else
+#else //!(BUILDING_V8_SHARED || USING_V8_SHARED)
#define V8_EXPORT_PRIVATE
-#endif // BUILDING_V8_SHARED
+#endif
+#endif
#else // V8_OS_WIN