google / shaderc-rs

Rust bindings for the shaderc library.
https://docs.rs/shaderc
Apache License 2.0
261 stars 64 forks source link

Crates that use shaderc at build time fail to build on docs.rs #144

Closed marc0246 closed 9 months ago

marc0246 commented 9 months ago

130 made shaderc unable to build on docs.rs at all. That's fine for building the crate itself, and crates depending on it, however some crates use shaderc at build time. See rust-lang/docs.rs#2329 for the issues this causes and the affected crates.

antiagainst commented 9 months ago

Oops sorry about it! I don't know what's the best way to handle this; maybe add another environment variable like SHADERC_DOC_BUILD_FORCE_LINK and use that in vulkano-shaders or a feature similar to that?

marc0246 commented 9 months ago

It's an understandable oversight.

I hope no one takes this the wrong way, as I don't mean to offend, but to me #130 seems like either a solution to a problem that didn't exist in the first place or the wrong solution. So my solution would be to revert #130 and solve whatever issue @chyyran was actually having. Maybe I'm missing something, and some change before #130 broke cross-compilation on docs.rs or something, however if you look at the reverse dependencies of shaderc you will see that the crates have been building just fine (including cross-compilation) before. Usually the first place to look when there's a docs.rs build failure is the package metadata, so maybe removing the package.metadata.docs.rs.targets field from @chyyran's crate will help. Or maybe @chyyran has some insight as to why their crate fails to build unlike all the others.

In any case, I maintain that penalizing all the other crates is insanity. Worst case scenario would be to simply not cross-compile on docs.rs.

marc0246 commented 9 months ago

After further inspection it appears that cross-compilation hasn't worked for any crate, exept ones that use shaderc only at build time or as an optional dependency, so I was wrong on that. Makes sense. I wish I knew how to solve this without resorting to unclean solutions. Would it even be possible to cross-compile shaderc?

chyyran commented 9 months ago

fwiw, #130 fixes docs.rs builds for x86_64-pc-windows-msvc. Versions prior simply could not build docs for this target and others at all if it depended on shaderc, this is clear if you look at docs for shaderc before 0.8.2. This is understandably an issue for libraries that are Windows-focused: providing only Linux docs means my users won't be able to see docs regarding Direct3D integration.

marc0246 commented 9 months ago

Makes sense, I made a patchwork PR trying to make it work in build scripts and proc-macros.