Skip to content

Commit

Permalink
Bug#36108397 Upgrade to latest protobuf library [patches]
Browse files Browse the repository at this point in the history
Followup patch:

We no longer need to support el6, so remove our own homegrown linker
scripts for the protobuf libraries. This fixes problems with ODR
violations when running protoc with gRPC plugins. It also fixes bad
symbol bindings for our plugins which link with the protobuf shared
libraries.

We switch from STATIC to SHARED abseil libraries, in order to make
linking consistent for MySQL and plugins, and for protoc and its
(gRPC) plugins.

One extension to extra/protobuf/protobuf-24.4/src/libprotobuf.map
was needed for UBSAN builds with gcc/clang.

Change-Id: Icaddbfc1dbebe26cfe1d79a7acb39d329dd66e25
  • Loading branch information
Tor Didriksen committed Feb 15, 2024
1 parent fb665eb commit 36a97ba
Show file tree
Hide file tree
Showing 15 changed files with 623 additions and 78 deletions.
3 changes: 3 additions & 0 deletions extra/abseil/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ SET(ABSL_PROPAGATE_CXX_STD ON)
IF(MSVC AND NOT WIN32_CLANG)
SET(absl_BUILD_SHARED_LIBS ON)
ENDIF()
IF(LINUX)
SET(absl_BUILD_SHARED_LIBS ON)
ENDIF()

IF(MSVC AND (FPROFILE_GENERATE OR FPROFILE_USE))
# The use of CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS is incompatible with
Expand Down
23 changes: 22 additions & 1 deletion extra/abseil/abseil-cpp-20230802.1/CMake/AbseilHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,28 @@ Cflags: -I\${includedir}${PC_CFLAGS}\n")
)

elseif(_build_type STREQUAL "static" OR _build_type STREQUAL "shared")
add_library(${_NAME} "")
if (_build_type STREQUAL "static")
add_library(${_NAME} STATIC)
else()
ADD_SHARED_LIBRARY(${_NAME} SKIP_INSTALL)
INSTALL_PRIVATE_LIBRARY(${_NAME})
IF(LINUX)
ADD_INSTALL_RPATH(${_NAME} "\$ORIGIN")
ENDIF()
TARGET_LINK_OPTIONS(${_NAME} PRIVATE
-Wl,--version-script=${CMAKE_SOURCE_DIR}/extra/abseil/absllib.map
)
SET_TARGET_PROPERTIES(${_NAME}
PROPERTIES LINK_DEPENDS ${CMAKE_SOURCE_DIR}/extra/abseil/absllib.map
)
IF(WITH_ROUTER)
INSTALL(TARGETS ${_NAME}
LIBRARY
DESTINATION "${ROUTER_INSTALL_LIBDIR}"
COMPONENT Router
)
ENDIF()
endif()
target_sources(${_NAME} PRIVATE ${ABSL_CC_LIB_SRCS} ${ABSL_CC_LIB_HDRS})
target_link_libraries(${_NAME}
PUBLIC ${ABSL_CC_LIB_DEPS}
Expand Down
66 changes: 66 additions & 0 deletions extra/abseil/absllib.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
Copyright (c) 2024, Oracle and/or its affiliates.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
as published by the Free Software Foundation.

This program is designed to work with certain software (including
but not limited to OpenSSL) that is licensed under separate terms,
as designated in a particular file or component or in included license
documentation. The authors of MySQL hereby grant you an additional
permission to link the program and your derivative works with the
separately licensed software that they have either included with
the program or referenced in the documentation.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License, version 2.0, for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

/*
Hide all symbols from the standard library.

This is a workaround for libstdc++ problems which are caused
by our INSTALL_DEBUG_TARGET cmake macro: we *link* with one .so library,
but *run* with a different version.

The installed mysqld-debug will not start because of:
./bin/mysqld-debug: symbol lookup error: ./bin/mysqld-debug:
undefined symbol:
_ZNSt18basic_stringstreamIcSt11char_traitsIcESaIcEEC1Ev

Running c++filt on that, we get
std::basic_stringstream<char, std::char_traits<char>,
std::allocator<char> >::basic_stringstream()

The abseil libraries do not come with any --version-script, and
hence will export *all* symbols. By providing this version script
we explicitly disable the export of everything from the standard
library.

For mangling of names in the standard library, see:
https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling

<substitution> ::= St # ::std::
<substitution> ::= Sa # ::std::allocator
<substitution> ::= Sb # ::std::basic_string
<substitution> ::= Ss # ::std::basic_string < char,
::std::char_traits<char>,
::std::allocator<char> >
<substitution> ::= Si # ::std::basic_istream<char, std::char_traits<char> >
<substitution> ::= So # ::std::basic_ostream<char, std::char_traits<char> >
<substitution> ::= Sd # ::std::basic_iostream<char, std::char_traits<char> >
*/

MYSQL_HIDE_STD {
local:
_ZS[tabsiod]*;
_ZNS[tabsiod]*;
_ZNKS[tabsiod]*;
};
17 changes: 4 additions & 13 deletions extra/protobuf/protobuf-24.4/cmake/libprotobuf-lite.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ add_library(libprotobuf-lite ${protobuf_SHARED_OR_STATIC}
${libprotobuf_lite_srcs}
${libprotobuf_lite_hdrs}
${protobuf_version_rc_file})

# Disable this, we have our own version script
if(FALSE AND protobuf_HAVE_LD_VERSION_SCRIPT)
if(protobuf_HAVE_LD_VERSION_SCRIPT)
if(${CMAKE_VERSION} VERSION_GREATER 3.13 OR ${CMAKE_VERSION} VERSION_EQUAL 3.13)
target_link_options(libprotobuf-lite PRIVATE -Wl,--version-script=${protobuf_SOURCE_DIR}/src/libprotobuf-lite.map)
elseif(protobuf_BUILD_SHARED_LIBS)
Expand Down Expand Up @@ -59,16 +57,6 @@ IF(protobuf_BUILD_SHARED_LIBS)
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/library_output_directory
)

IF(LINUX)
SET_TARGET_PROPERTIES(libprotobuf-lite
PROPERTIES LINK_FLAGS
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libprotobuf.ver"
)
SET_TARGET_PROPERTIES(libprotobuf-lite
PROPERTIES LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libprotobuf.ver
)
ENDIF()

IF(WIN32)
ADD_CUSTOM_COMMAND(TARGET libprotobuf-lite POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
Expand All @@ -84,6 +72,9 @@ IF(protobuf_BUILD_SHARED_LIBS)
)
ENDIF()

IF(LINUX)
ADD_INSTALL_RPATH(libprotobuf-lite "\$ORIGIN")
ENDIF()
INSTALL_PRIVATE_LIBRARY(libprotobuf-lite)

IF(WITH_ROUTER)
Expand Down
16 changes: 4 additions & 12 deletions extra/protobuf/protobuf-24.4/cmake/libprotobuf.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ ADD_OBJDUMP_TARGET(show_libprotobuf "$<TARGET_FILE:libprotobuf>"
DEPENDS libprotobuf)
ADD_LIBRARY(ext::libprotobuf ALIAS libprotobuf)

# Disable this, we have our own version script
if(FALSE AND protobuf_HAVE_LD_VERSION_SCRIPT)
if(protobuf_HAVE_LD_VERSION_SCRIPT)
if(${CMAKE_VERSION} VERSION_GREATER 3.13 OR ${CMAKE_VERSION} VERSION_EQUAL 3.13)
target_link_options(libprotobuf PRIVATE -Wl,--version-script=${protobuf_SOURCE_DIR}/src/libprotobuf.map)
elseif(protobuf_BUILD_SHARED_LIBS)
Expand Down Expand Up @@ -62,16 +61,6 @@ IF(protobuf_BUILD_SHARED_LIBS)
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/library_output_directory
)

IF(LINUX)
SET_TARGET_PROPERTIES(libprotobuf
PROPERTIES LINK_FLAGS
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libprotobuf.ver"
)
SET_TARGET_PROPERTIES(libprotobuf
PROPERTIES LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libprotobuf.ver
)
ENDIF()

IF(WIN32)
ADD_CUSTOM_COMMAND(TARGET libprotobuf POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
Expand All @@ -87,6 +76,9 @@ IF(protobuf_BUILD_SHARED_LIBS)
)
ENDIF()

IF(LINUX)
ADD_INSTALL_RPATH(libprotobuf "\$ORIGIN")
ENDIF()
INSTALL_PRIVATE_LIBRARY(libprotobuf)

ENDIF()
3 changes: 1 addition & 2 deletions extra/protobuf/protobuf-24.4/cmake/libprotoc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ add_library(libprotoc ${protobuf_SHARED_OR_STATIC}
${libprotoc_hdrs}
${protobuf_version_rc_file})

# Disable this, we have our own version script
if(FALSE AND protobuf_HAVE_LD_VERSION_SCRIPT)
if(protobuf_HAVE_LD_VERSION_SCRIPT)
if(${CMAKE_VERSION} VERSION_GREATER 3.13 OR ${CMAKE_VERSION} VERSION_EQUAL 3.13)
target_link_options(libprotoc PRIVATE -Wl,--version-script=${protobuf_SOURCE_DIR}/src/libprotoc.map)
elseif(protobuf_BUILD_SHARED_LIBS)
Expand Down
45 changes: 0 additions & 45 deletions extra/protobuf/protobuf-24.4/libprotobuf.ver

This file was deleted.

6 changes: 5 additions & 1 deletion extra/protobuf/protobuf-24.4/src/libprotobuf.map
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/*
extra symbol export needed for gcc/clang with UBSAN:
ZTIN2pb11CppFeaturesE = typeinfo for pb::CppFeatures
*/
{
global:
extern "C++" {
Expand All @@ -6,7 +10,7 @@
};
scc_info_*;
descriptor_table_*;

_ZTIN2pb11CppFeaturesE;
local:
*;
};
85 changes: 85 additions & 0 deletions packaging/deb-in/mysql-packagesource-server-core.install.in
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,91 @@ usr/share/man/man8/mysqld.8
# private shared libraries
usr/lib/mysql/private/libprotobuf-lite.so.24.4.0
usr/lib/mysql/private/libprotobuf.so.24.4.0
usr/lib/mysql/private/libabsl_bad_any_cast_impl.so
usr/lib/mysql/private/libabsl_bad_optional_access.so
usr/lib/mysql/private/libabsl_bad_variant_access.so
usr/lib/mysql/private/libabsl_base.so
usr/lib/mysql/private/libabsl_city.so
usr/lib/mysql/private/libabsl_civil_time.so
usr/lib/mysql/private/libabsl_cord_internal.so
usr/lib/mysql/private/libabsl_cord.so
usr/lib/mysql/private/libabsl_cordz_functions.so
usr/lib/mysql/private/libabsl_cordz_handle.so
usr/lib/mysql/private/libabsl_cordz_info.so
usr/lib/mysql/private/libabsl_cordz_sample_token.so
usr/lib/mysql/private/libabsl_crc32c.so
usr/lib/mysql/private/libabsl_crc_cord_state.so
usr/lib/mysql/private/libabsl_crc_cpu_detect.so
usr/lib/mysql/private/libabsl_crc_internal.so
usr/lib/mysql/private/libabsl_debugging_internal.so
usr/lib/mysql/private/libabsl_demangle_internal.so
usr/lib/mysql/private/libabsl_die_if_null.so
usr/lib/mysql/private/libabsl_examine_stack.so
usr/lib/mysql/private/libabsl_exponential_biased.so
usr/lib/mysql/private/libabsl_failure_signal_handler.so
usr/lib/mysql/private/libabsl_flags_commandlineflag_internal.so
usr/lib/mysql/private/libabsl_flags_commandlineflag.so
usr/lib/mysql/private/libabsl_flags_config.so
usr/lib/mysql/private/libabsl_flags_internal.so
usr/lib/mysql/private/libabsl_flags_marshalling.so
usr/lib/mysql/private/libabsl_flags_parse.so
usr/lib/mysql/private/libabsl_flags_private_handle_accessor.so
usr/lib/mysql/private/libabsl_flags_program_name.so
usr/lib/mysql/private/libabsl_flags_reflection.so
usr/lib/mysql/private/libabsl_flags.so
usr/lib/mysql/private/libabsl_flags_usage_internal.so
usr/lib/mysql/private/libabsl_flags_usage.so
usr/lib/mysql/private/libabsl_graphcycles_internal.so
usr/lib/mysql/private/libabsl_hash.so
usr/lib/mysql/private/libabsl_hashtablez_sampler.so
usr/lib/mysql/private/libabsl_int128.so
usr/lib/mysql/private/libabsl_kernel_timeout_internal.so
usr/lib/mysql/private/libabsl_leak_check.so
usr/lib/mysql/private/libabsl_log_entry.so
usr/lib/mysql/private/libabsl_log_flags.so
usr/lib/mysql/private/libabsl_log_globals.so
usr/lib/mysql/private/libabsl_log_initialize.so
usr/lib/mysql/private/libabsl_log_internal_check_op.so
usr/lib/mysql/private/libabsl_log_internal_conditions.so
usr/lib/mysql/private/libabsl_log_internal_format.so
usr/lib/mysql/private/libabsl_log_internal_globals.so
usr/lib/mysql/private/libabsl_log_internal_log_sink_set.so
usr/lib/mysql/private/libabsl_log_internal_message.so
usr/lib/mysql/private/libabsl_log_internal_nullguard.so
usr/lib/mysql/private/libabsl_log_internal_proto.so
usr/lib/mysql/private/libabsl_log_severity.so
usr/lib/mysql/private/libabsl_log_sink.so
usr/lib/mysql/private/libabsl_low_level_hash.so
usr/lib/mysql/private/libabsl_malloc_internal.so
usr/lib/mysql/private/libabsl_periodic_sampler.so
usr/lib/mysql/private/libabsl_random_distributions.so
usr/lib/mysql/private/libabsl_random_internal_distribution_test_util.so
usr/lib/mysql/private/libabsl_random_internal_platform.so
usr/lib/mysql/private/libabsl_random_internal_pool_urbg.so
usr/lib/mysql/private/libabsl_random_internal_randen_hwaes_impl.so
usr/lib/mysql/private/libabsl_random_internal_randen_hwaes.so
usr/lib/mysql/private/libabsl_random_internal_randen_slow.so
usr/lib/mysql/private/libabsl_random_internal_randen.so
usr/lib/mysql/private/libabsl_random_internal_seed_material.so
usr/lib/mysql/private/libabsl_random_seed_gen_exception.so
usr/lib/mysql/private/libabsl_random_seed_sequences.so
usr/lib/mysql/private/libabsl_raw_hash_set.so
usr/lib/mysql/private/libabsl_raw_logging_internal.so
usr/lib/mysql/private/libabsl_scoped_set_env.so
usr/lib/mysql/private/libabsl_spinlock_wait.so
usr/lib/mysql/private/libabsl_stacktrace.so
usr/lib/mysql/private/libabsl_statusor.so
usr/lib/mysql/private/libabsl_status.so
usr/lib/mysql/private/libabsl_strerror.so
usr/lib/mysql/private/libabsl_str_format_internal.so
usr/lib/mysql/private/libabsl_strings_internal.so
usr/lib/mysql/private/libabsl_strings.so
usr/lib/mysql/private/libabsl_string_view.so
usr/lib/mysql/private/libabsl_symbolize.so
usr/lib/mysql/private/libabsl_synchronization.so
usr/lib/mysql/private/libabsl_throw_delegate.so
usr/lib/mysql/private/libabsl_time.so
usr/lib/mysql/private/libabsl_time_zone.so
# private data files
usr/lib/mysql/private/icudt73l/cnvalias.icu
usr/lib/mysql/private/icudt73l/uemoji.icu
Expand Down
1 change: 1 addition & 0 deletions packaging/deb-in/mysql-router-packagesource.install.in
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ usr/lib/mysqlrouter/plugin/rest_routing.so
usr/lib/mysqlrouter/plugin/rest_metadata_cache.so
# private shared libraries
usr/lib/mysqlrouter/private/libprotobuf-lite.so.24.4.0
usr/lib/mysqlrouter/private/libabsl_*.so
usr/lib/mysqlrouter/private/libmysqlharness.so.1
usr/lib/mysqlrouter/private/libmysqlharness_stdx.so.1
usr/lib/mysqlrouter/private/libmysqlharness_tls.so.1
Expand Down
Loading

0 comments on commit 36a97ba

Please sign in to comment.