grpc-sys: Fix build failure on uncommon linux build targets
Hi owners, I'm Hsin-chen from Google. Recently we stepped into a build failure in our product, below is the failure reason.
After some investigation I believe the culprit is around the config_binding_path function: Our build target is not listed as a supported platform but the bindings are not generated either because our target_os is linux. Eventually we're only able to build with feature = "_gen-bindings".
I've attached a possible fix. Could you please help take a look? Thanks!
floss-9999: error: couldn't read /build/brya/var/cache/portage/net-wireless/floss/cros-rust/x86_64-cros-linux-gnu/release/build/grpcio-sys-947c4c4fa7b189ac/out/grpc-bindings.rs: No such file or directory (os error 2)
floss-9999: --> [REGISTRY]/grpcio-sys-0.13.0+1.56.2-patched/src/lib.rs:8:5
floss-9999: |
floss-9999: 8 | include!(env!("BINDING_PATH"));
floss-9999: | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
floss-9999: |
floss-9999: = note: this error originates in the macro `include` (in Nightly builds, run with -Z macro-backtrace for more info)
floss-9999:
floss-9999: error: could not compile `grpcio-sys` (lib) due to previous error
Can we please finally merge this?
@Eclextic what issue did you meet? Master branch has already changed the target match rules, so I think for uncommon targets, bindings should be generated at compile time already.
I don't see any revalent changes after this PR so I believe the issue is still there. An uncommon linux target would enter neither of the checks below, and as a result there's no bindings.rs file.
In my opinion the two checks must be complement (like what this PR does) to cover all cases. As per #discussion_r1602818903 the first one seems to be preferred, so I guess we shall chage the second one correspondingly.
let file_path: PathBuf = match target.as_str() {
"x86_64-unknown-linux-gnu"
| "x86_64-unknown-linux-musl"
| "aarch64-unknown-linux-musl"
| "aarch64-unknown-linux-gnu"
| "x86_64-apple-darwin"
| "aarch64-apple-darwin" =>
#[cfg(any(
feature = "_gen-bindings",
not(all(
any(target_os = "linux", target_os = "macos"),
any(target_arch = "x86_64", target_arch = "aarch64")
))
))]
@Eclextic what issue did you meet? Master branch has already changed the target match rules, so I think for uncommon targets, bindings should be generated at compile time already.
I mean I am gonna be honest. In hindsight I am kind of unsure if this is related at all, but whenever one cargo cleans and recompiles the project I get a cmake deprecation error on linux. I think this is technically unrelated to this issue and moreover related to #620.
So yeah I am sorry. I'll continue posting there.