Skip to content

Commit

Permalink
Use static-CRT OpenSSL & MySQL DLLs
Browse files Browse the repository at this point in the history
Users without the Microsoft Visual C++ Redistributable package (https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist) could not use dbconmy.dll
  • Loading branch information
botder committed Feb 12, 2024
1 parent d1dc526 commit ad96e8e
Show file tree
Hide file tree
Showing 11 changed files with 321 additions and 0 deletions.
Binary file modified Shared/data/MTA San Andreas/server/arm64/libcrypto-3-arm64.dll
Binary file not shown.
Binary file modified Shared/data/MTA San Andreas/server/arm64/libmysql.dll
Binary file not shown.
Binary file modified Shared/data/MTA San Andreas/server/arm64/libssl-3-arm64.dll
Binary file not shown.
Binary file not shown.
Binary file modified Shared/data/MTA San Andreas/server/mods/deathmatch/libmysql.dll
Binary file not shown.
Binary file modified Shared/data/MTA San Andreas/server/mods/deathmatch/libssl-3.dll
Binary file not shown.
Binary file modified Shared/data/MTA San Andreas/server/x64/libcrypto-3-x64.dll
Binary file not shown.
Binary file modified Shared/data/MTA San Andreas/server/x64/libmysql.dll
Binary file not shown.
Binary file modified Shared/data/MTA San Andreas/server/x64/libssl-3-x64.dll
Binary file not shown.
4 changes: 4 additions & 0 deletions vendor/mysql/README
Expand Up @@ -4,3 +4,7 @@ That directory gets copied to the "Bin" directory when you run "win-install-data
The source code for MySQL and OpenSSL used to produce the binaries can be found here:
https://github.com/mysql/mysql-server/releases/tag/mysql-8.3.0
https://github.com/openssl/openssl/releases/tag/openssl-3.2.1

Apply the "mysql-server.diff" prior to building the mysql-server source code.
You must use the "build-x86", "build-x64", "build-arm64" subfolder names (e.g. mysql-server/build-x64),
because otherwise the patch won't work for cross-compiling ARM64 architecture.
317 changes: 317 additions & 0 deletions vendor/mysql/mysql-server.diff
@@ -0,0 +1,317 @@
diff --git a/.gitignore b/.gitignore
index 511dcdab93d..9eb9aba4d7a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -28,3 +28,5 @@ scalability_jobs_*
.cproject
.project
.settings/
+
+build-*/
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 936657aadec..3d6297f78ab 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -53,6 +53,11 @@ IF(WIN32)
CMAKE_MINIMUM_REQUIRED(VERSION 3.15.3)
ENDIF()
ENDIF()
+ cmake_policy(SET CMP0091 NEW)
+ set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
+ SET(WITHOUT_SERVER ON CACHE BOOL "" FORCE)
+ SET(WITH_UNIT_TESTS OFF CACHE BOOL "" FORCE)
+ SET(LINK_STATIC_RUNTIME_LIBRARIES ON CACHE BOOL "" FORCE)
ELSEIF(APPLE)
# Version 3.12.4 is needed because the new build system of Xcode is not
# supported by cmake. 3.12.4 will force using the legacy build system.
@@ -653,7 +658,7 @@ MESSAGE(STATUS "SIZEOF_VOIDP ${SIZEOF_VOIDP}")
# even if we have configured for 64bit build....
SET(CMAKE_SIZEOF_VOID_P ${SIZEOF_VOIDP})
IF(NOT SIZEOF_VOIDP EQUAL 8)
- MESSAGE(FATAL_ERROR "MySQL supports only 64-bit platforms.")
+# MESSAGE(FATAL_ERROR "MySQL supports only 64-bit platforms.")
ENDIF()

INCLUDE(compile_flags)
diff --git a/cmake/libevent.cmake b/cmake/libevent.cmake
index 6376c452928..2447b532fd0 100644
--- a/cmake/libevent.cmake
+++ b/cmake/libevent.cmake
@@ -74,20 +74,21 @@ FUNCTION(FIND_LIBEVENT_VERSION LIBEVENT_INCLUDE_DIRS)
"${CMAKE_BINARY_DIR}/find_libevent_version.c"
"${TEST_SRC}"
)
- TRY_RUN(TEST_RUN_RESULT COMPILE_TEST_RESULT
- ${CMAKE_BINARY_DIR}
- "${CMAKE_BINARY_DIR}/find_libevent_version.c"
- CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${LIBEVENT_INCLUDE_DIRS}"
- COMPILE_OUTPUT_VARIABLE OUTPUT
- RUN_OUTPUT_VARIABLE RUN_OUTPUT
- )
+ # TRY_RUN(TEST_RUN_RESULT COMPILE_TEST_RESULT
+ # ${CMAKE_BINARY_DIR}
+ # "${CMAKE_BINARY_DIR}/find_libevent_version.c"
+ # CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${LIBEVENT_INCLUDE_DIRS}"
+ # COMPILE_OUTPUT_VARIABLE OUTPUT
+ # RUN_OUTPUT_VARIABLE RUN_OUTPUT
+ # )
# MESSAGE(STATUS "TRY_EVENT TEST_RUN_RESULT is ${TEST_RUN_RESULT}")
# MESSAGE(STATUS "TRY_EVENT COMPILE_TEST_RESULT is ${COMPILE_TEST_RESULT}")
# MESSAGE(STATUS "TRY_EVENT COMPILE_OUTPUT_VARIABLE is ${OUTPUT}")
# MESSAGE(STATUS "TRY_EVENT RUN_OUTPUT_VARIABLE is ${RUN_OUTPUT}")
+ SET(COMPILE_TEST_RESULT TRUE)

IF(COMPILE_TEST_RESULT)
- SET(LIBEVENT_VERSION_STRING "${RUN_OUTPUT}")
+ SET(LIBEVENT_VERSION_STRING "2.1.11-stable") # extra\libevent\libevent-2.1.11-stable\
STRING(REGEX REPLACE
"([.-0-9]+).*" "\\1" LIBEVENT_VERSION "${LIBEVENT_VERSION_STRING}")
SET(LIBEVENT_VERSION ${LIBEVENT_VERSION} CACHE INTERNAL "" FORCE)
diff --git a/cmake/os/Windows.cmake b/cmake/os/Windows.cmake
index 8ae3d150b88..f58cd717b09 100644
--- a/cmake/os/Windows.cmake
+++ b/cmake/os/Windows.cmake
@@ -61,6 +61,8 @@ IF(CMAKE_SIZEOF_VOID_P MATCHES 8)
ELSE()
IF(WITHOUT_SERVER)
MESSAGE(WARNING "32bit is experimental!!")
+ SET(SYSTEM_TYPE "Win32")
+ SET(MYSQL_MACHINE_TYPE "x86")
ELSE()
MESSAGE(FATAL_ERROR "32 bit Windows builds are not supported. "
"Clean the build dir and rebuild using -G \"${CMAKE_GENERATOR} Win64\"")
diff --git a/cmake/ssl.cmake b/cmake/ssl.cmake
index 9d76fa19616..94bf55ece00 100644
--- a/cmake/ssl.cmake
+++ b/cmake/ssl.cmake
@@ -196,7 +196,7 @@ FUNCTION(FIND_OPENSSL_EXECUTABLE)
FIND_PROGRAM(OPENSSL_EXECUTABLE openssl)
ENDIF()

