Skip to content

Commit 5dfa313

Browse files
committed
- Introduce MYSQL_ADD_PLUGIN that replaces MYSQL_STORAGE_ENGINE
- Fix semisync library prefix (remove lib on Unixes) - restrict exported symbols from zlib and yassl (fvisibility=hidden)
1 parent f458a4c commit 5dfa313

File tree

22 files changed

+145
-203
lines changed

22 files changed

+145
-203
lines changed

CMakeLists.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ MYSQL_CHECK_SSL()
169169
MYSQL_CHECK_READLINE()
170170

171171
IF(NOT WITHOUT_SERVER)
172+
SET (MYSQLD_STATIC_PLUGIN_LIBS "" CACHE INTERNAL "")
172173
# Add storage engines and plugins.
173174
CONFIGURE_PLUGINS()
174175
ENDIF()
@@ -219,7 +220,8 @@ CONFIGURE_FILE(config.h.cmake ${CMAKE_BINARY_DIR}/include/my_config.h)
219220
CONFIGURE_FILE(config.h.cmake ${CMAKE_BINARY_DIR}/include/config.h)
220221
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/include/mysql_version.h.in
221222
${CMAKE_BINARY_DIR}/include/mysql_version.h )
222-
223+
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/sql/sql_builtin.cc.in
224+
${CMAKE_BINARY_DIR}/sql/sql_builtin.cc)
223225

224226
# Packaging
225227
IF(WIN32)

cmake/Makefile.am

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
EXTRA_DIST = \
2-
cat.cmake \
2+
cmake_parse_arguments.cmake
33
configurable_file_content.in \
44
check_minimal_version.cmake \
55
create_initial_db.cmake.in \

cmake/libutils.cmake

+10-35
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@
5353

5454

5555
GET_FILENAME_COMPONENT(MYSQL_CMAKE_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
56-
IF(NOT WIN32 AND NOT CYGWIN AND NOT APPLE AND NOT WITH_PIC AND NOT DISABLE_SHARED
57-
AND CMAKE_SHARED_LIBRARY_C_FLAGS)
56+
IF(WIN32 OR CYGWIN OR APPLE OR WITH_PIC OR DISABLE_SHARED OR NOT CMAKE_SHARED_LIBRARY_C_FLAGS)
5857
SET(_SKIP_PIC 1)
5958
ENDIF()
60-
59+
60+
INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/cmake_parse_arguments.cmake)
6161
# CREATE_EXPORT_FILE (VAR target api_functions)
6262
# Internal macro, used to create source file for shared libraries that
6363
# otherwise consists entirely of "convenience" libraries. On Windows,
@@ -108,38 +108,6 @@ MACRO(ADD_CONVENIENCE_LIBRARY)
108108
ENDMACRO()
109109

110110

111-
# Handy macro to parse macro arguments
112-
MACRO(CMAKE_PARSE_ARGUMENTS prefix arg_names option_names)
113-
SET(DEFAULT_ARGS)
114-
FOREACH(arg_name ${arg_names})
115-
SET(${prefix}_${arg_name})
116-
ENDFOREACH(arg_name)
117-
FOREACH(option ${option_names})
118-
SET(${prefix}_${option} FALSE)
119-
ENDFOREACH(option)
120-
121-
SET(current_arg_name DEFAULT_ARGS)
122-
SET(current_arg_list)
123-
FOREACH(arg ${ARGN})
124-
SET(larg_names ${arg_names})
125-
LIST(FIND larg_names "${arg}" is_arg_name)
126-
IF (is_arg_name GREATER -1)
127-
SET(${prefix}_${current_arg_name} ${current_arg_list})
128-
SET(current_arg_name ${arg})
129-
SET(current_arg_list)
130-
ELSE (is_arg_name GREATER -1)
131-
SET(loption_names ${option_names})
132-
LIST(FIND loption_names "${arg}" is_option)
133-
IF (is_option GREATER -1)
134-
SET(${prefix}_${arg} TRUE)
135-
ELSE (is_option GREATER -1)
136-
SET(current_arg_list ${current_arg_list} ${arg})
137-
ENDIF (is_option GREATER -1)
138-
ENDIF (is_arg_name GREATER -1)
139-
ENDFOREACH(arg)
140-
SET(${prefix}_${current_arg_name} ${current_arg_list})
141-
ENDMACRO()
142-
143111
# Write content to file, using CONFIGURE_FILE
144112
# The advantage compared to FILE(WRITE) is that timestamp
145113
# does not change if file already has the same content
@@ -289,3 +257,10 @@ MACRO(MERGE_LIBRARIES)
289257
ENDIF()
290258
ENDMACRO()
291259

260+
MACRO(RESTRICT_SYMBOL_EXPORTS target)
261+
IF(CMAKE_COMPILER_IS_GNUCXX AND UNIX)
262+
GET_TARGET_PROPERTY(COMPILE_FLAGS ${target} COMPILE_FLAGS)
263+
SET_TARGET_PROPERTIES(${target} PROPERTIES
264+
COMPILE_FLAGS "${COMPILE_FLAGS} -fvisibility=hidden")
265+
ENDIF()
266+
ENDMACRO()

cmake/plugin.cmake

+91-101
Original file line numberDiff line numberDiff line change
@@ -13,106 +13,119 @@
1313
# along with this program; if not, write to the Free Software
1414
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1515

16-
# Creates a project to build plugin either as static or shared library
17-
# Parameters:
18-
# plugin - storage engine name.
19-
# variable BUILD_TYPE should be set to "STATIC" or "DYNAMIC"
20-
# Remarks:
21-
# ${PLUGIN}_SOURCES variable containing source files to produce the
22-
# library must set before calling this macro
2316

24-
MACRO(MYSQL_PLUGIN plugin)
17+
GET_FILENAME_COMPONENT(MYSQL_CMAKE_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
18+
INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/cmake_parse_arguments.cmake)
19+
20+
# MYSQL_ADD_PLUGIN(plugin_name source1...sourceN
21+
# [STORAGE_ENGINE]
22+
# [MANDATORY|DEFAULT]
23+
# [STATIC_ONLY|DYNAMIC_ONLY]
24+
# [MODULE_OUTPUT_NAME module_name]
25+
# [STATIC_OUTPUT_NAME static_name]
26+
# [RECOMPILE_FOR_EMBEDDED]
27+
# [LINK_LIBRARIES lib1...libN]
28+
# [DEPENDENCIES target1...targetN]
29+
30+
MACRO(MYSQL_ADD_PLUGIN)
31+
CMAKE_PARSE_ARGUMENTS(ARG
32+
"LINK_LIBRARIES;DEPENDENCIES;MODULE_OUTPUT_NAME;STATIC_OUTPUT_NAME"
33+
"STORAGE_ENGINE;STATIC_ONLY;MODULE_ONLY;MANDATORY;DEFAULT;DISABLED;RECOMPILE_FOR_EMBEDDED"
34+
${ARGN}
35+
)
36+
2537
# Add common include directories
2638
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
2739
${CMAKE_SOURCE_DIR}/sql
2840
${CMAKE_SOURCE_DIR}/regex
2941
${SSL_INCLUDE_DIRS}
3042
${ZLIB_INCLUDE_DIR})
3143

44+
LIST(GET ARG_DEFAULT_ARGS 0 plugin)
45+
SET(SOURCES ${ARG_DEFAULT_ARGS})
46+
LIST(REMOVE_AT SOURCES 0)
3247
STRING(TOUPPER ${plugin} plugin)
3348
STRING(TOLOWER ${plugin} target)
34-
35-
IF(NOT ${plugin}_PLUGIN_STATIC AND NOT ${plugin}_PLUGIN_DYNAMIC)
36-
MESSAGE(FATAL_ERROR
37-
"Neither ${plugin}_PLUGIN_STATIC nor ${plugin}_PLUGIN_DYNAMIC is defined.
38-
Please set at least one of these variables to the name of the output
39-
library in CMakeLists.txt prior to calling MYSQL_PLUGIN"
40-
)
41-
ENDIF()
4249

50+
# Figure out whether to build plugin
4351
IF(WITH_PLUGIN_${plugin})
4452
SET(WITH_${plugin} 1)
4553
ENDIF()
4654

47-
IF(WITH_${plugin}_STORAGE_ENGINE OR WITH_{$plugin} OR WITH_ALL
48-
OR WITH_MAX AND NOT WITHOUT_${plugin}_STORAGE_ENGINE AND NOT
49-
WITHOUT_${plugin})
55+
IF(WITH_${plugin}_STORAGE_ENGINE
56+
OR WITH_{$plugin}
57+
OR WITH_ALL
58+
OR WITH_MAX
59+
OR ARG_DEFAULT
60+
AND NOT WITHOUT_${plugin}_STORAGE_ENGINE
61+
AND NOT WITHOUT_${plugin}
62+
AND NOT ARG_MODULE_ONLY)
63+
5064
SET(WITH_${plugin} 1)
5165
ELSEIF(WITHOUT_${plugin}_STORAGE_ENGINE OR WITH_NONE OR ${plugin}_DISABLED)
5266
SET(WITHOUT_${plugin} 1)
5367
SET(WITH_${plugin}_STORAGE_ENGINE 0)
5468
SET(WITH_${plugin} 0)
5569
ENDIF()
56-
57-
IF(${plugin}_PLUGIN_MANDATORY)
58-
SET(WITH_${plugin} 1)
59-
ENDIF()
6070

