Bug #99241 WITH_ZSTD=system fails with zstd 0.8.1 or older
Submitted: 13 Apr 2020 12:59 Modified: 24 Apr 2020 17:54
Reporter: Przemysław Skibiński (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:8.0.19 OS:Any
Assigned to: CPU Architecture:Any

[13 Apr 2020 12:59] Przemysław Skibiński
Description:
When zstd 0.8.1 or older is installed as a system library using cmake with "-DWITH_ZSTD=system" or "-DWITH_SYSTEM_LIBS=ON" causes compilation failures (make) e.g.:
/data/mysql-server/mysql-8.0/plugin/x/protocol/stream/compression/compression_algorithm_zstd.h:84:22: error: unknown type name 'ZSTD_outBuffer'
  bool compress_impl(ZSTD_outBuffer *out_buffer) {
                     ^
/data/mysql-server/mysql-8.0/plugin/x/protocol/stream/compression/compression_algorithm_zstd.h:98:3: error: unknown type name 'ZSTD_CStream'
  ZSTD_CStream *m_stream;
  ^
/data/mysql-server/mysql-8.0/plugin/x/protocol/stream/compression/compression_algorithm_zstd.h:99:3: error: unknown type name 'ZSTD_inBuffer'
  ZSTD_inBuffer m_in_buffer{nullptr, 0, 0};
  ^

How to repeat:
Download https://github.com/facebook/zstd/archive/v0.8.1.zip
Compile and install zstd with "make install".
Call "cmake -DWITH_ZSTD=system"

Suggested fix:
Will be attached.
[13 Apr 2020 13:01] Przemysław Skibiński
Check minimum required zstd version (currently 1.0)

Attachment: 99241_8-0-19.patch (text/x-patch), 2.20 KiB.

[14 Apr 2020 13:06] MySQL Verification Team
Hi,

Thanks for the report and the fix.

Best regards
Bogdan
[16 Apr 2020 13:31] Tor Didriksen
Posted by developer:
 
to verify:
$ ~/zstd-1.2.0
$make install DESTDIR=/tmp/foo

In MySQL build dir:
cmake <source dir> -UZSTD_INCLUDE_DIR -UZSTD_VERSION -UZSTD_SYSTEM_LIBRARY -DWITH_DEBUG=1 -DCMAKE_PREFIX_PATH=/tmp/foo/usr/local -DWITH_ZSTD=system
[24 Apr 2020 17:54] Paul DuBois
Posted by developer:
 
Fixed in 8.0.22.

Configuring with -DWITH_ZSTD=system failed for older versions of the
zstd library. CMake now checks the zstd version and requires at least
1.0.0 for compilation, 1.2.0 to run compression checks.