Bug #115163 Contribution: Build failure with Protobuf 22+ in Linux
Submitted: 29 May 13:42 Modified: 4 Aug 0:04
Reporter: OCA Admin (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: CPU Architecture:Any

[29 May 13:42] OCA Admin
Description:
This bug tracks a contribution by gordon wang (Github user: gordonwwang), as described in http://github.com/mysql/mysql-server/pull/544

How to repeat:
See description

Suggested fix:
See contribution code attached
[29 May 13:42] OCA Admin
Contribution submitted via Github - Build failure with Protobuf 22+ in Linux 
(*) Contribution by gordon wang (Github gordonwwang, mysql-server/pull/544#issuecomment-2136426181): I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: git_patch_1886040851.txt (text/plain), 3.62 KiB.

[30 May 10:07] Tor Didriksen
Posted by developer:
 
with protobuf version >= 22, shouldn't this be solved by simply doing

find_package(Protobuf REQUIRED CONFIG)

that should look up /usr/lib64/cmake/protobuf/ProtobufTargets.cmake
(or something like that)
which will define a target protobuf::libprotobuf with a bunch of INTERFACE_LINK_LIBRARIES ...
[30 May 10:08] MySQL Verification Team
Thank you, Tor.
[30 May 10:08] MySQL Verification Team
Hi OCA Admin,

Would you be so kind to answer Tor's VERY valid question ????

Thank you in advance .....
[30 May 12:04] gordon wang
Hi Tor~

In fact, the comment in cmake/protobuf.cmake already mentions:
` ` `
# We cannot use the IMPORTED libraries defined by FIND_PACKAGE above,
# protobuf::libprotobuf may have INTERFACE properties like -std=gnu++11
# and that will break the build since we use -std=c++20
` ` `

This should explain your question about find_package.
[30 May 12:12] Tor Didriksen
ah yes, that was a broken build on MacOS, where system headers had ifdefs hiding C++17/C++20 features.

What Linux version are you using?
[30 May 12:22] gordon wang
kernel 6.6, gcc-12.3.1
[5 Jun 11:23] Tor Didriksen
thanks, but my intention was:
what Linux system has system protobuf >= 22, so that I can test  my cmake code?
[5 Jun 11:37] gordon wang
Hi Tor~

As far as I know, protobuf 22+ is available in both OpenCloudOS Stream and OpenSUSE Tumbleweed distributions. 
I compiled the verification in a Linux environment with OpenCloudOS Stream (ocs, similar to CentOS Stream 9, using rpm/dnf).

The following is the ocs image download address, if you need to install and verify:
https://qa.opencloudos.tech/image/20240220/x86_64/OpenCloudOS-Stream-23-20240220-netinst-x...
[6 Jun 11:14] Tor Didriksen
Posted by developer:
 
objdump -p /usr/lib64/libprotobuf.so | grep NEEDED
  NEEDED               libz.so.1
  NEEDED               libabsl_die_if_null.so.2401.0.0
  NEEDED               libabsl_statusor.so.2401.0.0
  NEEDED               libabsl_log_internal_check_op.so.2401.0.0
  NEEDED               libabsl_log_internal_conditions.so.2401.0.0
  NEEDED               libabsl_log_internal_message.so.2401.0.0
  NEEDED               libabsl_log_internal_nullguard.so.2401.0.0
  NEEDED               libabsl_raw_hash_set.so.2401.0.0
  NEEDED               libabsl_hash.so.2401.0.0
  NEEDED               libabsl_status.so.2401.0.0
  NEEDED               libabsl_cord.so.2401.0.0
  NEEDED               libabsl_cordz_info.so.2401.0.0
  NEEDED               libabsl_synchronization.so.2401.0.0
  NEEDED               libabsl_time.so.2401.0.0
  NEEDED               libabsl_time_zone.so.2401.0.0
  NEEDED               libabsl_bad_variant_access.so.2401.0.0
  NEEDED               libabsl_str_format_internal.so.2401.0.0
  NEEDED               libabsl_strings.so.2401.0.0
  NEEDED               libabsl_string_view.so.2401.0.0
  NEEDED               libabsl_spinlock_wait.so.2401.0.0
  NEEDED               libabsl_throw_delegate.so.2401.0.0
  NEEDED               libstdc++.so.6
  NEEDED               libgcc_s.so.1
  NEEDED               libc.so.6
  NEEDED               ld-linux-x86-64.so.2

but I still get missing symbols.
Rather than doing a transitive closure of library dependencies,
I will try to parse the output of this instead

ldd /usr/lib64/libprotobuf.so
        linux-vdso.so.1 (0x00007ffe70ac4000)
        libz.so.1 => /usr/lib64/libz.so.1 (0x00007fd72b0f4000)
        libabsl_die_if_null.so.2401.0.0 => /usr/lib64/libabsl_die_if_null.so.2401.0.0 (0x00007fd72b0f1000)
        libabsl_statusor.so.2401.0.0 => /usr/lib64/libabsl_statusor.so.2401.0.0 (0x00007fd72b0ec000)
        libabsl_log_internal_check_op.so.2401.0.0 => /usr/lib64/libabsl_log_internal_check_op.so.2401.0.0 (0x00007fd72b0e3000)
        libabsl_log_internal_conditions.so.2401.0.0 => /usr/lib64/libabsl_log_internal_conditions.so.2401.0.0 (0x00007fd72b0e0000)
        libabsl_log_internal_message.so.2401.0.0 => /usr/lib64/libabsl_log_internal_message.so.2401.0.0 (0x00007fd72b0d5000)
        libabsl_log_internal_nullguard.so.2401.0.0 => /usr/lib64/libabsl_log_internal_nullguard.so.2401.0.0 (0x00007fd72b0d2000)
        libabsl_raw_hash_set.so.2401.0.0 => /usr/lib64/libabsl_raw_hash_set.so.2401.0.0 (0x00007fd72b0ce000)
        libabsl_hash.so.2401.0.0 => /usr/lib64/libabsl_hash.so.2401.0.0 (0x00007fd72b0c9000)
        libabsl_status.so.2401.0.0 => /usr/lib64/libabsl_status.so.2401.0.0 (0x00007fd72b0c0000)
        libabsl_cord.so.2401.0.0 => /usr/lib64/libabsl_cord.so.2401.0.0 (0x00007fd72b0a8000)
        libabsl_cordz_info.so.2401.0.0 => /usr/lib64/libabsl_cordz_info.so.2401.0.0 (0x00007fd72b0a2000)
        libabsl_synchronization.so.2401.0.0 => /usr/lib64/libabsl_synchronization.so.2401.0.0 (0x00007fd72b092000)
        libabsl_time.so.2401.0.0 => /usr/lib64/libabsl_time.so.2401.0.0 (0x00007fd72b07d000)
        libabsl_time_zone.so.2401.0.0 => /usr/lib64/libabsl_time_zone.so.2401.0.0 (0x00007fd72b060000)
        libabsl_bad_variant_access.so.2401.0.0 => /usr/lib64/libabsl_bad_variant_access.so.2401.0.0 (0x00007fd72b05b000)
        libabsl_str_format_internal.so.2401.0.0 => /usr/lib64/libabsl_str_format_internal.so.2401.0.0 (0x00007fd72b03f000)
        libabsl_strings.so.2401.0.0 => /usr/lib64/libabsl_strings.so.2401.0.0 (0x00007fd72b01f000)
        libabsl_string_view.so.2401.0.0 => /usr/lib64/libabsl_string_view.so.2401.0.0 (0x00007fd72b01a000)
        libabsl_spinlock_wait.so.2401.0.0 => /usr/lib64/libabsl_spinlock_wait.so.2401.0.0 (0x00007fd72b017000)
        libabsl_throw_delegate.so.2401.0.0 => /usr/lib64/libabsl_throw_delegate.so.2401.0.0 (0x00007fd72b012000)
        libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007fd72adcb000)
        libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fd72ada7000)
        libc.so.6 => /lib64/libc.so.6 (0x00007fd72ab92000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fd72b3cc000)
        libabsl_raw_logging_internal.so.2401.0.0 => /usr/lib64/libabsl_raw_logging_internal.so.2401.0.0 (0x00007fd72ab8e000)
        libabsl_base.so.2401.0.0 => /usr/lib64/libabsl_base.so.2401.0.0 (0x00007fd72ab88000)
        libabsl_examine_stack.so.2401.0.0 => /usr/lib64/libabsl_examine_stack.so.2401.0.0 (0x00007fd72ab82000)
        libabsl_log_internal_format.so.2401.0.0 => /usr/lib64/libabsl_log_internal_format.so.2401.0.0 (0x00007fd72ab7e000)
        libabsl_log_internal_proto.so.2401.0.0 => /usr/lib64/libabsl_log_internal_proto.so.2401.0.0 (0x00007fd72ab7a000)
        libabsl_strerror.so.2401.0.0 => /usr/lib64/libabsl_strerror.so.2401.0.0 (0x00007fd72ab76000)
        libabsl_log_internal_log_sink_set.so.2401.0.0 => /usr/lib64/libabsl_log_internal_log_sink_set.so.2401.0.0 (0x00007fd72ab71000)
        libabsl_log_internal_globals.so.2401.0.0 => /usr/lib64/libabsl_log_internal_globals.so.2401.0.0 (0x00007fd72ab6b000)
        libabsl_log_globals.so.2401.0.0 => /usr/lib64/libabsl_log_globals.so.2401.0.0 (0x00007fd72ab66000)
        libabsl_city.so.2401.0.0 => /usr/lib64/libabsl_city.so.2401.0.0 (0x00007fd72ab62000)
        libabsl_low_level_hash.so.2401.0.0 => /usr/lib64/libabsl_low_level_hash.so.2401.0.0 (0x00007fd72ab5f000)
        libabsl_cord_internal.so.2401.0.0 => /usr/lib64/libabsl_cord_internal.so.2401.0.0 (0x00007fd72ab51000)
        libabsl_crc_cord_state.so.2401.0.0 => /usr/lib64/libabsl_crc_cord_state.so.2401.0.0 (0x00007fd72ab4a000)
        libabsl_cordz_functions.so.2401.0.0 => /usr/lib64/libabsl_cordz_functions.so.2401.0.0 (0x00007fd72ab45000)
        libabsl_cordz_handle.so.2401.0.0 => /usr/lib64/libabsl_cordz_handle.so.2401.0.0 (0x00007fd72ab40000)
        libabsl_stacktrace.so.2401.0.0 => /usr/lib64/libabsl_stacktrace.so.2401.0.0 (0x00007fd72ab3c000)
        libabsl_kernel_timeout_internal.so.2401.0.0 => /usr/lib64/libabsl_kernel_timeout_internal.so.2401.0.0 (0x00007fd72ab38000)
        libabsl_malloc_internal.so.2401.0.0 => /usr/lib64/libabsl_malloc_internal.so.2401.0.0 (0x00007fd72ab32000)
        libabsl_int128.so.2401.0.0 => /usr/lib64/libabsl_int128.so.2401.0.0 (0x00007fd72ab29000)
        libm.so.6 => /lib64/libm.so.6 (0x00007fd72aa3f000)
        libabsl_strings_internal.so.2401.0.0 => /usr/lib64/libabsl_strings_internal.so.2401.0.0 (0x00007fd72aa3b000)
        libabsl_symbolize.so.2401.0.0 => /usr/lib64/libabsl_symbolize.so.2401.0.0 (0x00007fd72aa34000)
        libabsl_log_sink.so.2401.0.0 => /usr/lib64/libabsl_log_sink.so.2401.0.0 (0x00007fd72aa31000)
        libabsl_crc32c.so.2401.0.0 => /usr/lib64/libabsl_crc32c.so.2401.0.0 (0x00007fd72aa2a000)
        libabsl_exponential_biased.so.2401.0.0 => /usr/lib64/libabsl_exponential_biased.so.2401.0.0 (0x00007fd72aa27000)
        libabsl_debugging_internal.so.2401.0.0 => /usr/lib64/libabsl_debugging_internal.so.2401.0.0 (0x00007fd72aa21000)
        libabsl_demangle_internal.so.2401.0.0 => /usr/lib64/libabsl_demangle_internal.so.2401.0.0 (0x00007fd72aa18000)
        libabsl_crc_internal.so.2401.0.0 => /usr/lib64/libabsl_crc_internal.so.2401.0.0 (0x00007fd72aa11000)
[6 Jun 11:23] MySQL Verification Team
Thank you, Tor.

These are the issues that have to be resolved by the reporter.
[4 Aug 0:04] Jon Stephens
Documented fix as follows in the MySQL 8.0.40, 8.4.3, and 9.1.0 changelogs:

    It was not possible to build MySQL using Protobuf 22 or later.

    Our thanks to Gordon Wang for the contribution.

Closed.
[5 Aug 9:59] MySQL Verification Team
Thank you, Jon.