From ff5a528f260ea81e5ef06f4fd36c3d179e91fbd9 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 13 Jan 2020 13:08:55 +0100 Subject: [PATCH] mysqltest crashes on Debian Debian is apparently offended that pcre2-posix implements POSIX API, thus it renames all posix-compatible symbols in libpcre2-posix to have the PCRE2 prefix. But Debian doesn't do anything to pcre2posix.h header, so any unaware application will get POSIX compatible type names and function prototypes from pcre2, but actual symbols will come from libc. To remedy this enormous incongruity we have to redefine POSIX-compatible function names in pcre2posix to match Debian's hack. --- client/CMakeLists.txt | 2 +- cmake/pcre.cmake | 5 +++++ extra/mariabackup/CMakeLists.txt | 1 + libmysqld/examples/CMakeLists.txt | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index a9a122317dc..dfa805fc7e8 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -45,7 +45,7 @@ IF(UNIX) ENDIF(UNIX) MYSQL_ADD_EXECUTABLE(mysqltest mysqltest.cc COMPONENT Test) -SET_SOURCE_FILES_PROPERTIES(mysqltest.cc PROPERTIES COMPILE_FLAGS "-DTHREADS") +SET_SOURCE_FILES_PROPERTIES(mysqltest.cc PROPERTIES COMPILE_FLAGS "-DTHREADS ${PCRE2_DEBIAN_HACK}") TARGET_LINK_LIBRARIES(mysqltest ${CLIENT_LIB} pcre2-posix pcre2-8) SET_TARGET_PROPERTIES(mysqltest PROPERTIES ENABLE_EXPORTS TRUE) diff --git a/cmake/pcre.cmake b/cmake/pcre.cmake index 7ea43b56dea..ba72991ecd9 100644 --- a/cmake/pcre.cmake +++ b/cmake/pcre.cmake @@ -61,6 +61,11 @@ MACRO (CHECK_PCRE) MESSAGE(FATAL_ERROR "system pcre2-8 library is not found or unusable") ENDIF() BUNDLE_PCRE2() + ELSE() + CHECK_LIBRARY_EXISTS(pcre2-posix PCRE2regcomp "" NEEDS_PCRE2_DEBIAN_HACK) + IF(NEEDS_PCRE2_DEBIAN_HACK) + SET(PCRE2_DEBIAN_HACK "-Dregcomp=PCRE2regcomp -Dregexec=PCRE2regexec -Dregerror=PCRE2regerror -Dregfree=PCRE2regfree") + ENDIF() ENDIF() ENDMACRO() diff --git a/extra/mariabackup/CMakeLists.txt b/extra/mariabackup/CMakeLists.txt index 1649676e468..9c49a1e961b 100644 --- a/extra/mariabackup/CMakeLists.txt +++ b/extra/mariabackup/CMakeLists.txt @@ -38,6 +38,7 @@ INCLUDE_DIRECTORIES( IF(NOT HAVE_SYSTEM_REGEX) INCLUDE_DIRECTORIES(${PCRE_INCLUDES}) + ADD_DEFINITIONS(${PCRE2_DEBIAN_HACK}) ENDIF() diff --git a/libmysqld/examples/CMakeLists.txt b/libmysqld/examples/CMakeLists.txt index 6b3bed6e50e..5bd861c2f63 100644 --- a/libmysqld/examples/CMakeLists.txt +++ b/libmysqld/examples/CMakeLists.txt @@ -35,6 +35,7 @@ ENDIF(UNIX) MYSQL_ADD_EXECUTABLE(mysqltest_embedded ../../client/mysqltest.cc COMPONENT Test) TARGET_LINK_LIBRARIES(mysqltest_embedded mysqlserver pcre2-posix pcre2-8) +SET_SOURCE_FILES_PROPERTIES(../../client/mysqltest.cc PROPERTIES COMPILE_FLAGS "${PCRE2_DEBIAN_HACK}") IF(CMAKE_GENERATOR MATCHES "Xcode") # It does not seem possible to tell Xcode the resulting target might need