Proposal: Add "cargo:rustc-compile-crate-without-waiting-for-build-rs" for build.rs

I have the feeling that build scripts do two different things: a) Compile and link libraries. b) Generate Rust code

While build scripts serve the secound application quite well, they have many shortcomings for the first one in particular:

i) Build scripts are compiled and executed, even in check mode.

ii) Build scripts poorly interact with each other or with external build systems of any kind.

iii) They often requiere options that need to be bubbled up through their users. (E.g. dynamic vs static linkage).

Rather them just introducing this flag, it would probably be usefull to introduce a more general way to indicate that something is used to provide some external dependency. My personal suggestion would be a different cargo-packge type (possibly embeddable into an other package) declaring what dependency and version it does provide and what linkage options (static, dynamic, etc), are supported. External dependencies could then be listed (usefull for something like cargo-deb), build in parallel to other code without ever becoming part of any .rlib and being linked into the final executable/dylib using explicit link flags set by cargo, configured globally, being replaced by a version build by an external build system, etc.

Edit: See also:

2 Likes