Skip to content

Conversation

mgorny
Copy link
Contributor

@mgorny mgorny commented Jan 24, 2025

  1. Refactor make_cffi.py to avoid performing the compilation in global scope, and allow passing parameters
  2. Support --system-zstd with the CFFI backend. This uses the C preprocessor to find the system headers for, well, further preprocessing.

With these changes, I can successfully build the CFFI extension using system zstd library, and have it pass tests. I've also confirmed that it builds fine after removing the zstd directory entirely.

Copy link
Owner

@indygreg indygreg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR got bit rotted. I'm supportive of the change in functionality. If you rebase, I'll merge and get it in the next release.

@mgorny
Copy link
Contributor Author

mgorny commented Sep 14, 2025

Sure, will do that now.

Move the CFFI-related logic from the global scope of `make_cffi.py`
file to a `get_ffi()` function.  This makes it possible to import
the file without executing the code immediately, and it will make it
possible to parametrize the invocation using explicit function
parameters.  Along with the change, I've renamed the variables to
lowercase since they are no longer global.

Signed-off-by: Michał Górny <[email protected]>
Support using the system zstd library with the CFFI backend.  Use
the GCC / Clang preprocessor output to find the paths to header files
for preprocessing.  Link to the system library, matching the behavior
for the C backend.

Signed-off-by: Michał Górny <[email protected]>
@mgorny
Copy link
Contributor Author

mgorny commented Sep 14, 2025

Rebased and updated.

@mgorny
Copy link
Contributor Author

mgorny commented Sep 14, 2025

Hmm, I wonder what's different about zstd on macOS that it fails. Unfortunately, I don't have a macOS system to test.

@indygreg
Copy link
Owner

Wow - that was a quick rebase!

The macOS failure looks legit. We'll need to figure out a path forward there. And I'm pressed for time today. I was planning to cut a release this weekend to help with 3.14 support. So we'll have to defer this to the next release.

@mgorny
Copy link
Contributor Author

mgorny commented Sep 14, 2025

Yeah, no problem with that. As a last resort, I suppose we could limit system zstd + CFFI to Linux, I guess, and force CFFI with vendored libs elsewhere.

Given that the CFFI code is much more fragile to library changes
than the C extension code, use a separate `--system-zstd-cffi` switch
to enable it.  This should resolve the test failure on macOS.

Signed-off-by: Michał Górny <[email protected]>
@mgorny
Copy link
Contributor Author

mgorny commented Sep 16, 2025

I went for the next best thing, I think: I've added a separate --system-zstd-cffi switch, so that both variants can switch between system and vendored library separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants