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

gdal crate failing to compile #1591

Closed
spadarian opened this issue Jan 12, 2022 · 6 comments
Closed

gdal crate failing to compile #1591

spadarian opened this issue Jan 12, 2022 · 6 comments

Comments

@spadarian
Copy link

Crate name

map-engine

Build failure link

https://docs.rs/crate/map-engine/0.1.0/builds/491073

Additional details

Happy new year to everyone and thanks for your amazing work.

I just published my first crate (map-engine) and I'm having problems generating the docs due to a dependency that fails to compile.

The dependency is gdal which has an external dependency (GDAL). I checked if it was possible to make a PR to crates-build-env but the problem is that Ubuntu 18.04 has a very old version of GDAL.

Is there any recommended way of dealing with this?

  • I can generate my docs locally, is there any way to upload those?
  • The gdal crate has a custom build.rs that seems to deal with this. Does the build system use that or should I write my own build.rs?

Thanks!

@spadarian
Copy link
Author

The error comes from this conditional compilation in gdal:

#[cfg(docsrs)]
pub fn gdal_version_info(_key: &str) -> String {
    "GDAL 3.2.0, released 2222/02/22".to_string()
}

#[cfg(not(docsrs))]
pub fn gdal_version_info(key: &str) -> String {
    let c_key = std::ffi::CString::new(key.as_bytes()).unwrap();

    unsafe {
        let res_ptr = gdal_sys::GDALVersionInfo(c_key.as_ptr());
        let c_res = std::ffi::CStr::from_ptr(res_ptr);
        c_res.to_string_lossy().into_owned()
    }
}

They do provide a flag in their Cargo.toml:

[package.metadata.docs.rs]
rustc-args = ["--cfg", "docsrs"]

But the building system seems to ignore it (you can see "--config" "build.rustflags=[\"--cfg\", \"docsrs\"]" in the build log).

@syphar
Copy link
Member

syphar commented Jan 13, 2022

@Nemo157 could you have a look here?

@Nemo157
Copy link
Member

Nemo157 commented Jan 13, 2022

I think this is caused by #1580 which is afaik still blocked on rust-lang/cargo#10206; the --cfg docsrs is not passed to the build-script-build. After opening that issue I meant to see if I could fix cargo so we could fix this, but haven't had time to.

@syphar
Copy link
Member

syphar commented Aug 2, 2023

@Nemo157 was this solved with the resolved cargo issue?

@Nemo157
Copy link
Member

Nemo157 commented Aug 2, 2023

I think it should have been, I've queued a rebuild and we'll see what happens.

@Nemo157
Copy link
Member

Nemo157 commented Aug 3, 2023

Rebuild succeeded 🎉

@Nemo157 Nemo157 closed this as completed Aug 3, 2023
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

3 participants