61-
IF(${plugin} MATCHES NDBCLUSTER AND WITH_MAX_NO_NDB)
62-
SET(WITH_${plugin} 0)
63-
SET(WITH_${plugin}_STORAGE_ENGINE 0)
64-
SET(WITHOUT_${plugin} 1)
65-
SET(WITHOUT_${plugin}_STORAGE_ENGINE 0)
71+
72+
IF(ARG_MANDATORY)
73+
SET(WITH_${plugin} 1)
6674
ENDIF()
75+
6776

68-
IF(STORAGE_ENGINE)
69-
SET(with_var "WITH_${plugin}_STORAGE_ENGINE" )
77+
IF(ARG_STORAGE_ENGINE)
78+
SET(with_var "WITH_${plugin}_STORAGE_ENGINE" )
7079
ELSE()
71-
SET(with_var "WITH_${plugin}")
80+
SET(with_var "WITH_${plugin}")
7281
ENDIF()
7382

74-
75-
IF (WITH_${plugin} AND ${plugin}_PLUGIN_STATIC)
76-
ADD_DEFINITIONS(-DMYSQL_SERVER)
77-
#Create static library.
78-
ADD_LIBRARY(${target} ${${plugin}_SOURCES})
79-
DTRACE_INSTRUMENT(${target})
80-
ADD_DEPENDENCIES(${target} GenError)
81-
IF(WITH_EMBEDDED_SERVER AND NOT ${plugin}_PLUGIN_DYNAMIC)
82-
# Recompile couple of plugins for embedded
83-
ADD_LIBRARY(${target}_embedded ${${plugin}_SOURCES})
84-
DTRACE_INSTRUMENT(${target}_embedded)
85-
SET_TARGET_PROPERTIES(${target}_embedded
86-
PROPERTIES COMPILE_DEFINITIONS "EMBEDDED_LIBRARY")
87-
ADD_DEPENDENCIES(${target}_embedded GenError)
88-
ENDIF()
89-
IF(${plugin}_LIBS)
90-
TARGET_LINK_LIBRARIES(${target} ${${plugin}_LIBS})
83+
IF(NOT ARG_DEPENDENCIES)
84+
SET(ARG_DEPENDENCIES)
85+
ENDIF()
86+
# Build either static library or module
87+
IF (WITH_${plugin} AND NOT ARG_MODULE_ONLY)
88+
ADD_LIBRARY(${target} STATIC ${SOURCES})
89+
SET_TARGET_PROPERTIES(${target} PROPERTIES COMPILE_DEFINITONS "MYSQL_SERVER")
90+
DTRACE_INSTRUMENT(${target})
91+
ADD_DEPENDENCIES(${target} GenError ${ARG_DEPENDENCIES})
92+
IF(WITH_EMBEDDED_SERVER)
93+
# Embedded library should contain PIC code and be linkable
94+
# to shared libraries (on systems that need PIC)
95+
IF(ARG_RECOMPILE_FOR_EMBEDDED OR NOT _SKIP_PIC)
96+
# Recompile some plugins for embedded
97+
ADD_CONVENIENCE_LIBRARY(${target}_embedded ${SOURCES})
98+
DTRACE_INSTRUMENT(${target}_embedded)
99+
IF(ARG_RECOMPILE_FOR_EMBEDDED)
100+
SET_TARGET_PROPERTIES(${target}_embedded
101+
PROPERTIES COMPILE_DEFINITIONS "MYSQL_SERVER;EMBEDDED_LIBRARY")
102+
ENDIF()
103+
ADD_DEPENDENCIES(${target}_embedded GenError)
104+
ENDIF()
91105
ENDIF()
92106

