Skip to content

Commit

Permalink
Merge pull request #18416 from GordonSmith/HPCC-31456-LIBMYSQL_HOSTS
Browse files Browse the repository at this point in the history
HPCC-31456 Prevent libmysql from building "host" targets

Reviewed-by: Gavin Halliday <[email protected]>
Merged-by: Gavin Halliday <[email protected]>
  • Loading branch information
ghalliday authored Mar 15, 2024
2 parents 1b9763f + 8a11e42 commit 43962f5
Show file tree
Hide file tree
Showing 9 changed files with 663 additions and 1 deletion.
4 changes: 3 additions & 1 deletion vcpkg.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@
},
{
"name": "libmysql",
"platform": "@VCPKG_MYSQLEMBED@ & !(windows & x86)"
"platform": "@VCPKG_MYSQLEMBED@ & !(windows & x86)",
"default-features": false,
"features": []
},
{
"name": "librdkafka",
Expand Down
162 changes: 162 additions & 0 deletions vcpkg_overlays/libmysql/cross-build.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
diff --git a/cmake/os/Darwin.cmake b/cmake/os/Darwin.cmake
index 725b9bd..289bb3d 100644
--- a/cmake/os/Darwin.cmake
+++ b/cmake/os/Darwin.cmake
@@ -31,13 +31,9 @@ ENDIF()
# We require at least XCode 10.0
IF(NOT FORCE_UNSUPPORTED_COMPILER)
IF(MY_COMPILER_IS_CLANG)
- CHECK_C_SOURCE_RUNS("
- int main()
- {
- return (__clang_major__ < 10);
- }" HAVE_SUPPORTED_CLANG_VERSION)
- IF(NOT HAVE_SUPPORTED_CLANG_VERSION)
- MESSAGE(FATAL_ERROR "XCode 10.0 or newer is required!")
+ IF (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10)
+ MESSAGE(FATAL_ERROR
+ "XCode 10.0 or newer is required! Compiler version was ${CMAKE_CXX_COMPILER_VERSION}")
ENDIF()
ELSE()
MESSAGE(FATAL_ERROR "Unsupported compiler!")
diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt
index 8e22453..2b63413 100644
--- a/libmysql/CMakeLists.txt
+++ b/libmysql/CMakeLists.txt
@@ -259,6 +259,7 @@ ELSEIF(FREEBSD)
MESSAGE(STATUS "BSD built in DNS SRV APIs")
ELSE()
FIND_LIBRARY(RESOLV_LIBRARY NAMES resolv)
+ FIND_LIBRARY(RESOLV_LIBRARY NAMES resolv PATHS ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES} NO_DEFAULT_PATH)
IF (RESOLV_LIBRARY)
LIST(APPEND LIBS_TO_LINK ${RESOLV_LIBRARY})
SET(HAVE_UNIX_DNS_SRV 1 PARENT_SCOPE)
@@ -413,6 +414,7 @@ MYSQL_ADD_EXECUTABLE(libmysql_api_test
${CMAKE_CURRENT_BINARY_DIR}/api_test.c
LINK_LIBRARIES libmysql ${LIBRT}
SKIP_INSTALL
+ EXCLUDE_FROM_ALL
)
# Clang/UBSAN needs this on some platforms.
SET_TARGET_PROPERTIES(libmysql_api_test PROPERTIES LINKER_LANGUAGE CXX)
@@ -439,6 +441,6 @@ ADD_CUSTOM_COMMAND(
COMMAND libmysql_api_test
> ${CMAKE_CURRENT_BINARY_DIR}/libmysql_api_test.out
)
-MY_ADD_CUSTOM_TARGET(run_libmysql_api_test ALL
+MY_ADD_CUSTOM_TARGET(run_libmysql_api_test
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/libmysql_api_test.out
)
diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt
index 8e93387..d971acb 100644
--- a/scripts/CMakeLists.txt
+++ b/scripts/CMakeLists.txt
@@ -69,7 +69,6 @@ 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
)

diff --git a/scripts/sys_schema/CMakeLists.txt b/scripts/sys_schema/CMakeLists.txt
index aaba357..a0e5265 100644
--- a/scripts/sys_schema/CMakeLists.txt
+++ b/scripts/sys_schema/CMakeLists.txt
@@ -221,7 +221,6 @@ MY_ADD_CUSTOM_TARGET(sql_commands
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/sql_commands.h)

MY_ADD_CUSTOM_TARGET(GenSysSchemaC
- ALL
DEPENDS comp_sql sql_commands
COMMENT "Generating Sys Schema C code"
)
diff --git a/share/CMakeLists.txt b/share/CMakeLists.txt
index 28cde40..be916cb 100644
--- a/share/CMakeLists.txt
+++ b/share/CMakeLists.txt
@@ -47,8 +47,12 @@ SET(dirs
ukrainian
)

-FOREACH (dir ${dirs})
- INSTALL(DIRECTORY ${CMAKE_BINARY_DIR}/${INSTALL_MYSQLSHAREDIR}/${dir}
+ set(src_dir ${CMAKE_BINARY_DIR}/share/libmysql)
+ if(CMAKE_CROSSCOMPILING)
+ set(src_dir ${VCPKG_INSTALLED_DIR}/${VCPKG_HOST_TRIPLET}/share/libmysql)
+ endif()
+ FOREACH (dir ${dirs})
+ INSTALL(DIRECTORY ${src_dir}/${dir}
DESTINATION ${INSTALL_MYSQLSHAREDIR}
COMPONENT Server
)
diff --git a/strings/CMakeLists.txt b/strings/CMakeLists.txt
index 665b35d..88f0743 100644
--- a/strings/CMakeLists.txt
+++ b/strings/CMakeLists.txt
@@ -69,6 +69,13 @@ SET(ZH_HANS_SRC_FILE ${CMAKE_SOURCE_DIR}/strings/lang_data/zh_hans.txt)
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(CMAKE_CROSSCOMPILING)
+ file(COPY
+ "${VCPKG_INSTALLED_DIR}/${VCPKG_HOST_TRIPLET}/share/libmysql/${PROJECT_VERSION}/uca900_zh_tbls.cc"
+ "${VCPKG_INSTALLED_DIR}/${VCPKG_HOST_TRIPLET}/share/libmysql/${PROJECT_VERSION}/uca900_ja_tbls.cc"
+ DESTINATION "${CMAKE_BINARY_DIR}/strings"
+ )
+else()
ADD_CUSTOM_COMMAND(OUTPUT ${ZH_HANS_DST_FILE}
${JA_HANS_DST_FILE}
COMMAND uca9dump zh
@@ -79,6 +86,8 @@ ADD_CUSTOM_COMMAND(OUTPUT ${ZH_HANS_DST_FILE}
--out_file=${JA_HANS_DST_FILE}
DEPENDS uca9dump ${ZH_HANS_SRC_FILE} ${JA_HANS_SRC_FILE}
)
+install(FILES "${ZH_HANS_DST_FILE}" "${JA_HANS_DST_FILE}" DESTINATION "share/libmysql/${PROJECT_VERSION}")
+endif()

SET_SOURCE_FILES_PROPERTIES(
${JA_HANS_DST_FILE} ${ZH_HANS_DST_FILE}
diff --git a/utilities/CMakeLists.txt b/utilities/CMakeLists.txt
index da34524..dc397da 100644
--- a/utilities/CMakeLists.txt
+++ b/utilities/CMakeLists.txt
@@ -39,6 +39,21 @@ MYSQL_ADD_EXECUTABLE(comp_client_err
SKIP_INSTALL
)

+if(CMAKE_CROSSCOMPILING)
+ file(COPY
+ ${VCPKG_INSTALLED_DIR}/${VCPKG_HOST_TRIPLET}/include/mysql/mysqld_error.h
+ ${VCPKG_INSTALLED_DIR}/${VCPKG_HOST_TRIPLET}/share/libmysql/${PROJECT_VERSION}/mysqlclient_ername.h
+ ${VCPKG_INSTALLED_DIR}/${VCPKG_HOST_TRIPLET}/share/libmysql/${PROJECT_VERSION}/mysqld_ername.h
+ ${VCPKG_INSTALLED_DIR}/${VCPKG_HOST_TRIPLET}/share/libmysql/${PROJECT_VERSION}/mysqld_errmsg.h
+ DESTINATION ${PROJECT_BINARY_DIR}/include
+ )
+ file(COPY
+ ${VCPKG_INSTALLED_DIR}/${VCPKG_HOST_TRIPLET}/share/libmysql/${PROJECT_VERSION}/errmsg.sys
+ DESTINATION ${PROJECT_BINARY_DIR}/share/libmysql/english
+ )
+ add_custom_target(GenClientError)
+ add_custom_target(GenError)
+else()
ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_BINARY_DIR}/include/mysqlclient_ername.h
COMMAND comp_client_err
--in_file=${PROJECT_SOURCE_DIR}/include/errmsg.h
@@ -97,6 +112,16 @@ MYSQL_ADD_EXECUTABLE(range_check_err
SKIP_INSTALL
)

+ install(
+ FILES
+ ${PROJECT_BINARY_DIR}/include/mysqlclient_ername.h
+ ${PROJECT_BINARY_DIR}/include/mysqld_ername.h
+ ${PROJECT_BINARY_DIR}/include/mysqld_errmsg.h
+ ${PROJECT_BINARY_DIR}/share/libmysql/english/errmsg.sys
+ DESTINATION share/libmysql/${PROJECT_VERSION}
+ )
+endif()
+
# Set InnoDB mutex type
ADD_DEFINITIONS(-DMUTEX_EVENT)

140 changes: 140 additions & 0 deletions vcpkg_overlays/libmysql/dependencies.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e17ec1d0..465e42f0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -818,8 +818,12 @@ INCLUDE(fileutils)
INCLUDE(zlib)
INCLUDE(zstd)
INCLUDE(lz4)
-INCLUDE(icu)
-INCLUDE(libevent)
+macro(MYSQL_CHECK_ICU)
+endmacro()
+macro(MYSQL_CHECK_LIBEVENT)
+endmacro()
+macro(WARN_MISSING_SYSTEM_LIBEVENT)
+endmacro()
INCLUDE(ssl)
INCLUDE(sasl)
INCLUDE(ldap)
@@ -837,7 +841,8 @@ INCLUDE(curl)
INCLUDE(rapidjson)
INCLUDE(fprofile)
INCLUDE(gloves)
-INCLUDE(fido2)
+macro(MYSQL_CHECK_FIDO)
+endmacro()
INCLUDE(win_jemalloc)

IF(UNIX)
@@ -1942,7 +1947,7 @@ MYSQL_CHECK_RAPIDJSON()
MYSQL_CHECK_FIDO()
MYSQL_CHECK_FIDO_DLLS()

-IF(APPLE)
+IF(0)
GET_FILENAME_COMPONENT(HOMEBREW_BASE ${HOMEBREW_HOME} DIRECTORY)
IF(EXISTS ${HOMEBREW_BASE}/include/boost)
FOREACH(SYSTEM_LIB ICU LIBEVENT LZ4 PROTOBUF ZSTD FIDO)
diff --git a/cmake/boost.cmake b/cmake/boost.cmake
index c979055c..53e55fcf 100644
--- a/cmake/boost.cmake
+++ b/cmake/boost.cmake
@@ -301,7 +301,7 @@ IF(NOT BOOST_MAJOR_VERSION EQUAL 10)
COULD_NOT_FIND_BOOST()
ENDIF()

-IF(NOT BOOST_MINOR_VERSION EQUAL 77)
+IF(NOT BOOST_MINOR_VERSION EQUAL 77 AND NOT IGNORE_BOOST_VERSION)
MESSAGE(WARNING "Boost minor version found is ${BOOST_MINOR_VERSION} "
"we need 77"
)
diff --git a/cmake/libutils.cmake b/cmake/libutils.cmake
index 7107f4bd..bb7f3733 100644
--- a/cmake/libutils.cmake
+++ b/cmake/libutils.cmake
@@ -534,7 +534,7 @@ MACRO(MERGE_CONVENIENCE_LIBRARIES TARGET_ARG)

# On Windows, ssleay32.lib/libeay32.lib or libssl.lib/libcrypto.lib
# must be merged into mysqlclient.lib
- IF(WIN32 AND ${TARGET} STREQUAL "mysqlclient")
+ IF(0)
SET(LINKER_EXTRA_FLAGS "")
FOREACH(LIB ${SSL_LIBRARIES})
STRING_APPEND(LINKER_EXTRA_FLAGS " ${LIB}")
diff --git a/cmake/lz4.cmake b/cmake/lz4.cmake
index 10e7e8c8..48772329 100644
--- a/cmake/lz4.cmake
+++ b/cmake/lz4.cmake
@@ -46,7 +46,7 @@ FUNCTION(FIND_SYSTEM_LZ4)
FIND_PATH(LZ4_INCLUDE_DIR
NAMES lz4frame.h)
FIND_LIBRARY(LZ4_SYSTEM_LIBRARY
- NAMES lz4)
+ NAMES lz4d lz4 NAMES_PER_DIR)
IF (LZ4_INCLUDE_DIR AND LZ4_SYSTEM_LIBRARY)
SET(SYSTEM_LZ4_FOUND 1 CACHE INTERNAL "")
ADD_LIBRARY(lz4_interface INTERFACE)
diff --git a/cmake/ssl.cmake b/cmake/ssl.cmake
index 04e3af87..8ae52c82 100644
--- a/cmake/ssl.cmake
+++ b/cmake/ssl.cmake
@@ -273,7 +273,18 @@ MACRO (MYSQL_CHECK_SSL)
FIND_ALTERNATIVE_SYSTEM_SSL()
ENDIF()

- IF(WITH_SSL STREQUAL "system" OR WITH_SSL_PATH OR ALTERNATIVE_SYSTEM_SSL)
+ IF(WITH_SSL STREQUAL "system")
+ find_package(OpenSSL REQUIRED)
+ set(OPENSSL_LIBRARY OpenSSL::SSL CACHE STRING "")
+ set(CRYPTO_LIBRARY OpenSSL::Crypto CACHE STRING "")
+ find_program(OPENSSL_EXECUTABLE openssl
+ DOC "path to the openssl executable")
+ set(SSL_DEFINES "-DHAVE_OPENSSL")
+ add_library(ext::openssl ALIAS OpenSSL::SSL)
+ set(SSL_LIBRARIES ext::openssl)
+ set(OPENSSL_APPLINK_C "${OPENSSL_APPLINK_SOURCE}")
+ include_directories(SYSTEM ${OPENSSL_INCLUDE_DIR})
+ ELSEIF(WITH_SSL STREQUAL "system" OR WITH_SSL_PATH OR ALTERNATIVE_SYSTEM_SSL)
IF((APPLE OR WIN32) AND WITH_SSL STREQUAL "system")
# FindOpenSSL.cmake knows about
# http://www.slproweb.com/products/Win32OpenSSL.html
diff --git a/cmake/zlib.cmake b/cmake/zlib.cmake
index 3781fe09..ac312ad0 100644
--- a/cmake/zlib.cmake
+++ b/cmake/zlib.cmake
@@ -124,7 +124,7 @@ MACRO (MYSQL_CHECK_ZLIB)
MESSAGE(FATAL_ERROR "WITH_ZLIB must be bundled or system")
ENDIF()

- ADD_LIBRARY(ext::zlib ALIAS zlib_interface)
+ ADD_LIBRARY(ext::zlib ALIAS ZLIB::ZLIB)

IF(ZLIB_VERSION VERSION_LESS MIN_ZLIB_VERSION_REQUIRED)
MESSAGE(FATAL_ERROR
diff --git a/cmake/zstd.cmake b/cmake/zstd.cmake
index 425426d1..0ae1a907 100644
--- a/cmake/zstd.cmake
+++ b/cmake/zstd.cmake
@@ -90,15 +90,16 @@ MACRO (MYSQL_CHECK_ZSTD)
IF(WITH_ZSTD STREQUAL "bundled")
MYSQL_USE_BUNDLED_ZSTD()
ELSEIF(WITH_ZSTD STREQUAL "system")
- FIND_SYSTEM_ZSTD()
- IF (NOT SYSTEM_ZSTD_FOUND)
- MESSAGE(FATAL_ERROR "Cannot find system zstd libraries.")
- ENDIF()
+ find_package(ZSTD NAMES zstd REQUIRED)
ELSE()
MESSAGE(FATAL_ERROR "WITH_ZSTD must be bundled or system")
ENDIF()

- ADD_LIBRARY(ext::zstd ALIAS zstd_interface)
+ if(TARGET zstd::libzstd_shared)
+ add_library(ext::zstd ALIAS zstd::libzstd_shared)
+ else()
+ add_library(ext::zstd ALIAS zstd::libzstd_static)
+ endif()

IF(ZSTD_VERSION VERSION_LESS MIN_ZSTD_VERSION_REQUIRED)
MESSAGE(FATAL_ERROR
20 changes: 20 additions & 0 deletions vcpkg_overlays/libmysql/fix_dup_symbols.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt
index 058967b..bcd8841 100644
--- a/client/CMakeLists.txt
+++ b/client/CMakeLists.txt
@@ -43,7 +43,6 @@ MYSQL_ADD_EXECUTABLE(mysql
pattern_matcher.cc
readline.cc
client_query_attributes.cc
- multi_factor_passwordopt-vars.cc
${CMAKE_CURRENT_SOURCE_DIR}/common/user_registration.cc
LINK_LIBRARIES mysqlclient client_base ${EDITLINE_LIBRARY}
)
@@ -226,7 +226,6 @@ SET(MYSQLBINLOG_SOURCES
${CMAKE_SOURCE_DIR}/sql/binlog_reader.cc
${CMAKE_SOURCE_DIR}/sql/stream_cipher.cc
${CMAKE_SOURCE_DIR}/sql/rpl_log_encryption.cc
- ${CMAKE_SOURCE_DIR}/libbinlogevents/src/trx_boundary_parser.cpp
)

SET(MYSQLBINLOG_LIBRARIES
Loading

0 comments on commit 43962f5

Please sign in to comment.