Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compilation issue when included with flate2 & cloudflare backend #14

Open
rob-p opened this issue Jan 13, 2025 · 2 comments
Open

compilation issue when included with flate2 & cloudflare backend #14

rob-p opened this issue Jan 13, 2025 · 2 comments

Comments

@rob-p
Copy link

rob-p commented Jan 13, 2025

Hi @kaizhang,

First, thanks for the nice crate! I was able to get anndata support working for our rust single-cell tool fairly easily!

I'm posting because I discovered a strange conflict when I include this crate along with flate2 (with my preferred cloudflare-zlib implementation)

I posted the issue in more detail in the flate2 repository. However, essentially, the following Cargo.toml is sufficient to trigger the problem:

[package]
name = "test_flate2"
version = "0.1.0"
edition = "2021"

[dependencies]
anndata = "0.6.1"
flate2 = { version = "1.0.35", features = ["cloudflare_zlib"] }

This results in the following compiler error:

error[E0308]: mismatched types
  --> /home/rob/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flate2-1.0.35/src/ffi/c.rs:65:25
   |
65 |                 zalloc: Some(allocator::zalloc),
   |                         ^^^^^^^^^^^^^^^^^^^^^^^ expected fn pointer, found `Option<extern "C" fn(..., ..., ...) -> ... {z
alloc}>`
   |
   = note: expected fn pointer `unsafe extern "C" fn(*mut c_void, u32, u32) -> *mut c_void`
                    found enum `Option<extern "C" fn(*mut c_void, u32, u32) -> *mut c_void {zalloc}>`

error[E0308]: mismatched types
  --> /home/rob/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flate2-1.0.35/src/ffi/c.rs:67:24
   |
67 |                 zfree: Some(allocator::zfree),
   |                        ^^^^^^^^^^^^^^^^^^^^^^ expected fn pointer, found `Option<extern "C" fn(..., ...) {zfree}>`
   |
   = note: expected fn pointer `unsafe extern "C" fn(*mut c_void, *mut c_void)`
                    found enum `Option<extern "C" fn(*mut c_void, *mut c_void) {zfree}>`

For more information about this error, try `rustc --explain E0308`.
error: could not compile `flate2` (lib) due to 2 previous errors

So it seems there is some conflicting / improper definition or it is somehow being included in the wrong place? Hopefully we can figure out what's triggering this so that this crate can be used successfully with flate2 with any of the zlib backends.

@kaizhang
Copy link
Owner

@rob-p Thanks for reporting this issue. I'll take a look into this.

BTW, anndata-rs supports only zstd compression by default. I'll add an option to select compression backends.

@rob-p
Copy link
Author

rob-p commented Jan 13, 2025

Thanks Kai!

I think the gz stuff is being pulled in by polars, but setting flags that break stuff. The error shows up when I include the niffler crate (for transparently detecting compression) in the project later. But both polars and flate2 are fine by themselves. It feels like the upstream package should maybe set some different options or flate2 should figure out what to do if different crates are included with different options? However, I think right now there is potential trouble for anyone wanting to use anndata (or polars) with a separate compression crate in their project, which would seem pretty common.

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

No branches or pull requests

2 participants