diff --git a/mingw-w64-mysql-client/Fixed-build-issue-on-MSYS2.patch b/mingw-w64-mysql-client/Fixed-build-issue-on-MSYS2.patch new file mode 100644 index 0000000000000..fa349b6beee89 --- /dev/null +++ b/mingw-w64-mysql-client/Fixed-build-issue-on-MSYS2.patch @@ -0,0 +1,273 @@ +From d3a4d87dc4d3ea4291bfed1891e2ee4eb2b99a6f Mon Sep 17 00:00:00 2001 +From: taozuhong +Date: Tue, 7 Jan 2025 11:37:07 +0800 +Subject: [PATCH 1/3] Fixed build issue on MSYS2 + +--- + client/CMakeLists.txt | 38 ++++++++++--------- + .../components/services/bits/my_io_bits.h | 2 +- + libmysql/CMakeLists.txt | 2 +- + mysys/CMakeLists.txt | 7 +++- + mysys/mf_tempfile.cc | 2 +- + scripts/CMakeLists.txt | 8 ++-- + sql/CMakeLists.txt | 2 +- + sql/log_event.cc | 6 +-- + sql/rpl_gtid_set.cc | 3 +- + 9 files changed, 38 insertions(+), 32 deletions(-) + +diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt +index 0b88a4b4afb..ece278c2c8b 100644 +--- a/client/CMakeLists.txt ++++ b/client/CMakeLists.txt +@@ -43,25 +43,27 @@ MYSQL_ADD_EXECUTABLE(mysql + LINK_LIBRARIES mysqlclient ${EDITLINE_LIBRARY} + ) + +-MYSQL_ADD_EXECUTABLE(mysqltest +- mysqltest.cc +- mysqltest/error_names.cc +- mysqltest/expected_errors.cc +- mysqltest/expected_warnings.cc +- mysqltest/logfile.cc +- mysqltest/regular_expressions.cc +- mysqltest/secondary_engine.cc +- mysqltest/utils.cc +- client_query_attributes.cc +- +- COMPONENT Test +- DEPENDENCIES GenError GenClientError +- ENABLE_EXPORTS +- LINK_LIBRARIES mysqlclient +- ) ++IF (NOT MINGW) ++ MYSQL_ADD_EXECUTABLE(mysqltest ++ mysqltest.cc ++ mysqltest/error_names.cc ++ mysqltest/expected_errors.cc ++ mysqltest/expected_warnings.cc ++ mysqltest/logfile.cc ++ mysqltest/regular_expressions.cc ++ mysqltest/secondary_engine.cc ++ mysqltest/utils.cc ++ client_query_attributes.cc ++ ++ COMPONENT Test ++ DEPENDENCIES GenError GenClientError ++ ENABLE_EXPORTS ++ LINK_LIBRARIES mysqlclient ++ ) + +-IF(MY_COMPILER_IS_GNU AND (WITH_LTO OR CMAKE_COMPILER_FLAG_WITH_LTO)) +- TARGET_LINK_OPTIONS(mysqltest PRIVATE -Wno-error=stringop-overflow) ++ IF(MY_COMPILER_IS_GNU AND (WITH_LTO OR CMAKE_COMPILER_FLAG_WITH_LTO)) ++ TARGET_LINK_OPTIONS(mysqltest PRIVATE -Wno-error=stringop-overflow) ++ ENDIF() + ENDIF() + + MYSQL_ADD_EXECUTABLE(mysqlcheck +diff --git a/include/mysql/components/services/bits/my_io_bits.h b/include/mysql/components/services/bits/my_io_bits.h +index f314a8aaada..debc87203cd 100644 +--- a/include/mysql/components/services/bits/my_io_bits.h ++++ b/include/mysql/components/services/bits/my_io_bits.h +@@ -51,7 +51,7 @@ + typedef int File; /* File descriptor */ + #if defined(_WIN32) && !defined(MYSQL_ABI_CHECK) + typedef int MY_MODE; +-typedef int mode_t; ++// typedef int mode_t; + typedef int socket_len_t; + typedef SOCKET my_socket; + #define MY_SOCKET_FMT "%llu" +diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt +index 863b7be3f27..2ca0e5b6733 100644 +--- a/libmysql/CMakeLists.txt ++++ b/libmysql/CMakeLists.txt +@@ -201,7 +201,7 @@ SET(CLIENT_SOURCES + ../sql/auth/sha2_password_common.cc + ) + +-IF (WIN32 AND OPENSSL_APPLINK_C) ++IF (WIN32 AND OPENSSL_APPLINK_C AND NOT MINGW) + MY_ADD_COMPILE_DEFINITIONS( + ../sql-common/client_authentication.cc + COMPILE_DEFINITIONS HAVE_OPENSSL_APPLINK_C +diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt +index aef2a83b3b1..5676ca08041 100644 +--- a/mysys/CMakeLists.txt ++++ b/mysys/CMakeLists.txt +@@ -105,7 +105,6 @@ SET(MYSYS_SOURCES + print_version.cc + psi_noop.cc + ptr_cmp.cc +- stacktrace.cc + str2int.cc + strcont.cc + strmake.cc +@@ -133,6 +132,10 @@ SET(MYSYS_SOURCES + ) + LIST(APPEND MYSYS_SOURCES my_aes_openssl.cc) + ++IF (NOT MINGW) ++ LIST(APPEND MYSYS_SOURCES stacktrace.cc) ++ENDIF() ++ + IF(BUILD_IS_SINGLE_CONFIG) + GET_PROPERTY(CWD_DEFINITIONS DIRECTORY PROPERTY COMPILE_DEFINITIONS) + IF(NOT CMAKE_CXX_FLAGS MATCHES "DSAFE_MUTEX" AND +@@ -224,7 +227,7 @@ IF(CMAKE_USE_PTHREADS_INIT AND CMAKE_C_FLAGS MATCHES "-fsanitize=") + ENDIF() + # Needed to resolve OpenSSL dependency on Windows + IF(WIN32) +- TARGET_LINK_LIBRARIES(mysys crypt32) ++ TARGET_LINK_LIBRARIES(mysys crypt32 rpcrt4) + ENDIF() + + # MD5_Init() and others are deprecated. +diff --git a/mysys/mf_tempfile.cc b/mysys/mf_tempfile.cc +index 8a865d7de38..fac868f5b2c 100644 +--- a/mysys/mf_tempfile.cc ++++ b/mysys/mf_tempfile.cc +@@ -62,7 +62,7 @@ + #include + #include + /* UuidCreateSequential needs Rpcrt4 library */ +-#pragma comment(lib, "Rpcrt4") ++#pragma comment(lib, "rpcrt4") + + static void encode_crockford_base32(uint64_t val_to_encode, char *to, + size_t encode_len) { +diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt +index 9ebe10bdb51..0a45daebe6e 100644 +--- a/scripts/CMakeLists.txt ++++ b/scripts/CMakeLists.txt +@@ -69,10 +69,10 @@ ADD_CUSTOM_COMMAND( + ) + + # Add target for the above to be built +-MY_ADD_CUSTOM_TARGET(GenFixPrivs +- ALL +- DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/mysql_fix_privilege_tables_sql.h +-) ++# MY_ADD_CUSTOM_TARGET(GenFixPrivs ++# ALL ++# DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/mysql_fix_privilege_tables_sql.h ++# ) + + ADD_CUSTOM_COMMAND( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sql_commands_system_data.h +diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt +index 3c4086fa90a..c27adbd08b7 100644 +--- a/sql/CMakeLists.txt ++++ b/sql/CMakeLists.txt +@@ -1015,7 +1015,7 @@ SET_TARGET_PROPERTIES(sql_dd PROPERTIES LINK_INTERFACE_MULTIPLICITY 3) + # On Windows platform we compile in the client-side Windows Native Authentication + # plugin which is used by the client connection code included in the server. + # +-IF(WIN32) ++IF(WIN32 AND NOT MINGW) + ADD_DEFINITIONS(-DAUTHENTICATION_WIN) + TARGET_LINK_LIBRARIES(sql_main auth_win_client) + IF(OPENSSL_APPLINK_C) +diff --git a/sql/log_event.cc b/sql/log_event.cc +index d87ecbb4779..00d33eb1d91 100644 +--- a/sql/log_event.cc ++++ b/sql/log_event.cc +@@ -790,9 +790,9 @@ bool net_field_length_checked(const uchar **packet, size_t *max_length, + } + template bool net_field_length_checked(const uchar **packet, + size_t *max_length, size_t *out); +-template bool net_field_length_checked(const uchar **packet, +- size_t *max_length, +- ulonglong *out); ++// template bool net_field_length_checked(const uchar **packet, ++// size_t *max_length, ++// ulonglong *out); + + /** + Transforms a string into "" or its expression in 0x... form. +diff --git a/sql/rpl_gtid_set.cc b/sql/rpl_gtid_set.cc +index 0017cd03c05..1f2fbe6ac14 100644 +--- a/sql/rpl_gtid_set.cc ++++ b/sql/rpl_gtid_set.cc +@@ -236,10 +236,11 @@ void Gtid_set::create_new_chunk(int size) { + */ + if (MAX_NEW_CHUNK_ALLOCATE_TRIES == i || + DBUG_EVALUATE_IF("rpl_simulate_new_chunk_allocate_failure", 1, 0)) { +- my_safe_print_system_time(); ++ /* my_safe_print_system_time(); + my_safe_printf_stderr("%s", + "[Fatal] Out of memory while allocating " + "a new chunk of intervals for storing GTIDs.\n"); ++ */ + _exit(MYSQLD_FAILURE_EXIT); + } + // store the chunk in the list of chunks +-- +2.47.1 + + +From 079dec43eed227b3b87b0aec2a4cfe4d782499c7 Mon Sep 17 00:00:00 2001 +From: taozuhong +Date: Tue, 7 Jan 2025 15:00:57 +0800 +Subject: [PATCH 2/3] Fixed build issue on MSYS2(2) + +--- + cmake/ssl.cmake | 2 +- + include/CMakeLists.txt | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/cmake/ssl.cmake b/cmake/ssl.cmake +index 932659d030f..28ab950c693 100644 +--- a/cmake/ssl.cmake ++++ b/cmake/ssl.cmake +@@ -433,7 +433,7 @@ FUNCTION(FIND_CUSTOM_OPENSSL) + HINTS ${OPENSSL_ROOT_DIR}/include + ) + +- IF (WIN32) ++ IF (WIN32 AND NOT MINGW) + FIND_FILE(OPENSSL_APPLINK_C + NAMES openssl/applink.c + NO_DEFAULT_PATH +diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt +index 642d7403d69..78c235ebfa7 100644 +--- a/include/CMakeLists.txt ++++ b/include/CMakeLists.txt +@@ -58,7 +58,7 @@ INSTALL(FILES ${HEADERS_MYSQL_DIR} + ) + + # openssl/applink.c must be built into applications linking with libmysql.dll +-IF (WIN32 AND OPENSSL_APPLINK_C) ++IF (WIN32 AND OPENSSL_APPLINK_C AND NOT MINGW) + INSTALL(FILES ${OPENSSL_APPLINK_C} + DESTINATION ${INSTALL_INCLUDEDIR}/openssl + COMPONENT Development +-- +2.47.1 + + +From 71c2d7f2ca0b60a285b59541dc6f5e3b4c3762bd Mon Sep 17 00:00:00 2001 +From: taozuhong +Date: Tue, 7 Jan 2025 16:17:26 +0800 +Subject: [PATCH 3/3] Fixed build issue on MSYS2(3) + +--- + cmake/ssl.cmake | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/cmake/ssl.cmake b/cmake/ssl.cmake +index 28ab950c693..c581e48a9dd 100644 +--- a/cmake/ssl.cmake ++++ b/cmake/ssl.cmake +@@ -788,7 +788,7 @@ MACRO(MYSQL_CHECK_SSL_DLLS) + ENDIF() + ENDIF(APPLE_WITH_CUSTOM_SSL) + +- IF(WIN32) ++ IF(WIN32 AND NOT MINGW) + GET_FILENAME_COMPONENT(CRYPTO_NAME "${CRYPTO_LIBRARY}" NAME_WE) + GET_FILENAME_COMPONENT(OPENSSL_NAME "${OPENSSL_LIBRARY}" NAME_WE) + +-- +2.47.1 + diff --git a/mingw-w64-mysql-client/PKGBUILD b/mingw-w64-mysql-client/PKGBUILD new file mode 100644 index 0000000000000..ecdd3a786a2a7 --- /dev/null +++ b/mingw-w64-mysql-client/PKGBUILD @@ -0,0 +1,76 @@ +# Maintainer: https://github.com/taozuhong + +_realname=mysql-client +pkgbase="${MINGW_PACKAGE_PREFIX}-${_realname}" +pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}" +pkgver=9.1.0 +pkgrel=1 +pkgdesc="MySQL client libraries for mingw (mingw-w64)" +arch=('any') +mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64') +url="https://github.com/mysql/mysql-server" +license=('spdx:LGPL-2.1-or-later') +options=('!strip') +makedepends=("base-devel" + "git" + "libfido2-devel" + "${MINGW_PACKAGE_PREFIX}-boost" + "${MINGW_PACKAGE_PREFIX}-cc" + "${MINGW_PACKAGE_PREFIX}-cmake" + "${MINGW_PACKAGE_PREFIX}-cyrus-sasl" + "${MINGW_PACKAGE_PREFIX}-make" + "${MINGW_PACKAGE_PREFIX}-ninja" + "${MINGW_PACKAGE_PREFIX}-pkgconf") +depends=("libfido2" + "${MINGW_PACKAGE_PREFIX}-libevent" + "${MINGW_PACKAGE_PREFIX}-zlib" + "${MINGW_PACKAGE_PREFIX}-zstd" + "${MINGW_PACKAGE_PREFIX}-openssl") +source=("https://github.com/mysql/mysql-server/archive/refs/tags/mysql-${pkgver}.tar.gz" + "Fixed-build-issue-on-MSYS2.patch") +sha256sums=('2bf56cad7ada7a758620e63e70d6445e5c9d93f910e7594959ea436a9b25a1be' + '7a7dff075b90ec8d5a231ca1a6c71739f5fca381d9c42d1dfb3be69924555a90') + +prepare() { + cd ${srcdir}/mysql-server-mysql-${pkgver} + patch -p1 -i ${srcdir}/Fixed-build-issue-on-MSYS2.patch +} + +build() { + rm -rf "${srcdir}/build-${MINGW_CHOST}" + mkdir "${srcdir}/build-${MINGW_CHOST}" + cd "${srcdir}/build-${MINGW_CHOST}" + + declare -a _extra_config + if check_option "debug" "n"; then + _extra_config+=("-DCMAKE_BUILD_TYPE=Release") + else + _extra_config+=("-DCMAKE_BUILD_TYPE=Debug") + fi + + # MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" + "${MINGW_PREFIX}"/bin/cmake -G "MinGW Makefiles" \ + ${extra_config[@]} \ + -DCMAKE_INSTALL_PREFIX=${pkgdir}${MINGW_PREFIX} \ + -DINSTALL_INCLUDEDIR=include/mysql \ + -DINSTALL_MYSQLSHAREDIR=share/mysql \ + -DINSTALL_DOCDIR=share/doc/mysql \ + -DINSTALL_INFODIR=share/info \ + -DINSTALL_MANDIR=share/man \ + -DCMAKE_PREFIX_PATH=${MINGW_PREFIX} \ + -DWITH_SSL_PATH=${MINGW_PREFIX} \ + -DWITHOUT_SERVER=ON \ + -DCMAKE_CXX_STANDARD=20 \ + -DDEFAULT_CHARSET=utf8mb4 \ + -DDEFAULT_COLLATION=utf8mb4_general_ci \ + -DWITH_AUTHENTICATION_CLIENT_PLUGINS=OFF \ + -DWITH_UNIT_TESTS=OFF \ + ../mysql-server-mysql-${pkgver} + + ${MINGW_PREFIX}/bin/cmake --build . +} + +package() { + cd "${srcdir}/build-${MINGW_CHOST}" + ${MINGW_PREFIX}/bin/cmake --install . +}