- IF(OPENSSL_EXECUTABLE)
+ IF(OFF) #OPENSSL_EXECUTABLE)
SET(OPENSSL_EXECUTABLE_HAS_ZLIB 0)
EXECUTE_PROCESS(
COMMAND ${OPENSSL_EXECUTABLE} "list-cipher-commands"
@@ -806,6 +806,13 @@ MACRO(MYSQL_CHECK_SSL_DLLS)
SET(SSL_MSVC_VERSION_SUFFIX "-3")
SET(SSL_MSVC_ARCH_SUFFIX "-x64")
ENDIF()
+ IF("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "Win32")
+ SET(SSL_MSVC_ARCH_SUFFIX "")
+ ELSEIF("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "x64")
+ SET(SSL_MSVC_ARCH_SUFFIX "-x64")
+ ELSEIF("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "ARM64")
+ SET(SSL_MSVC_ARCH_SUFFIX "-arm64")
+ ENDIF()

FIND_FILE(HAVE_CRYPTO_DLL
NAMES
diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt
index 8222a5c38a7..857f74d8242 100644
--- a/scripts/CMakeLists.txt
+++ b/scripts/CMakeLists.txt
@@ -53,11 +53,17 @@ ELSE()
MESSAGE(FATAL_ERROR "Cannot concatenate files")
ENDIF()

+IF(WIN32 AND "${CMAKE_GENERATOR_PLATFORM}" STREQUAL "ARM64")
+ SET(comp_sql_CMD "${CMAKE_BINARY_DIR}/../build-x64/runtime_output_directory/RelWithDebInfo/comp_sql.exe")
+ELSE()
+ SET(comp_sql_CMD comp_sql)
+ENDIF()
+
# Build mysql_fix_privilege_tables.h
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/mysql_fix_privilege_tables_sql.h
${CAT_COMMAND}
- COMMAND comp_sql
+ COMMAND ${comp_sql_CMD}
mysql_fix_privilege_tables
mysql_fix_privilege_tables.sql
mysql_fix_privilege_tables_sql.h
@@ -75,7 +81,7 @@ MY_ADD_CUSTOM_TARGET(GenFixPrivs

ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sql_commands_sys_schema.h
- COMMAND comp_sql
+ COMMAND ${comp_sql_CMD}
mysql_sys_schema
${CMAKE_CURRENT_SOURCE_DIR}/mysql_sys_schema.sql
sql_commands_sys_schema.h
@@ -86,7 +92,7 @@ ADD_CUSTOM_COMMAND(

ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sql_commands_system_data.h
- COMMAND comp_sql
+ COMMAND ${comp_sql_CMD}
mysql_system_data
${CMAKE_CURRENT_SOURCE_DIR}/mysql_system_tables_data.sql
sql_commands_system_data.h
@@ -97,7 +103,7 @@ ADD_CUSTOM_COMMAND(

ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sql_commands_system_tables_data_fix.h
- COMMAND comp_sql
+ COMMAND ${comp_sql_CMD}
mysql_system_tables_data_fix
${CMAKE_CURRENT_SOURCE_DIR}/mysql_system_tables_data_fix.sql
sql_commands_system_tables_data_fix.h
@@ -108,7 +114,7 @@ ADD_CUSTOM_COMMAND(

ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sql_commands_system_tables.h
- COMMAND comp_sql
+ COMMAND ${comp_sql_CMD}
mysql_system_tables
${CMAKE_CURRENT_SOURCE_DIR}/mysql_system_tables.sql
sql_commands_system_tables.h
@@ -119,7 +125,7 @@ ADD_CUSTOM_COMMAND(

ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sql_commands_system_users.h
- COMMAND comp_sql
+ COMMAND ${comp_sql_CMD}
mysql_system_users
${CMAKE_CURRENT_SOURCE_DIR}/mysql_system_users.sql
sql_commands_system_users.h
@@ -130,7 +136,7 @@ ADD_CUSTOM_COMMAND(

ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sql_commands_help_data.h
- COMMAND comp_sql
+ COMMAND ${comp_sql_CMD}
fill_help_tables
${CMAKE_CURRENT_SOURCE_DIR}/fill_help_tables.sql
sql_commands_help_data.h
@@ -141,7 +147,7 @@ ADD_CUSTOM_COMMAND(

ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sql_firewall_stored_procedures.h
- COMMAND comp_sql
+ COMMAND ${comp_sql_CMD}
firewall_stored_procedures
${CMAKE_CURRENT_SOURCE_DIR}/firewall_stored_procedures.sql
sql_firewall_stored_procedures.h
diff --git a/scripts/sys_schema/CMakeLists.txt b/scripts/sys_schema/CMakeLists.txt
index aaba3575df4..8ae560a53e9 100644
--- a/scripts/sys_schema/CMakeLists.txt
+++ b/scripts/sys_schema/CMakeLists.txt
@@ -204,10 +204,16 @@ ADD_CUSTOM_COMMAND(
MY_ADD_CUSTOM_TARGET(all_sys_schema
DEPENDS ALL_SYS_SCHEMA.sql)

+IF(WIN32 AND "${CMAKE_GENERATOR_PLATFORM}" STREQUAL "ARM64")
+ SET(comp_sql_CMD "${CMAKE_BINARY_DIR}/../build-x64/runtime_output_directory/RelWithDebInfo/comp_sql.exe")
+ELSE()
+ SET(comp_sql_CMD comp_sql)
+ENDIF()
+

ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/sql_commands.h
- COMMAND comp_sql
+ COMMAND ${comp_sql_CMD}
mysql_sys_schema
${CMAKE_CURRENT_BINARY_DIR}/ALL_SYS_SCHEMA.sql
sql_commands.h
diff --git a/sql-common/client.cc b/sql-common/client.cc
index a57e94d30c7..701d190675d 100644
--- a/sql-common/client.cc
+++ b/sql-common/client.cc
@@ -8535,9 +8535,9 @@ int STDCALL mysql_options(MYSQL *mysql, enum mysql_option option,
mysql->options.report_data_truncation = *static_cast<const bool *>(arg);
break;
case MYSQL_OPT_RECONNECT:
- fprintf(stderr,
- "WARNING: MYSQL_OPT_RECONNECT is deprecated and will be "
- "removed in a future version.\n");
+ // fprintf(stderr,
+ // "WARNING: MYSQL_OPT_RECONNECT is deprecated and will be "
+ // "removed in a future version.\n");
mysql->reconnect = *static_cast<const bool *>(arg);
break;
case MYSQL_OPT_BIND:
@@ -8865,9 +8865,9 @@ int STDCALL mysql_get_option(MYSQL *mysql, enum mysql_option option,
mysql->options.report_data_truncation;
break;
case MYSQL_OPT_RECONNECT:
- fprintf(stderr,
- "WARNING: MYSQL_OPT_RECONNECT is deprecated and will be "
- "removed in a future version.\n");
+ // fprintf(stderr,
+ // "WARNING: MYSQL_OPT_RECONNECT is deprecated and will be "
+ // "removed in a future version.\n");
*(const_cast<bool *>(static_cast<const bool *>(arg))) = mysql->reconnect;
break;
case MYSQL_OPT_BIND:
diff --git a/strings/CMakeLists.txt b/strings/CMakeLists.txt
index 4fd0f3afd16..4e1e25ddb39 100644
--- a/strings/CMakeLists.txt
+++ b/strings/CMakeLists.txt
@@ -68,9 +68,15 @@ SET(ZH_HANS_DST_FILE ${CMAKE_BINARY_DIR}/strings/uca900_zh_tbls.cc)
SET(JA_HANS_SRC_FILE ${CMAKE_SOURCE_DIR}/strings/lang_data/ja_hans.txt)
SET(JA_HANS_DST_FILE ${CMAKE_BINARY_DIR}/strings/uca900_ja_tbls.cc)

+IF(WIN32 AND "${CMAKE_GENERATOR_PLATFORM}" STREQUAL "ARM64")
+ SET(uca9dump_CMD "${CMAKE_BINARY_DIR}/../build-x64/runtime_output_directory/RelWithDebInfo/uca9dump.exe")
+ELSE()
+ SET(uca9dump_CMD uca9dump)
+ENDIF()
+
ADD_CUSTOM_COMMAND(
OUTPUT ${JA_HANS_DST_FILE}
- COMMAND uca9dump ja
+ COMMAND ${uca9dump_CMD} ja
--in_file=${JA_HANS_SRC_FILE}
--out_file=${JA_HANS_DST_FILE}
DEPENDS uca9dump ${JA_HANS_SRC_FILE}
@@ -79,7 +85,7 @@ ADD_CUSTOM_TARGET(strings_ja_hans DEPENDS ${JA_HANS_DST_FILE})

ADD_CUSTOM_COMMAND(
OUTPUT ${ZH_HANS_DST_FILE}
- COMMAND uca9dump zh
+ COMMAND ${uca9dump_CMD} zh
--in_file=${ZH_HANS_SRC_FILE}
--out_file=${ZH_HANS_DST_FILE}
DEPENDS uca9dump ${ZH_HANS_SRC_FILE}
diff --git a/utilities/CMakeLists.txt b/utilities/CMakeLists.txt
index 808c2e8a38a..4fe75209824 100644
--- a/utilities/CMakeLists.txt
+++ b/utilities/CMakeLists.txt
@@ -44,8 +44,14 @@ MYSQL_ADD_EXECUTABLE(comp_client_err
SKIP_INSTALL
)

+IF(WIN32 AND "${CMAKE_GENERATOR_PLATFORM}" STREQUAL "ARM64")
+ SET(comp_client_err_CMD "${CMAKE_BINARY_DIR}/../build-x64/runtime_output_directory/RelWithDebInfo/comp_client_err.exe")
+ELSE()
+ SET(comp_client_err_CMD comp_client_err)
+ENDIF()
+
ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_BINARY_DIR}/include/mysqlclient_ername.h
- COMMAND comp_client_err
+ COMMAND ${comp_client_err_CMD}
--in_file=${PROJECT_SOURCE_DIR}/include/errmsg.h
--out_file=${PROJECT_BINARY_DIR}/include/mysqlclient_ername.h
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/comp_client_err.cc)
@@ -69,12 +75,18 @@ FILE(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/${INSTALL_MYSQLSHAREDIR})
#
# Please see errmsg_readme.txt in the same directory for more information.
#
+IF(WIN32 AND "${CMAKE_GENERATOR_PLATFORM}" STREQUAL "ARM64")
+ SET(comp_err_CMD "${CMAKE_BINARY_DIR}/../build-x64/runtime_output_directory/RelWithDebInfo/comp_err.exe")
+ELSE()
+ SET(comp_err_CMD comp_err)
+ENDIF()
+
ADD_CUSTOM_COMMAND(OUTPUT
${PROJECT_BINARY_DIR}/include/mysqld_error.h
${PROJECT_BINARY_DIR}/include/mysqld_ername.h
${PROJECT_BINARY_DIR}/include/mysqld_errmsg.h
${PROJECT_BINARY_DIR}/${INSTALL_MYSQLSHAREDIR}/english/errmsg.sys
- COMMAND comp_err
+ COMMAND ${comp_err_CMD}
--charset=${PROJECT_SOURCE_DIR}/share/charsets
--out-dir=${PROJECT_BINARY_DIR}/${INSTALL_MYSQLSHAREDIR}/
--header_file=${PROJECT_BINARY_DIR}/include/mysqld_error.h

0 comments on commit ad96e8e

Please sign in to comment.