-
Notifications
You must be signed in to change notification settings - Fork 253
/
0004-Allow-Windows-builds-under-Bazel.patch
248 lines (240 loc) · 8.31 KB
/
0004-Allow-Windows-builds-under-Bazel.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
From 41767e80304816d674136ce08ab241596e4494ee Mon Sep 17 00:00:00 2001
From: Brendan Coll <bcoll@cloudflare.com>
Date: Thu, 16 Mar 2023 11:56:10 +0000
Subject: Allow Windows builds under Bazel
diff --git a/BUILD.bazel b/BUILD.bazel
index 05b7472165ae858df0a300279c6065c38faf1768..4a914c56851dbd43329829f9b42c9ca500055fc7 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -778,6 +778,7 @@ filegroup(
"src/base/platform/mutex.h",
"src/base/platform/platform.cc",
"src/base/platform/platform.h",
+ "src/base/platform/platform-posix.h", # Always included by src/execution/isolate.h
"src/base/platform/semaphore.cc",
"src/base/platform/semaphore.h",
"src/base/platform/time.cc",
@@ -817,7 +818,6 @@ filegroup(
] + select({
"@v8//bazel/config:is_posix": [
"src/base/platform/platform-posix.cc",
- "src/base/platform/platform-posix.h",
"src/base/platform/platform-posix-time.cc",
"src/base/platform/platform-posix-time.h",
],
@@ -840,6 +840,7 @@ filegroup(
"@v8//bazel/config:is_windows": [
"src/base/debug/stack_trace_win.cc",
"src/base/platform/platform-win32.cc",
+ "src/base/platform/platform-win32.h",
"src/base/win32-headers.h",
],
}),
@@ -1229,6 +1230,7 @@ filegroup(
"include/v8-wasm-trap-handler-posix.h",
"src/api/api.cc",
"src/api/api.h",
+ "include/v8-wasm-trap-handler-win.h",
"src/api/api-arguments.cc",
"src/api/api-arguments.h",
"src/api/api-arguments-inl.h",
@@ -2672,6 +2674,11 @@ filegroup(
"src/trap-handler/handler-inside-posix.cc",
"src/trap-handler/handler-outside-posix.cc",
],
+ "@v8//bazel/config:is_windows": [
+ "src/trap-handler/handler-inside-win.cc",
+ "src/trap-handler/handler-inside-win.h",
+ "src/trap-handler/handler-outside-win.cc",
+ ],
"//conditions:default": [],
}) + select({
"@v8//bazel/config:v8_arm64_simulator": [
@@ -2679,13 +2686,6 @@ filegroup(
"src/trap-handler/trap-handler-simulator.h",
],
"//conditions:default": [],
- }) + select({
- "@v8//bazel/config:is_windows": [
- "src/trap-handler/handler-inside-win.cc",
- "src/trap-handler/handler-inside-win.h",
- "src/trap-handler/handler-outside-win.cc",
- ],
- "//conditions:default": [],
}) + select({
"@v8//bazel/config:is_windows_64bit": [
"src/diagnostics/unwinding-info-win64.cc",
@@ -3682,6 +3682,9 @@ filegroup(
"@v8//bazel/config:is_msvc_asm_ia32": ["src/heap/base/asm/ia32/push_registers_masm.asm"],
"@v8//bazel/config:is_msvc_asm_x64": ["src/heap/base/asm/x64/push_registers_masm.asm"],
"@v8//bazel/config:is_msvc_asm_arm64": ["src/heap/base/asm/arm64/push_registers_masm.S"],
+ "@v8//bazel/config:is_windows_clang_asm_ia32": ["src/heap/base/asm/ia32/push_registers_asm.cc"],
+ "@v8//bazel/config:is_windows_clang_asm_x64": ["src/heap/base/asm/x64/push_registers_asm.cc"],
+ "@v8//bazel/config:is_windows_clang_asm_arm64": ["src/heap/base/asm/arm64/push_registers_asm.cc"],
}),
)
@@ -4057,9 +4060,11 @@ filegroup(
"src/d8/d8-js.cc",
"src/d8/d8-platforms.cc",
"src/d8/d8-platforms.h",
- "src/d8/d8-posix.cc",
"src/d8/d8-test.cc",
- ],
+ ] + select({
+ "@v8//bazel/config:is_posix": ["src/d8/d8-posix.cc"],
+ "@v8//bazel/config:is_windows": ["src/d8/d8-windows.cc"],
+ }),
)
genrule(
@@ -4396,7 +4401,7 @@ py_test(
":noicu/d8",
":noicu/v8_build_config",
"//testing/pybase",
- ] + glob(["test/**"]) + glob(["tools/**/*.js"]) + glob(["tools/**/*.mjs"]),
+ ] + glob(["test/**"], exclude = ["test/message/unicode-filename-*"],) + glob(["tools/**/*.js"]) + glob(["tools/**/*.mjs"]),
main = "tools/run-tests.py",
python_version = "PY3",
tags = [
@@ -4426,7 +4431,7 @@ py_test(
":icu/d8",
":icu/v8_build_config",
"//testing/pybase",
- ] + glob(["test/**"]) + glob(["tools/**/*.js"]) + glob(["tools/**/*.mjs"]),
+ ] + glob(["test/**"], exclude = ["test/message/unicode-filename-*"]) + glob(["tools/**/*.js"]) + glob(["tools/**/*.mjs"]),
main = "tools/run-tests.py",
python_version = "PY3",
tags = [
diff --git a/bazel/config/BUILD.bazel b/bazel/config/BUILD.bazel
index 67454fa90eea460e70e286623fb1c99edd22c650..7efff1ab909dc7048a216e511c2e71c72ee8847a 100644
--- a/bazel/config/BUILD.bazel
+++ b/bazel/config/BUILD.bazel
@@ -286,6 +286,7 @@ selects.config_setting_group(
match_all = [
":is_windows",
":is_x64",
+ ":is_compiler_default",
],
)
@@ -294,6 +295,7 @@ selects.config_setting_group(
match_all = [
":is_windows",
":is_ia32",
+ ":is_compiler_default",
],
)
@@ -302,6 +304,34 @@ selects.config_setting_group(
match_all = [
":is_windows",
":is_arm64",
+ ":is_compiler_default",
+ ],
+)
+
+selects.config_setting_group(
+ name = "is_windows_clang_asm_x64",
+ match_all = [
+ ":is_windows",
+ ":is_x64",
+ ":is_compiler_clang_cl",
+ ],
+)
+
+selects.config_setting_group(
+ name = "is_windows_clang_asm_ia32",
+ match_all = [
+ ":is_windows",
+ ":is_ia32",
+ ":is_compiler_clang_cl",
+ ],
+)
+
+selects.config_setting_group(
+ name = "is_windows_clang_asm_arm64",
+ match_all = [
+ ":is_windows",
+ ":is_arm64",
+ ":is_compiler_clang_cl",
],
)
@@ -343,6 +373,13 @@ config_setting(
},
)
+config_setting(
+ name = "is_compiler_clang_cl",
+ flag_values = {
+ "@bazel_tools//tools/cpp:compiler": "clang-cl",
+ },
+)
+
selects.config_setting_group(
name = "is_clang",
match_any = [
diff --git a/bazel/defs.bzl b/bazel/defs.bzl
index f23f48ef03ae6adb08e3cfa605bff35d820c865e..fba64a0ca755da3c4a6b24a02d16ca552113a384 100644
--- a/bazel/defs.bzl
+++ b/bazel/defs.bzl
@@ -118,6 +118,24 @@ def _default_args():
"-Wno-non-virtual-dtor",
"-isystem .",
],
+ "@v8//bazel/config:is_windows": [
+ ## From BUILD.gn: `if (is_win)`
+ "/wd4245",
+ "/wd4267",
+ "/wd4324",
+ "/wd4701",
+ "/wd4702",
+ "/wd4703",
+ "/wd4709",
+ "/wd4714",
+ "/wd4715",
+ "/wd4718",
+ "/wd4723",
+ "/wd4724",
+ "/wd4800",
+ ## From BUILD.icu
+ "/wd4005",
+ ],
"//conditions:default": [],
}) + select({
"@v8//bazel/config:is_clang": [
@@ -164,13 +182,23 @@ def _default_args():
],
"//conditions:default": [
],
+ }) + select({
+ "@v8//bazel/config:is_compiler_clang_cl": [
+ "-Wno-invalid-offsetof",
+ ],
+ "//conditions:default": [],
}),
includes = ["include"],
linkopts = select({
"@v8//bazel/config:is_windows": [
+ # Increase the initial stack size. The default is 1MB, this is 2MB. This
+ # applies only to executables and shared libraries produced by V8 since
+ # ldflags are not pushed to dependants.
+ "/STACK:2097152",
"Winmm.lib",
"DbgHelp.lib",
"Advapi32.lib",
+ "Shell32.lib",
],
"@v8//bazel/config:is_macos": ["-pthread"],
"//conditions:default": ["-Wl,--no-as-needed -ldl -pthread"],
@@ -492,6 +520,7 @@ def v8_mksnapshot(name, args, suffix = ""):
suffix = suffix,
target_os = select({
"@v8//bazel/config:is_macos": "mac",
+ "@v8//bazel/config:is_windows": "win",
"//conditions:default": "",
}),
)
@@ -503,6 +532,7 @@ def v8_mksnapshot(name, args, suffix = ""):
suffix = suffix,
target_os = select({
"@v8//bazel/config:is_macos": "mac",
+ "@v8//bazel/config:is_windows": "win",
"//conditions:default": "",
}),
)