-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmysql-8.0.37-e2k.patch
406 lines (367 loc) · 15.6 KB
/
mysql-8.0.37-e2k.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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
From 9663a967bf17e04aba2bb07c3810a435cb4dc235 Mon Sep 17 00:00:00 2001
From: Ilya Kurdyukov <[email protected]>
Date: Wed, 22 May 2024 11:17:56 +0700
Subject: [PATCH] mysql-8.0.37 e2k support
These sed patches are also needed to workaround bugs in the EDG frontend:
sed -i "/using __base/{N;N;s/^.*using __base.*EncodeBase.*friend __base.*$/EncodeBase_EDG/}" router/src/mysql_protocol/include/mysqlrouter/classic_protocol_codec_*.h
sed -i "s/-Werror/-Wno-error/" mysql-shell/cmake/compiler.cmake
---
CMakeLists.txt | 1 +
cmake/abi_check.cmake | 2 +-
.../devapi/mod_mysqlx_collection_find.cc | 6 ++++++
.../devapi/mod_mysqlx_collection_modify.cc | 4 ++++
.../modules/devapi/mod_mysqlx_table_insert.cc | 6 ++++++
.../mysqlshdk/include/scripting/types_cpp.h | 4 ++--
.../mysqlshdk/libs/storage/backend/directory.cc | 4 ++--
.../mysqlrouter/classic_protocol_codec_base.h | 17 +++++++++++++++++
sql/containers/atomics_array.h | 2 +-
sql/mem_root_array.h | 2 +-
sql/mysqld.cc | 2 +-
sql/mysqld.h | 2 +-
sql/thr_malloc.h | 2 +-
storage/innobase/buf/checksum.cc | 2 ++
storage/innobase/include/os0thread.h | 7 +++++++
storage/innobase/include/ut0rnd.h | 9 +++++++++
storage/innobase/ut/ut0rnd.cc | 7 +++++++
storage/ndb/include/portlib/mt-asm.h | 17 +++++++++++++++++
unittest/gunit/fake_table.cc | 7 +++++++
unittest/gunit/gunit_test_main.cc | 2 +-
unittest/gunit/gunit_test_main.h | 2 +-
21 files changed, 95 insertions(+), 12 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 401d0e74..1a832692 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -701,6 +701,7 @@ SET(MYSQL_MACHINE_TYPE ${CMAKE_SYSTEM_PROCESSOR})
SET(KNOWN_64BIT_ARCHITECTURES
arm64
aarch64
+ e2k
ppc64
ppc64le
s390x
diff --git a/cmake/abi_check.cmake b/cmake/abi_check.cmake
index bfca594f..5ca14971 100644
--- a/cmake/abi_check.cmake
+++ b/cmake/abi_check.cmake
@@ -33,7 +33,7 @@
# On Windows we use the Windows subsystem for Linux and gcc and sed
# installed in it, if available.
SET(RUN_ABI_CHECK 0)
-IF(LINUX AND MY_COMPILER_IS_GNU)
+IF(LINUX AND MY_COMPILER_IS_GNU AND NOT CMAKE_SYSTEM_PROCESSOR STREQUAL "e2k")
SET(RUN_ABI_CHECK 1)
ELSEIF(WIN32)
FIND_PROGRAM(WSL_EXECUTABLE wsl HINTS C:/Windows/Sysnative)
diff --git a/mysql-shell/modules/devapi/mod_mysqlx_collection_find.cc b/mysql-shell/modules/devapi/mod_mysqlx_collection_find.cc
index 2cb6dc36..4df895bd 100644
--- a/mysql-shell/modules/devapi/mod_mysqlx_collection_find.cc
+++ b/mysql-shell/modules/devapi/mod_mysqlx_collection_find.cc
@@ -38,9 +38,15 @@ namespace mysqlsh {
namespace mysqlx {
using shcore::Value;
+#ifdef __EDG__
+constexpr shcore::Value_type Array = shcore::Value_type::Array;
+constexpr shcore::Value_type Object = shcore::Value_type::Object;
+constexpr shcore::Value_type String = shcore::Value_type::String;
+#else
using shcore::Value_type::Array;
using shcore::Value_type::Object;
using shcore::Value_type::String;
+#endif
using std::placeholders::_1;
REGISTER_HELP_CLASS(CollectionFind, mysqlx);
diff --git a/mysql-shell/modules/devapi/mod_mysqlx_collection_modify.cc b/mysql-shell/modules/devapi/mod_mysqlx_collection_modify.cc
index 8030204e..b67f2961 100644
--- a/mysql-shell/modules/devapi/mod_mysqlx_collection_modify.cc
+++ b/mysql-shell/modules/devapi/mod_mysqlx_collection_modify.cc
@@ -44,7 +44,11 @@ namespace mysqlsh {
namespace mysqlx {
using shcore::Value;
+#ifdef __EDG__
+constexpr shcore::Value_type Array = shcore::Value_type::Array;
+#else
using shcore::Value_type::Array;
+#endif
using std::placeholders::_1;
// Documentation of CollectionModify class
diff --git a/mysql-shell/modules/devapi/mod_mysqlx_table_insert.cc b/mysql-shell/modules/devapi/mod_mysqlx_table_insert.cc
index 0bcb2a51..a068464c 100644
--- a/mysql-shell/modules/devapi/mod_mysqlx_table_insert.cc
+++ b/mysql-shell/modules/devapi/mod_mysqlx_table_insert.cc
@@ -35,9 +35,15 @@ namespace mysqlsh {
namespace mysqlx {
using shcore::Value;
+#ifdef __EDG__
+constexpr shcore::Value_type Array = shcore::Value_type::Array;
+constexpr shcore::Value_type Map = shcore::Value_type::Map;
+constexpr shcore::Value_type String = shcore::Value_type::String;
+#else
using shcore::Value_type::Array;
using shcore::Value_type::Map;
using shcore::Value_type::String;
+#endif
using std::placeholders::_1;
REGISTER_HELP_CLASS(TableInsert, mysqlx);
diff --git a/mysql-shell/mysqlshdk/include/scripting/types_cpp.h b/mysql-shell/mysqlshdk/include/scripting/types_cpp.h
index 046d7439..d11e92c2 100644
--- a/mysql-shell/mysqlshdk/include/scripting/types_cpp.h
+++ b/mysql-shell/mysqlshdk/include/scripting/types_cpp.h
@@ -1652,7 +1652,7 @@ class SHCORE_PUBLIC Cpp_object_bridge : public Object_bridge {
_funcs.emplace(
registered_name,
std::shared_ptr<Cpp_function>(
- new Cpp_function(&md, [&md, func = std::forward<F>(func),
+ new Cpp_function(&md, [this, &md, func = std::forward<F>(func),
defs = std::make_tuple(std::move(defs)...)](
const shcore::Argument_list &args) {
// Executes parameter validators
@@ -1663,7 +1663,7 @@ class SHCORE_PUBLIC Cpp_object_bridge : public Object_bridge {
md.signature[index]->validate(args[index], &context);
}
- return detail::Result_wrapper<R>::call([&func, &args, &defs]() {
+ return detail::Result_wrapper<R>::call([this, &func, &args, &defs]() {
return call<R, F, A...>(func, args, defs,
std::index_sequence_for<A...>{});
});
diff --git a/mysql-shell/mysqlshdk/libs/storage/backend/directory.cc b/mysql-shell/mysqlshdk/libs/storage/backend/directory.cc
index 7e246035..952131e0 100644
--- a/mysql-shell/mysqlshdk/libs/storage/backend/directory.cc
+++ b/mysql-shell/mysqlshdk/libs/storage/backend/directory.cc
@@ -68,7 +68,7 @@ std::unordered_set<IDirectory::File_info> Directory::filter_files(
std::error_code ec;
for (auto &entry : std::filesystem::directory_iterator(path, ec)) {
- if (entry.is_regular_file()
+ if (std::filesystem::is_regular_file(entry.symlink_status())) {
#if (__GNUC__ < 8 || (__GNUC__ == 8 && __GNUC_MINOR__ < 4)) && \
!defined(__clang__)
// older versions of GCC do not handle filesystems which do not support
@@ -86,7 +86,7 @@ std::unordered_set<IDirectory::File_info> Directory::filter_files(
if (pattern.empty() || shcore::match_glob(pattern, name)) {
files.emplace(std::move(name), [entry = std::move(entry)]() {
- return entry.file_size();
+ return std::filesystem::file_size(entry.path());
});
}
}
diff --git a/router/src/mysql_protocol/include/mysqlrouter/classic_protocol_codec_base.h b/router/src/mysql_protocol/include/mysqlrouter/classic_protocol_codec_base.h
index ecc4a69b..893c7610 100644
--- a/router/src/mysql_protocol/include/mysqlrouter/classic_protocol_codec_base.h
+++ b/router/src/mysql_protocol/include/mysqlrouter/classic_protocol_codec_base.h
@@ -371,6 +371,22 @@ class EncodeSizeAccumulator {
* used by .size() and .encode() as both have to process the same
* fields in the same order, just with different mappers
*/
+#ifdef __EDG__
+#define EncodeBase_EDG \
+ private: \
+ const capabilities::value_type __base; \
+ public: \
+ constexpr size_t size() const noexcept { \
+ return accumulate_fields(impl::EncodeSizeAccumulator(__base)); \
+ } \
+ stdx::expected<size_t, std::error_code> encode( \
+ const net::mutable_buffer &buffer) const { \
+ return accumulate_fields(impl::EncodeBufferAccumulator(buffer, __base)); \
+ } \
+ constexpr capabilities::value_type caps() const noexcept { return __base; }
+
+template <class T> class EncodeBase {};
+#else
template <class T>
class EncodeBase {
public:
@@ -392,6 +408,7 @@ class EncodeBase {
private:
const capabilities::value_type caps_;
};
+#endif
} // namespace impl
} // namespace classic_protocol
diff --git a/sql/containers/atomics_array.h b/sql/containers/atomics_array.h
index 0ebbc346..ca15aa5e 100644
--- a/sql/containers/atomics_array.h
+++ b/sql/containers/atomics_array.h
@@ -257,7 +257,7 @@ class Atomics_array {
friend std::ostream &operator<<(std::ostream &out,
Atomics_array<T, I, A> &in) {
- out << in.to_string(true) << std::flush;
+ out << in.to_string() << std::flush;
return out;
}
diff --git a/sql/mem_root_array.h b/sql/mem_root_array.h
index 58c9fbef..fc9e875f 100644
--- a/sql/mem_root_array.h
+++ b/sql/mem_root_array.h
@@ -485,7 +485,7 @@ class Mem_root_array : public Mem_root_array_YY<Element_type> {
: Mem_root_array(root, x.cbegin(), x.cend()) {}
Mem_root_array(std::initializer_list<Element_type> elements)
- : Mem_root_array(*THR_MALLOC, begin(elements), end(elements)) {}
+ : Mem_root_array(*THR_MALLOC, elements.begin(), elements.end()) {}
~Mem_root_array() { super::clear(); }
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index e176b83b..7922fb7e 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -1557,7 +1557,7 @@ SHOW_COMP_OPTION have_statement_timeout = SHOW_OPTION_DISABLED;
/* Thread specific variables */
-thread_local MEM_ROOT **THR_MALLOC = nullptr;
+__thread MEM_ROOT **THR_MALLOC = nullptr;
mysql_mutex_t LOCK_status, LOCK_uuid_generator, LOCK_crypt,
LOCK_global_system_variables, LOCK_user_conn, LOCK_error_messages;
diff --git a/sql/mysqld.h b/sql/mysqld.h
index 42e22df7..af539642 100644
--- a/sql/mysqld.h
+++ b/sql/mysqld.h
@@ -422,7 +422,7 @@ extern bool migrate_connect_options;
extern LEX_CSTRING sql_statement_names[(uint)SQLCOM_END + 1];
-extern thread_local MEM_ROOT **THR_MALLOC;
+extern __thread MEM_ROOT **THR_MALLOC;
extern PSI_file_key key_file_binlog_cache;
extern PSI_file_key key_file_binlog_index_cache;
diff --git a/sql/thr_malloc.h b/sql/thr_malloc.h
index c5e3ae7b..a0416d47 100644
--- a/sql/thr_malloc.h
+++ b/sql/thr_malloc.h
@@ -29,7 +29,7 @@
struct CHARSET_INFO;
struct MEM_ROOT;
typedef unsigned int PSI_memory_key;
-extern thread_local MEM_ROOT **THR_MALLOC;
+extern __thread MEM_ROOT **THR_MALLOC;
void init_sql_alloc(PSI_memory_key key, MEM_ROOT *root, size_t block_size);
diff --git a/storage/innobase/buf/checksum.cc b/storage/innobase/buf/checksum.cc
index 1385f236..5d88de50 100644
--- a/storage/innobase/buf/checksum.cc
+++ b/storage/innobase/buf/checksum.cc
@@ -31,6 +31,8 @@ this program; if not, write to the Free Software Foundation, Inc.,
Created Aug 11, 2011 Vasil Dimov
*******************************************************/
+#define EDG_THREAD_FIX
+
#include <sys/types.h>
#include <zlib.h>
diff --git a/storage/innobase/include/os0thread.h b/storage/innobase/include/os0thread.h
index 1fe5aa9e..38b274d3 100644
--- a/storage/innobase/include/os0thread.h
+++ b/storage/innobase/include/os0thread.h
@@ -70,8 +70,15 @@ using os_thread_id_t = std::thread::native_handle_type;
namespace ut {
/** The hash value of the current thread's id */
+#ifdef __EDG__
+extern const thread_local size_t this_thread_hash;
+#ifdef EDG_THREAD_FIX
+const thread_local size_t this_thread_hash = std::hash<std::thread::id>{}(std::this_thread::get_id());
+#endif
+#else
const inline thread_local size_t this_thread_hash =
std::hash<std::thread::id>{}(std::this_thread::get_id());
+#endif
} // namespace ut
/** Returns the string representation of the thread ID supplied. It uses the
diff --git a/storage/innobase/include/ut0rnd.h b/storage/innobase/include/ut0rnd.h
index c5a6c742..66d8bcd0 100644
--- a/storage/innobase/include/ut0rnd.h
+++ b/storage/innobase/include/ut0rnd.h
@@ -112,7 +112,16 @@ on data written to disk.
namespace detail {
/** Seed value of ut::random_64() */
+#ifdef __EDG__
+struct edg_random_seed {
+ uint64_t val; bool init_done; void init();
+ operator uint64_t() { if (!init_done) init(); return val; }
+ uint64_t& operator=(uint64_t x) { init_done = true; val = x; return val; }
+};
+extern __thread edg_random_seed random_seed;
+#else
extern thread_local uint64_t random_seed;
+#endif
/** A helper method, it is used by hash_binary_ib for backward compatibility.
NOTE: Do not use this method, it produces results that are not hashed well.
diff --git a/storage/innobase/ut/ut0rnd.cc b/storage/innobase/ut/ut0rnd.cc
index 19b1ad71..d8dbfc49 100644
--- a/storage/innobase/ut/ut0rnd.cc
+++ b/storage/innobase/ut/ut0rnd.cc
@@ -37,7 +37,14 @@ this program; if not, write to the Free Software Foundation, Inc.,
namespace ut::detail {
/* Changes for each threads for more different sequences. */
+#ifdef __EDG__
+__thread edg_random_seed random_seed;
+void edg_random_seed::init() {
+ init_done = true; val = ut::this_thread_hash + my_timer_cycles();
+}
+#else
thread_local uint64_t random_seed = ut::this_thread_hash + my_timer_cycles();
+#endif
/* This is a "precomputed" table of random hash values. */
alignas(ut::INNODB_CACHE_LINE_SIZE)
diff --git a/storage/ndb/include/portlib/mt-asm.h b/storage/ndb/include/portlib/mt-asm.h
index 379d48f8..26b4cdea 100644
--- a/storage/ndb/include/portlib/mt-asm.h
+++ b/storage/ndb/include/portlib/mt-asm.h
@@ -123,6 +123,23 @@ static inline int xcng(volatile unsigned *addr, int val) {
return prev;
}
+#elif defined(__e2k__)
+#include "x86intrin.h"
+#define NDB_HAVE_MB
+#define NDB_HAVE_RMB
+#define NDB_HAVE_WMB
+#define NDB_HAVE_XCNG
+#define NDB_HAVE_CPU_PAUSE
+
+#define mb() __builtin_ia32_mfence()
+#define rmb() __builtin_ia32_lfence()
+#define wmb() __builtin_ia32_sfence()
+#define cpu_pause() __builtin_ia32_pause()
+
+static inline int xcng(volatile unsigned *addr, int val) {
+ return __sync_lock_test_and_set(addr, (unsigned)val);
+}
+
#elif defined(__aarch64__)
/**
* Use generic defaults for mb(), rmb(), wmb() see further down.
diff --git a/unittest/gunit/fake_table.cc b/unittest/gunit/fake_table.cc
index ece6f632..51ff29d2 100644
--- a/unittest/gunit/fake_table.cc
+++ b/unittest/gunit/fake_table.cc
@@ -20,7 +20,14 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
+#ifdef __EDG__
+#include "sql/table.h"
+class Fake_TABLE : public TABLE {
+ static int highest_table_id;
+};
+#else
#include "unittest/gunit/fake_table.h"
+#endif
// We choose non-zero to avoid it working by coincidence.
int Fake_TABLE::highest_table_id = 5;
diff --git a/unittest/gunit/gunit_test_main.cc b/unittest/gunit/gunit_test_main.cc
index 0dfb099d..31dd95cf 100644
--- a/unittest/gunit/gunit_test_main.cc
+++ b/unittest/gunit/gunit_test_main.cc
@@ -122,7 +122,7 @@ static void init_signal_handling() {
// Some globals needed for "small" tests.
mysql_mutex_t LOCK_open;
uint opt_debug_sync_timeout = 0;
-thread_local MEM_ROOT **THR_MALLOC = nullptr;
+__thread MEM_ROOT **THR_MALLOC = nullptr;
thread_local THD *current_thd = nullptr;
size_t malloc_chunk_size = 1024;
diff --git a/unittest/gunit/gunit_test_main.h b/unittest/gunit/gunit_test_main.h
index 43f2f0bf..54ab62e9 100644
--- a/unittest/gunit/gunit_test_main.h
+++ b/unittest/gunit/gunit_test_main.h
@@ -31,7 +31,7 @@ struct MEM_ROOT;
extern mysql_mutex_t LOCK_open;
extern uint opt_debug_sync_timeout;
-extern thread_local MEM_ROOT **THR_MALLOC;
+extern __thread MEM_ROOT **THR_MALLOC;
extern thread_local THD *current_thd;
extern size_t malloc_chunk_size;
--
2.34.1