93-
SET_TARGET_PROPERTIES(${target} PROPERTIES
94-
OUTPUT_NAME "${${plugin}_PLUGIN_STATIC}")
107+
IF(ARG_STATIC_OUTPUT_NAME)
108+
SET_TARGET_PROPERTIES(${target} PROPERTIES
109+
OUTPUT_NAME ${ARG_STATIC_OUTPUT_NAME})
110+
ENDIF()
111+
95112
# Update mysqld dependencies
96113
SET (MYSQLD_STATIC_PLUGIN_LIBS ${MYSQLD_STATIC_PLUGIN_LIBS}
97-
${target} PARENT_SCOPE)
114+
${target} CACHE INTERNAL "")
115+
98116
SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_${target}_plugin"
99-
PARENT_SCOPE)
100-
SET(${with_var} ON CACHE BOOL "Link ${plugin} statically to the server"
101-
FORCE)
102-
103-
ELSEIF(NOT WITHOUT_${plugin} AND ${plugin}_PLUGIN_DYNAMIC
104-
AND NOT WITHOUT_DYNAMIC_PLUGINS)
105-
106-
# Create a shared module.
107-
ADD_DEFINITIONS(-DMYSQL_DYNAMIC_PLUGIN)
108-
ADD_LIBRARY(${target} MODULE ${${plugin}_SOURCES})
109-
IF(${plugin}_LIBS)
110-
TARGET_LINK_LIBRARIES(${target} ${${plugin}_LIBS})
111-
ENDIF()
112-
DTRACE_INSTRUMENT(${target})
113-
SET_TARGET_PROPERTIES (${target} PROPERTIES PREFIX "")
117+
PARENT_SCOPE)
118+
IF(ARG_STORAGE_ENGINE)
119+
SET(${with_var} ON CACHE BOOL "Link ${plugin} statically to the server"
120+
FORCE)
121+
ENDIF()
122+
ELSEIF(NOT WITHOUT_${plugin} AND NOT ARG_STATIC_ONLY AND NOT WITHOUT_DYNAMIC_PLUGINS)
123+
124+
ADD_LIBRARY(${target} MODULE ${SOURCES})
125+
DTRACE_INSTRUMENT(${target})
126+
SET_TARGET_PROPERTIES (${target} PROPERTIES PREFIX ""
127+
COMPILE_DEFINITIONS "MYSQL_DYNAMIC_PLUGIN")
114128
TARGET_LINK_LIBRARIES (${target} mysqlservices)
115-
116129
# Plugin uses symbols defined in mysqld executable.
117130
# Some operating systems like Windows and OSX and are pretty strict about
118131
# unresolved symbols. Others are less strict and allow unresolved symbols
@@ -121,41 +134,26 @@ MACRO(MYSQL_PLUGIN plugin)
121134
# Thus we skip TARGET_LINK_LIBRARIES on Linux, as it would only generate
122135
# an additional dependency.
123136
IF(NOT CMAKE_SYSTEM_NAME STREQUAL "Linux")
124-
TARGET_LINK_LIBRARIES (${target} mysqld)
125-
ENDIF()
126-
ADD_DEPENDENCIES(${target} GenError)
127-
128-
IF(${plugin}_PLUGIN_DYNAMIC)
129-
SET_TARGET_PROPERTIES(${target} PROPERTIES
130-
OUTPUT_NAME "${${plugin}_PLUGIN_DYNAMIC}")
137+
TARGET_LINK_LIBRARIES (${target} mysqld ${ARG_LINK_LIBRARIES})
131138
ENDIF()
132-
133-
# Update cache "WITH" variable for plugins that support static linking
134-
IF(${plugin}_PLUGIN_STATIC)
135-
SET(${with_var} OFF CACHE BOOL "Link ${plugin} statically to the server"
136-
FORCE)
139+
ADD_DEPENDENCIES(${target} GenError ${ARG_DEPENDENCIES})
140+
141+
IF(NOT ARG_MODULE_OUTPUT_NAME)
142+
IF(ARG_STORAGE_ENGINE)
143+
SET(ARG_MODULE_OUTPUT_NAME "ha_${target}")
144+
ELSE()
145+
SET(ARG_MODULE_OUTPUT_NAME "${target}")
146+
ENDIF()
137147
ENDIF()
138-
148+
SET_TARGET_PROPERTIES(${target} PROPERTIES
149+
OUTPUT_NAME "${ARG_MODULE_OUTPUT_NAME}")
139150
# Install dynamic library
140151
SET(INSTALL_LOCATION lib/plugin)
141152
INSTALL(TARGETS ${target} DESTINATION ${INSTALL_LOCATION})
142153
INSTALL_DEBUG_SYMBOLS(${target})
143-
ELSE()
144-
IF(STORAGE_ENGINE)
145-
SET(without_var "WITHOUT_${plugin}_STORAGE_ENGINE")
146-
ELSE()
147-
SET(without_var "WITHOUT_${plugin}")
148-
ENDIF()
149-
SET(${without_var} ON CACHE BOOL "Link ${plugin} statically to the server"
150-
FORCE)
151-
MARK_AS_ADVANCED(${without_var})
152154
ENDIF()
153155
ENDMACRO()
154156

