Commit afcd7091 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-5529 Sync libmysqlclient.so symbol versioning across distributions

An attempt to introduce libmysqlclient.so symbol versioning that is
compatible both with Debian and Fedora all versions: put all symbols into
libmysqlclient_18 version node (as on Debian), but also put aliases of
old symbols into libmysqlclient_16 version node (as on Fedora).

Also use a linker script to create aliases of exported symbols, not
rpm_support.cc source file.
parent b1966435
...@@ -1432,4 +1432,4 @@ storage/tokudb/ft-index/util/tests/threadpool-testrunf ...@@ -1432,4 +1432,4 @@ storage/tokudb/ft-index/util/tests/threadpool-testrunf
storage/tokudb/ft-index/utils/tokudb_dump storage/tokudb/ft-index/utils/tokudb_dump
storage/tokudb/ft-index/utils/tokudb_gen storage/tokudb/ft-index/utils/tokudb_gen
storage/tokudb/ft-index/utils/tokudb_load storage/tokudb/ft-index/utils/tokudb_load
libmysql/libmysql.version libmysql/libmysql_versions.ld
...@@ -26,8 +26,6 @@ ADD_DEFINITIONS(${SSL_DEFINES}) ...@@ -26,8 +26,6 @@ ADD_DEFINITIONS(${SSL_DEFINES})
SET(CLIENT_API_FUNCTIONS_5_1 SET(CLIENT_API_FUNCTIONS_5_1
get_tty_password get_tty_password
handle_options
load_defaults
mysql_thread_end mysql_thread_end
mysql_thread_init mysql_thread_init
myodbc_remove_escape myodbc_remove_escape
...@@ -131,6 +129,12 @@ mysql_server_init ...@@ -131,6 +129,12 @@ mysql_server_init
mysql_server_end mysql_server_end
mysql_set_character_set mysql_set_character_set
mysql_get_character_set_info mysql_get_character_set_info
# These are documented in Paul DuBois' MySQL book,
# so we treat them as part of the de-facto API.
handle_options
load_defaults
free_defaults
my_print_help
) )
SET(CLIENT_API_FUNCTIONS_5_5 SET(CLIENT_API_FUNCTIONS_5_5
...@@ -153,6 +157,8 @@ mysql_close_cont ...@@ -153,6 +157,8 @@ mysql_close_cont
mysql_close_start mysql_close_start
mysql_commit_cont mysql_commit_cont
mysql_commit_start mysql_commit_start
mysql_dump_debug_info_cont
mysql_dump_debug_info_start
mysql_fetch_row_cont mysql_fetch_row_cont
mysql_fetch_row_start mysql_fetch_row_start
mysql_free_result_cont mysql_free_result_cont
...@@ -239,17 +245,24 @@ IF(CMAKE_SYSTEM_NAME MATCHES "Linux") ...@@ -239,17 +245,24 @@ IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
# for compatibility with distribution packages, so client shared library can # for compatibility with distribution packages, so client shared library can
# painlessly replace the one supplied by the distribution. # painlessly replace the one supplied by the distribution.
# Also list of exported symbols in distributions may differ from what is considered # Also list of exported symbols in distributions may differ from what is
# official API. Define CLIENT_API_EXTRA for the set of symbols, that required to # considered official API. Define CLIENT_API_5_1_EXTRA for the set of
# be exported on different platforms. # symbols, that required to be exported on different platforms.
IF(RPM)
# Fedora & Co declared following functions as part of API # Fedora & Co declared following functions as part of API
SET(CLIENT_API_EXTRA SET(CLIENT_API_5_1_EXTRA
# why does Fedora export these?
_fini
_init
my_init
# mysql-connector-odbc requires these
mysql_default_charset_info mysql_default_charset_info
mysql_get_charset mysql_get_charset
mysql_get_charset_by_csname mysql_get_charset_by_csname
mysql_net_realloc mysql_net_realloc
# PHP's mysqli.so requires this (via the ER() macro)
mysql_client_errors mysql_client_errors
# Also export the non-renamed variants # Also export the non-renamed variants
...@@ -260,51 +273,47 @@ IF(CMAKE_SYSTEM_NAME MATCHES "Linux") ...@@ -260,51 +273,47 @@ IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
get_charset_by_csname get_charset_by_csname
net_realloc net_realloc
client_errors client_errors
# pure-ftpd requires this
my_make_scrambled_password
# hydra requires this
scramble
# ODB requires this: https://bugzilla.redhat.com/show_bug.cgi?id=846602
THR_KEY_mysys THR_KEY_mysys
)
# Add special script to fix symbols renames by Fedora # DBD::mysql requires this
SET(CLIENT_SOURCES_EXTRA rpm_support.cc) is_prefix
SET(VERSION_SCRIPT_TEMPLATE
${CMAKE_CURRENT_SOURCE_DIR}/libmysql_rpm_version.in)
ELSEIF(DEB)
# libmyodbc on Ubuntu is using functions below
# If we don't export them, linker would just remove
# them (they are not used inside libmysqlclient)
SET(CLIENT_API_EXTRA
strfill
init_dynamic_string
) )
# MySQL supplied with Ubuntu does not have versioning, bug Debian does.
IF(DEB MATCHES "debian")
SET(VERSION_SCRIPT_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/libmysql.ver.in)
ENDIF()
ENDIF()
IF(VERSION_SCRIPT_TEMPLATE) # Linker script to version symbols in Fedora- and Debian- compatible way, MDEV-5529
SET(VERSION_SCRIPT_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/libmysql_versions.ld.in)
# Generate version script. # Generate version script.
# Create semicolon separated lists of functions to export from # Create semicolon separated lists of functions to export from
# Since RPM packages use separate versioning for 5.1 API # Since RPM packages use separate versioning for 5.1 API
# and 5.5 API (libmysqlclient_16 vs libmysqlclient_18), # and 5.5 API (libmysqlclient_16 vs libmysqlclient_18),
# we need 2 lists. # we need 2 lists.
SET (CLIENT_API_5_1_LIST) SET (CLIENT_API_5_1_LIST)
FOREACH (f ${CLIENT_API_FUNCTIONS_5_1}) SET (CLIENT_API_5_1_ALIASES)
SET(CLIENT_API_5_1_LIST "${CLIENT_API_5_1_LIST}\n${f};") FOREACH (f ${CLIENT_API_FUNCTIONS_5_1} ${CLIENT_API_5_1_EXTRA})
SET(CLIENT_API_5_1_LIST "${CLIENT_API_5_1_LIST}\t${f};\n")
SET(CLIENT_API_5_1_ALIASES "${CLIENT_API_5_1_ALIASES}\"${f}@libmysqlclient_16\" = ${f};\n")
ENDFOREACH() ENDFOREACH()
SET (CLIENT_API_5_5_LIST) SET (CLIENT_API_5_5_LIST)
FOREACH (f ${CLIENT_API_FUNCTIONS_5_5}) FOREACH (f ${CLIENT_API_FUNCTIONS_5_5})
SET(CLIENT_API_5_5_LIST "${CLIENT_API_5_5_LIST}\n${f};") SET(CLIENT_API_5_5_LIST "${CLIENT_API_5_5_LIST}\t${f};\n")
ENDFOREACH() ENDFOREACH()
CONFIGURE_FILE( CONFIGURE_FILE(
${VERSION_SCRIPT_TEMPLATE} ${VERSION_SCRIPT_TEMPLATE}
${CMAKE_CURRENT_BINARY_DIR}/libmysql.version ${CMAKE_CURRENT_BINARY_DIR}/libmysql_versions.ld
@ONLY@ @ONLY@
) )
SET(VERSION_SCRIPT_LINK_FLAGS SET(VERSION_SCRIPT_LINK_FLAGS
"-Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/libmysql.version") "-Wl,${CMAKE_CURRENT_BINARY_DIR}/libmysql_versions.ld")
ENDIF()
ENDIF() ENDIF()
...@@ -355,7 +364,7 @@ IF(UNIX) ...@@ -355,7 +364,7 @@ IF(UNIX)
ENDIF() ENDIF()
IF(NOT DISABLE_SHARED) IF(NOT DISABLE_SHARED)
MERGE_LIBRARIES(libmysql SHARED ${LIBS} EXPORTS ${CLIENT_API_FUNCTIONS} ${CLIENT_API_EXTRA} COMPONENT SharedLibraries) MERGE_LIBRARIES(libmysql SHARED ${LIBS} EXPORTS ${CLIENT_API_FUNCTIONS} ${CLIENT_API_5_1_EXTRA} COMPONENT SharedLibraries)
IF(UNIX) IF(UNIX)
# libtool compatability # libtool compatability
IF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR APPLE) IF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR APPLE)
...@@ -372,9 +381,6 @@ IF(NOT DISABLE_SHARED) ...@@ -372,9 +381,6 @@ IF(NOT DISABLE_SHARED)
SOVERSION "${SHARED_LIB_MAJOR_VERSION}") SOVERSION "${SHARED_LIB_MAJOR_VERSION}")
IF(LINK_FLAG_NO_UNDEFINED OR VERSION_SCRIPT_LINK_FLAGS) IF(LINK_FLAG_NO_UNDEFINED OR VERSION_SCRIPT_LINK_FLAGS)
GET_TARGET_PROPERTY(libmysql_link_flags libmysql LINK_FLAGS) GET_TARGET_PROPERTY(libmysql_link_flags libmysql LINK_FLAGS)
IF(NOT libmysql_link_flag)
SET(libmysql_link_flags)
ENDIF()
SET_TARGET_PROPERTIES(libmysql PROPERTIES LINK_FLAGS SET_TARGET_PROPERTIES(libmysql PROPERTIES LINK_FLAGS
"${libmysql_link_flags} ${LINK_FLAG_NO_UNDEFINED} ${VERSION_SCRIPT_LINK_FLAGS}") "${libmysql_link_flags} ${LINK_FLAG_NO_UNDEFINED} ${VERSION_SCRIPT_LINK_FLAGS}")
ENDIF() ENDIF()
......
libmysqlclient_@SHARED_LIB_MAJOR_VERSION@ { global: *; };
# This version script is heavily inspired by Fedora's and Mageia's version scripts for
# MySQL client shared library. It is used in MariaDB for building RPMs.
libmysqlclient_16 {
global:
@CLIENT_API_5_1_LIST@
# some stuff from Mageia, I have no idea why it is there
# But too afraid to throw anything away
_fini;
_init;
my_init;
my_progname;
myodbc_remove_escape;
# These are documented in Paul DuBois' MySQL book, so we treat them as part
# of the de-facto API.
free_defaults;
handle_options;
load_defaults;
my_print_help;
# pure-ftpd requires this
my_make_scrambled_password;
# fedora18 export
THR_KEY_mysys;
# hydra requires this
scramble;
# DBD::mysql requires this
is_prefix;
local:
*;
};
libmysqlclient_18 {
global:
@CLIENT_API_5_5_LIST@
#
# Ideally the following symbols wouldn't be exported, but various applications
# require them. Fedora limits the namespace damage by prefixing mysql_
# (see mysql-dubious-exports.patch), which means the symbols are not present
# in libmysqlclient_16.
#
# MariaDB does not do the Fedora-style function renaming via #define in headers,
# however it exports mysql_ prefixed symbols in addition to the "normal" ones.
#
# To ensure successful recompilation of affected projects, as well as drop-in replacement
# for MySQL libraries, provided by distribution, both original symbols and their mysql_
# prefixed counterparts have to be exported.
# mysql-connector-odbc requires these
mysql_default_charset_info;
mysql_get_charset;
mysql_get_charset_by_csname;
mysql_net_realloc;
default_charset_info;
get_charset;
get_charset_by_csname;
net_realloc;
# PHP's mysqli.so requires this (via the ER() macro)
mysql_client_errors;
client_errors;
};
/*
This version script is heavily inspired by Fedora's and Mageia's version
scripts for MySQL client shared library.
But it was modified to support Debian-compatible versioning too.
In RedHat universe, symbols from old libmysqlclient.so.16
keep their libmysqlclient_16 version. New symbols added in
libmysqlclient.so.18 get the new libmysqlclient_18 version.
In Debian all symbols in libmysqlclient.so.18 have libmysqlclient_18 version,
including symbols that existed in libmysqlclient.so.16
We solve this by putting all symbols into libmysqlclient_18 version node,
but creating aliases for old symbols in the libmysqlclient_16 version node.
*/
@CLIENT_API_5_1_ALIASES@
/*
On Fedora the following symbols are exported, but renamed into a mysql_
namespace. We export them as aliases, but keep original symbols too. See
MDEV-4127.
*/
mysql_default_charset_info = default_charset_info;
mysql_get_charset = get_charset;
mysql_get_charset_by_csname = get_charset_by_csname;
mysql_net_realloc = net_realloc;
mysql_client_errors = client_errors;
VERSION {
libmysqlclient_18 {
global:
@CLIENT_API_5_1_LIST@
@CLIENT_API_5_5_LIST@
local:
*;
};
libmysqlclient_16 {
/* empty here. aliases are added above */
};
}
/*
Provide aliases for several symbols, to support drop-in replacement for
MariaDB on Fedora and several derives distributions.
These distributions redefine several symbols (in a way that is no compatible
with either MySQL or MariaDB) and export it from the client library ( as seen
e.g from this patch)
http://lists.fedoraproject.org/pipermail/scm-commits/2010-December/537257.html
MariaDB handles compatibility distribution by providing the same symbols from
the client library if it is built with -DRPM
*/
#include <errmsg.h>
#include <my_sys.h>
#include <mysql.h>
extern "C" {
CHARSET_INFO *mysql_default_charset_info = default_charset_info;
CHARSET_INFO *mysql_get_charset(uint cs_number, myf flags)
{
return get_charset(cs_number, flags);
}
CHARSET_INFO *mysql_get_charset_by_csname(const char *cs_name,
uint cs_flags, myf my_flags)
{
return get_charset_by_csname(cs_name, cs_flags, my_flags);
}
my_bool mysql_net_realloc(NET *net, size_t length)
{
return net_realloc(net,length);
}
const char **mysql_client_errors = client_errors;
} /*extern "C" */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment