profile
viewpoint

Ask questionsgrpcio-sys recompiling every build on non-linux platforms

Description

When compiling (using cargo) for targets that aren't either x86_64-unknown-linux-gnu or aarch64-unknown-linux-gnu, cargo determines that grpcio-sys needs to be recompiled regardless of whether anything has changed.

This is happening because of this line in grpcio-sys/build.rs:

println!("cargo:rerun-if-changed=bindings/{}-bindings.rs", &target);

which was introduced in this commit. There is only a -bindings.rs file for the 2 targets mentioned above. Cargo will always rerun when it encounters a missing file specified by a cargo:rerun-if-changed directive. See this comment for reference.

To Reproduce

This can be reproduced by compiling any package that depends on grpcio-sys (I'm using 0.5.0). For detailed log information, set the CARGO_LOG environment variable to cargo::core::compiler::fingerprint=info:

CARGO_LOG=cargo::core::compiler::fingerprint=info cargo build

The output will be something similar to:

[2020-03-25T02:33:41Z INFO  cargo::core::compiler::fingerprint] stale: missing "/Users/kyle/.cargo/registry/src/github.com-1ecc6299db9ec823/grpcio-sys-0.5.0/bindings/x86_64-apple-darwin-bindings.rs"
[2020-03-25T02:33:41Z INFO  cargo::core::compiler::fingerprint] fingerprint error for grpcio v0.5.0/Build/Target { ..: lib_target("grpcio", ["lib"], "/Users/kyle/.cargo/registry/src/github.com-1ecc6299db9ec823/grpcio-0.5.0/src/lib.rs", Edition2018) }
[2020-03-25T02:33:41Z INFO  cargo::core::compiler::fingerprint]     err: current filesystem status shows we're outdated
[2020-03-25T02:33:41Z INFO  cargo::core::compiler::fingerprint] fingerprint error for grpcio-sys v0.5.0/Build/Target { ..: lib_target("grpcio-sys", ["lib"], "/Users/kyle/.cargo/registry/src/github.com-1ecc6299db9ec823/grpcio-sys-0.5.0/src/lib.rs", Edition2018) }
[2020-03-25T02:33:41Z INFO  cargo::core::compiler::fingerprint]     err: current filesystem status shows we're outdated
[2020-03-25T02:33:41Z INFO  cargo::core::compiler::fingerprint] fingerprint error for grpcio-sys v0.5.0/RunCustomBuild/Target { ..: custom_build_target("build-script-build", "/Users/kyle/.cargo/registry/src/github.com-1ecc6299db9ec823/grpcio-sys-0.5.0/build.rs", Edition2018) }
[2020-03-25T02:33:41Z INFO  cargo::core::compiler::fingerprint]     err: current filesystem status shows we're outdated
   Compiling grpcio-sys v0.5.0
   Compiling grpcio v0.5.0

System information

  • CPU architecture: x86_64
  • Distribution and kernel version: Darwin 19.3.0
  • SELinux on?: No
tikv/grpc-rs

Answer questions BusyJay

@eranrund Can you share your Cargo.toml? I suspect that's because 0.5.1 updates bindgen, which may be conflict with your existing dependency and prevents cargo to use an updated version. It's probably related to https://github.com/rust-lang/cargo/issues/5237.

useful!

Related questions

No questions were found.
Github User Rank List