-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy path004-swiftshader-updates.patch
290 lines (265 loc) · 9.83 KB
/
004-swiftshader-updates.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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
diff --git a/src/Reactor/BUILD.gn b/src/Reactor/BUILD.gn
index 67dfeb0ec..ceb96a5d7 100644
--- a/src/Reactor/BUILD.gn
+++ b/src/Reactor/BUILD.gn
@@ -16,7 +16,7 @@ import("reactor.gni")
import("../swiftshader.gni")
config("swiftshader_llvm_reactor_private_config") {
- if (is_win) {
+ if (is_msvs) {
cflags = [
"/wd4141", # 'inline' used more than once. (LLVM 7.0)
"/wd4146", # unary minus operator applied to unsigned type. (LLVM 7.0)
@@ -109,7 +109,7 @@ if (supports_subzero) {
config("swiftshader_subzero_private_config") {
cflags = []
- if (is_win) {
+ if (is_msvs) {
cflags += [
"/wd4005",
"/wd4018",
@@ -155,7 +155,7 @@ if (supports_subzero) {
config("swiftshader_reactor_with_subzero_private_config") {
cflags = []
- if (is_win) {
+ if (is_msvs) {
cflags += [
"/wd4141",
"/wd4146",
diff --git a/src/Reactor/SubzeroReactor.cpp b/src/Reactor/SubzeroReactor.cpp
index 0a4e9d2ce..0d282b0d3 100644
--- a/src/Reactor/SubzeroReactor.cpp
+++ b/src/Reactor/SubzeroReactor.cpp
@@ -286,7 +286,7 @@ private:
static void cpuid(int registers[4], int info)
{
#if defined(__i386__) || defined(__x86_64__)
-# if defined(_WIN32)
+# if defined(_MSC_VER)
__cpuid(registers, info);
# else
__asm volatile("cpuid"
diff --git a/src/Vulkan/BUILD.gn b/src/Vulkan/BUILD.gn
index 5556abdf0..4bc957ba8 100644
--- a/src/Vulkan/BUILD.gn
+++ b/src/Vulkan/BUILD.gn
@@ -183,8 +183,10 @@ swiftshader_shared_library("swiftshader_libvulkan") {
"vk_swiftshader.def",
]
libs += [
- "gdi32.lib",
- "user32.lib",
+ "psapi",
+ "shell32",
+ "gdi32",
+ "user32",
]
}
@@ -237,7 +239,7 @@ action("icd_file") {
input_file = swiftshader_icd_file_name
if (is_win) {
- library_path = ".\\vk_swiftshader.dll"
+ library_path = "./libvk_swiftshader.dll"
} else if (is_mac) {
library_path = "./libvk_swiftshader.dylib"
} else if (is_fuchsia) {
diff --git a/third_party/llvm-10.0/BUILD.gn b/third_party/llvm-10.0/BUILD.gn
index 59e52303c..09ca85108 100644
--- a/third_party/llvm-10.0/BUILD.gn
+++ b/third_party/llvm-10.0/BUILD.gn
@@ -18,7 +18,7 @@ import("../../src/swiftshader.gni")
config("swiftshader_llvm_private_config") {
cflags = []
- if (is_win) {
+ if (is_msvs) {
cflags += [
"/wd4005",
"/wd4018",
diff --git a/third_party/llvm-10.0/llvm/include/llvm/Support/Windows/WindowsSupport.h b/third_party/llvm-10.0/llvm/include/llvm/Support/Windows/WindowsSupport.h
index bb7e79b86..640c00eed 100644
--- a/third_party/llvm-10.0/llvm/include/llvm/Support/Windows/WindowsSupport.h
+++ b/third_party/llvm-10.0/llvm/include/llvm/Support/Windows/WindowsSupport.h
@@ -28,7 +28,9 @@
// Require at least Windows 7 API.
#define _WIN32_WINNT 0x0601
#define _WIN32_IE 0x0800 // MinGW at it again. FIXME: verify if still needed.
+#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
+#endif
#ifndef NOMINMAX
#define NOMINMAX
#endif
diff --git a/third_party/llvm-10.0/llvm/lib/Support/ErrorHandling.cpp b/third_party/llvm-10.0/llvm/lib/Support/ErrorHandling.cpp
index a9463024c..2df917cc7 100644
--- a/third_party/llvm-10.0/llvm/lib/Support/ErrorHandling.cpp
+++ b/third_party/llvm-10.0/llvm/lib/Support/ErrorHandling.cpp
@@ -32,7 +32,7 @@
#if defined(HAVE_UNISTD_H)
# include <unistd.h>
#endif
-#if defined(_MSC_VER)
+#if defined(_WIN32)
# include <io.h>
# include <fcntl.h>
#endif
diff --git a/third_party/llvm-subzero/lib/Support/ErrorHandling.cpp b/third_party/llvm-subzero/lib/Support/ErrorHandling.cpp
index a7d3a1800..191264b4b 100644
--- a/third_party/llvm-subzero/lib/Support/ErrorHandling.cpp
+++ b/third_party/llvm-subzero/lib/Support/ErrorHandling.cpp
@@ -33,7 +33,7 @@
#if defined(HAVE_UNISTD_H)
# include <unistd.h>
#endif
-#if defined(_MSC_VER)
+#if defined(_WIN32)
# include <io.h>
# include <fcntl.h>
#endif
diff --git a/third_party/llvm-subzero/lib/Support/Timer.cpp b/third_party/llvm-subzero/lib/Support/Timer.cpp
index fbd73d0b6..c9d17a53b 100644
--- a/third_party/llvm-subzero/lib/Support/Timer.cpp
+++ b/third_party/llvm-subzero/lib/Support/Timer.cpp
@@ -174,7 +174,7 @@ void TimeRecord::print(const TimeRecord &Total, raw_ostream &OS) const {
OS << " ";
if (Total.getMemUsed())
- OS << format("%9" PRId64 " ", (int64_t)getMemUsed());
+ OS << format("%9lld ", (int64_t)getMemUsed());
}
diff --git a/third_party/llvm-subzero/lib/Support/Windows/Process.inc b/third_party/llvm-subzero/lib/Support/Windows/Process.inc
index 8d646b321..2d56e4c0d 100644
--- a/third_party/llvm-subzero/lib/Support/Windows/Process.inc
+++ b/third_party/llvm-subzero/lib/Support/Windows/Process.inc
@@ -24,14 +24,7 @@
#include <psapi.h>
#include <shellapi.h>
-#ifdef __MINGW32__
- #if (HAVE_LIBPSAPI != 1)
- #error "libpsapi.a should be present"
- #endif
- #if (HAVE_LIBSHELL32 != 1)
- #error "libshell32.a should be present"
- #endif
-#else
+#ifdef _MSC_VER
#pragma comment(lib, "psapi.lib")
#pragma comment(lib, "shell32.lib")
#endif
diff --git a/third_party/llvm-subzero/lib/Support/Windows/Signals.inc b/third_party/llvm-subzero/lib/Support/Windows/Signals.inc
index 38cc56654..edd9f8d3d 100644
--- a/third_party/llvm-subzero/lib/Support/Windows/Signals.inc
+++ b/third_party/llvm-subzero/lib/Support/Windows/Signals.inc
@@ -36,9 +36,6 @@
#ifdef _MSC_VER
#pragma comment(lib, "psapi.lib")
#elif __MINGW32__
- #if (HAVE_LIBPSAPI != 1)
- #error "libpsapi.a should be present"
- #endif
// The version of g++ that comes with MinGW does *not* properly understand
// the ll format specifier for printf. However, MinGW passes the format
// specifiers on to the MSVCRT entirely, and the CRT understands the ll
diff --git a/third_party/llvm-subzero/lib/Support/Windows/WindowsSupport.h b/third_party/llvm-subzero/lib/Support/Windows/WindowsSupport.h
index c358b99ab..d67b21ec8 100644
--- a/third_party/llvm-subzero/lib/Support/Windows/WindowsSupport.h
+++ b/third_party/llvm-subzero/lib/Support/Windows/WindowsSupport.h
@@ -29,7 +29,9 @@
// Require at least Windows 7 API.
#define _WIN32_WINNT 0x0601
#define _WIN32_IE 0x0800 // MinGW at it again. FIXME: verify if still needed.
+#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
+#endif
#ifndef NOMINMAX
#define NOMINMAX
#endif
diff --git a/third_party/marl/BUILD.gn b/third_party/marl/BUILD.gn
index 4c0264892..ccd1c482a 100644
--- a/third_party/marl/BUILD.gn
+++ b/third_party/marl/BUILD.gn
@@ -14,7 +14,9 @@
import("../../src/swiftshader.gni")
-import("//testing/test.gni")
+if (build_with_chromium) {
+ import("//testing/test.gni")
+}
config("marl_config") {
include_dirs = [ "include" ]
diff --git a/third_party/marl/src/scheduler.cpp b/third_party/marl/src/scheduler.cpp
index f5e9df0ec..c762e5dde 100644
--- a/third_party/marl/src/scheduler.cpp
+++ b/third_party/marl/src/scheduler.cpp
@@ -20,7 +20,7 @@
#include "marl/thread.h"
#include "marl/trace.h"
-#if defined(_WIN32)
+#if defined(_MSC_VER)
#include <intrin.h> // __nop()
#endif
@@ -60,7 +60,7 @@ inline uint64_t threadID() {
#endif
inline void nop() {
-#if defined(_WIN32)
+#if defined(_MSC_VER)
__nop();
#else
__asm__ __volatile__("nop");
diff --git a/third_party/subzero/CMakeLists.txt b/third_party/subzero/CMakeLists.txt
index aec878b79..7c9fc9f2e 100644
--- a/third_party/subzero/CMakeLists.txt
+++ b/third_party/subzero/CMakeLists.txt
@@ -78,7 +78,7 @@ else()
message(WARNING "Architecture '${ARCH}' not supported by Subzero")
endif()
-if(WIN32)
+if(MSVC)
list(APPEND SUBZERO_COMPILE_OPTIONS
"/wd4146" # unary minus operator applied to unsigned type, result still unsigned
"/wd4334" # ''operator' : result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
diff --git a/third_party/subzero/src/IceTargetLowering.cpp b/third_party/subzero/src/IceTargetLowering.cpp
index ab09b48cb..64cca4cda 100644
--- a/third_party/subzero/src/IceTargetLowering.cpp
+++ b/third_party/subzero/src/IceTargetLowering.cpp
@@ -48,6 +48,7 @@
// createTargetHeaderLowering(Ice::GlobalContext *);
// void staticInit(::Ice::GlobalContext *);
// }
+#undef SUBZERO_TARGET
#define SUBZERO_TARGET(X) \
namespace X { \
std::unique_ptr<::Ice::TargetLowering> \
diff --git a/third_party/subzero/src/IceTargetLoweringX8632.cpp b/third_party/subzero/src/IceTargetLoweringX8632.cpp
index 6875c8aa3..c5055d6d3 100644
--- a/third_party/subzero/src/IceTargetLoweringX8632.cpp
+++ b/third_party/subzero/src/IceTargetLoweringX8632.cpp
@@ -34,7 +34,7 @@
#include <stack>
-#if defined(_WIN32)
+#if defined(_MSC_VER) && defined(_WIN32)
extern "C" void _chkstk();
#endif
@@ -7868,7 +7868,7 @@ Variable *TargetX8632::moveReturnValueToRegister(Operand *Value,
}
void TargetX8632::emitStackProbe(size_t StackSizeBytes) {
-#if defined(_WIN32)
+#if defined(_MSC_VER) && defined(_WIN32)
if (StackSizeBytes >= 4096) {
// _chkstk on Win32 is actually __alloca_probe, which adjusts ESP by the
// stack amount specified in EAX, so we save ESP in ECX, and restore them
diff --git a/third_party/subzero/src/IceTargetLoweringX8664.cpp b/third_party/subzero/src/IceTargetLoweringX8664.cpp
index 13f8f85ff..a0f92fe8b 100644
--- a/third_party/subzero/src/IceTargetLoweringX8664.cpp
+++ b/third_party/subzero/src/IceTargetLoweringX8664.cpp
@@ -33,7 +33,7 @@
#include <stack>
-#if defined(_WIN64)
+#if defined(_MSC_VER) && defined(_WIN64)
extern "C" void __chkstk();
#endif
@@ -7183,7 +7183,7 @@ Variable *TargetX8664::moveReturnValueToRegister(Operand *Value,
}
void TargetX8664::emitStackProbe(size_t StackSizeBytes) {
-#if defined(_WIN64)
+#if defined(_MSC_VER) && defined(_WIN64)
// Mirroring the behavior of MSVC here, which emits a _chkstk when locals are
// >= 4KB, rather than the 8KB claimed by the docs.
if (StackSizeBytes >= 4096) {