gdal
gdal copied to clipboard
docs.rs failing to compile dependent crate
Hello everyone. I hope you are having a good start to the year.
I'm having problems compiling the docs for my crate (map-engine) probably because docs.rs' build system doesn't have GDAL installed.
I saw that you guys have a custom build script that mentions a similar (?) problem. I was hoping that docs.rs would execute that and that everything would work :smile:
I also noticed that many of the crates that depend on gdal (not as a development dependency) have the same problem.
Do you have any recommendations on how to deal with this?
For future reference, I also created an issue on their repo: https://github.com/rust-lang/docs.rs/issues/1591
Thanks
Looks like we're taking this branch in the gdal
(not gdal-sys
) build script.
We'll probably get a linker error if we look at DOCS_RS
instead. Maybe we should remove the version check?
@spadarian can you add
[package.metadata.docs.rs]
rustdoc-args = ["--cfg", "docsrs"]
to your manifest?
I will give that a try tomorrow.
Is there a way of checking if that works locally? I guess I can use their docker container...
Just to confirm... not rustc-args = ["--cfg", "docsrs"]
like you have in your Cargo.toml?
I also have the same problem in rasters
crate. I have included the [package.metadata.docs.rs]
section, but the build still errors out.
The previous version of the crate (which used gdal 0.7.2) did build successfully: https://docs.rs/crate/rasters/0.6.2 . Upgrading to latest, broke docs. For reference, snippet from the build-logs:
env/linux@sha256:a429bb59b7a3b4e7270a4b4c243bb115fc561d8f62ec34ef63a0a36cabf65dfd" "/opt/rustwide/cargo-home/bin/cargo" "+nightly" "rustdoc" "--lib" "-Zrustdoc-map" "--all-features" "-Z" "unstable-options" "--config" "build.rustflags=[\"--cfg\", \"docsrs\"]" "--config" "build.rustdocflags=[\"-Z\", \"unstable-options\", \"--emit=invocation-specific\", \"--resource-suffix\", \"-20220106-1.59.0-nightly-cfa4ac66c\", \"--static-root-path\", \"/\", \"--cap-lints\", \"warn\", \"--disable-per-crate-search\"]" "-Zunstable-options" "--config=doc.extern-map.registries.crates-io=\"https://docs.rs/{pkg_name}/{version}/x86_64-unknown-linux-gnu\"" "-j3" "--target" "x86_64-unknown-linux-gnu", kill_on_drop: false }`
....... removed irrelevant lines from the log .......
[INFO] [stderr] = note: /usr/bin/ld: /opt/rustwide/target/debug/build/gdal-4a35e4eaea3e24c0/build_script_build-4a35e4eaea3e24c0.build_script_build.636fb01f-cgu.3.rcgu.o: in function `build_script_build::gdal_version_info':
[INFO] [stderr] /opt/rustwide/cargo-home/registry/src/github.com-1ecc6299db9ec823/gdal-0.11.0/build.rs:13: undefined reference to `GDALVersionInfo'
[INFO] [stderr] collect2: error: ld returned 1 exit status
The section above the ........
in the snippet shows that --cfg docsrs
is indeed being passed to rustflags, but it still seems to be picking the wrong flavour of the function in gdal/build.rs
.
EDIT: add details on docs build failure
I seem to have added rustc-args = [...]
, which worked in previous versions of the rasters
crate (that uses gdal 0.7.2).
However, I tried locally (as explained using docs.rs github) using rustdoc-args = [...]
and it still fails.
Intersetingly, even the previous version that did build successfully on docs.rs now fails when tried locally. It suggests that this may be a bug in the docs.rs build process.
Apparently, the guys from docs.rs have reported a bug in cargo, which is still blocked on https://github.com/rust-lang/cargo/issues/10206
The cargo issue above seems to be fixed now; should it work now?
I tried locally and it still fails...
i think we had that issue before... maybe docs.rs needs some time to update
The cargo issue is fixed but docs.rs may also need to fix things (ref. https://github.com/rust-lang/docs.rs/issues/1580 , https://github.com/rust-lang/docs.rs/issues/1591).
Builds are still failing (https://docs.rs/crate/geozero/0.9.5-beta1/builds/597082)
I noticed this fix in proc-macro2
crate that has a similar problem. Would it work for us?
https://github.com/dtolnay/proc-macro2/pull/310/files
It wouldn't work. The compiler would try to compile both branches of the if statement (checking for DOCS_RS
), failing to find gdal_sys::GDALVersionInfo
.
@spadarian @pka can you check your gdal-dependent crates and verify the docs do build? I checked rasters.rs locally and it builds; it doesn't even seem to need the rustc-args
configuration anymore.
docs.rs build for geozero is working again, thanks!
It works locally for my crate as well. I also removed the rustc-args
configuration.
Thanks for solving it!
On Mon, 5 Sept 2022 at 06:01, Pirmin Kalberer @.***> wrote:
docs.rs build for geozero is working again, thanks!
— Reply to this email directly, view it on GitHub https://github.com/georust/gdal/issues/240#issuecomment-1236405691, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACXIKSZD525LQHGGZLCMOTV4T5YNANCNFSM5LYAQBNA . You are receiving this because you were mentioned.Message ID: @.***>
Great! Closing this as completed.