python-zstandard icon indicating copy to clipboard operation
python-zstandard copied to clipboard

0.23.0: build breakage with zstd 1.5.7

Open 0-wiz-0 opened this issue 9 months ago • 2 comments

When trying to compile release 0.23.0 having zstd 1.5.7 installed, I see

build/zstandard/_cffi.c: In function '_cffi_const_ZSTD_c_useBlockSplitter':
build/zstandard/_cffi.c:12168:12: error: 'ZSTD_c_useBlockSplitter' undeclared (first use in this function); did you mean 'ZSTD_c_maxBlockSize'?
12168 |   int n = (ZSTD_c_useBlockSplitter) <= 0;
      |            ^~~~~~~~~~~~~~~~~~~~~~~
      |            ZSTD_c_maxBlockSize

This parameter was removed in 1.5.7.

0-wiz-0 avatar Feb 20 '25 12:02 0-wiz-0

This was changed in https://github.com/facebook/zstd/pull/4180 - ZSTD_c_useBlockSplitter was an experimental parameter that never should have been used.

hhoffstaette avatar Feb 22 '25 12:02 hhoffstaette

To understand why this fails, see: https://github.com/indygreg/python-zstandard/blob/0063333790a853360c816101511635865405834f/c-ext/backend_c.c#L137-L151.

jjerphan avatar Feb 24 '25 17:02 jjerphan

Fixed with the 0.24 release and the upgrade to 1.5.7.

This was an error because the cffi bindings parse the zstd c source code and turn all structs and defines into Python equivalent values. But we parse the bundled libffi. So the bundled zstd 1.5.6 generated a cffi reference to a symbol that wasn't present in the library being compiled against, leading to an error.

Nominally we'd have cffi parse whatever libzstd is being linked against or have an allow list of symbols to limit exposure to this failure. But that can be discussed in a separate issue.

indygreg avatar Aug 17 '25 20:08 indygreg