155-
MACRO (MYSQL_STORAGE_ENGINE engine)
156-
SET(STORAGE_ENGINE 1)
157-
MYSQL_PLUGIN(${engine})
158-
ENDMACRO()
159157

160158
# Add all CMake projects under storage and plugin
161159
# subdirectories, configure sql_builtins.cc
@@ -167,12 +165,4 @@ MACRO(CONFIGURE_PLUGINS)
167165
ADD_SUBDIRECTORY(${dir})
168166
ENDIF()
169167
ENDFOREACH()
170-
# Special handling for partition(not really pluggable)
171-
IF(NOT WITHOUT_PARTITION_STORAGE_ENGINE)
172-
SET (WITH_PARTITION_STORAGE_ENGINE 1)
173-
SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_partition_plugin")
174-
ENDIF(NOT WITHOUT_PARTITION_STORAGE_ENGINE)
175-
ADD_DEFINITIONS(${STORAGE_ENGINE_DEFS})
176-
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/sql/sql_builtin.cc.in
177-
${CMAKE_BINARY_DIR}/sql/sql_builtin.cc)
178168
ENDMACRO()

extra/yassl/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@ SET(YASSL_SOURCES src/buffer.cpp src/cert_wrapper.cpp src/crypto_wrapper.cpp sr
3030
src/log.cpp src/socket_wrapper.cpp src/ssl.cpp src/timer.cpp src/yassl_error.cpp
3131
src/yassl_imp.cpp src/yassl_int.cpp)
3232
ADD_CONVENIENCE_LIBRARY(yassl ${YASSL_SOURCES})
33+
RESTRICT_SYMBOL_EXPORTS(yassl)
3334

3435

extra/yassl/taocrypt/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@ SET(TAOCRYPT_SOURCES src/aes.cpp src/aestables.cpp src/algebra.cpp src/arc4.cpp
2727
include/md2.hpp include/md5.hpp include/misc.hpp include/modarith.hpp include/modes.hpp
2828
include/random.hpp include/ripemd.hpp include/rsa.hpp include/sha.hpp)
2929
ADD_CONVENIENCE_LIBRARY(taocrypt ${TAOCRYPT_SOURCES})
30+
RESTRICT_SYMBOL_EXPORTS(taocrypt)
3031

mysql-test/mysql-test-run.pl

+3-11
Original file line numberDiff line numberDiff line change
@@ -1873,18 +1873,10 @@ sub environment_setup {
18731873
# Add the path where mysqld will find semisync plugins
18741874
# --------------------------------------------------------------------------
18751875
if (!$opt_embedded_server) {
1876-
my $semisync_lib_prefix;
1877-
if (IS_WINDOWS)
1878-
{
1879-
$semisync_lib_prefix = "";
1880-
}
1881-
else
1882-
{
1883-
$semisync_lib_prefix= "lib";
1884-
}
18851876

1886-
my ($lib_semisync_master_plugin) = find_plugin($semisync_lib_prefix."semisync_master", "plugin/semisync");
1887-
my ($lib_semisync_slave_plugin) = find_plugin($semisync_lib_prefix."semisync_slave", "plugin/semisync");
1877+
1878+
my ($lib_semisync_master_plugin) = find_plugin("semisync_master", "plugin/semisync");
1879+
my ($lib_semisync_slave_plugin) = find_plugin("semisync_slave", "plugin/semisync");
18881880

18891881
if ($lib_semisync_master_plugin && $lib_semisync_slave_plugin)
18901882
{

plugin/daemon_example/CMakeLists.txt

+1-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,4 @@
1313
# along with this program; if not, write to the Free Software
1414
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1515

16-
SET(DAEMON_EXAMPLE_PLUGIN_DYNAMIC daemon_example)
17-
SET(DAEMON_EXAMPLE_SOURCES daemon_example.cc)
18-
MYSQL_PLUGIN(DAEMON_EXAMPLE)
16+
MYSQL_ADD_PLUGIN(DAEMON_EXAMPLE daemon_example.cc MODULE_ONLY)

plugin/fulltext/CMakeLists.txt

+2-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,5 @@
1313
# along with this program; if not, write to the Free Software
1414
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1515

16-
SET(FTEXAMPLE_PLUGIN_DYNAMIC mypluglib)
17-
SET(FTEXAMPLE_SOURCES plugin_example.c)
18-
MYSQL_PLUGIN(FTEXAMPLE)
16+
17+
MYSQL_ADD_PLUGIN(FTEXAMPLE plugin_example.c MODULE_ONLY MODULE_OUTPUT_NAME mypluglib)

0 commit comments

Comments
 (0)