I was playing with Rust when I encountered a bug inside a cargo projects source code, I changed the code to fix the bug and recompiled the project but it was still using the old code which made me think.
Is Rust compiling the source code of a cargo package on my machine or does the result come from the cloud? If it is compiled on my machine is it only done once? Where are the results? If they are compiled in the Cloud how does that maintain compatibility between versions (of Rust) if the binary is static? Or are is there a binary for each Rust version?
Cargo only compiles code on the local machine- there is no built-in support for downloading pre-built Rust binaries from the Internet. You can find the source code of dependencies you have used in ~/.cargo/registry/src (Linux path). Cargo places all of the generated binary files in your project's target directory; It doesn't even reuse dependencies compiled on the local machine.
However, by installing and using sccache, you actually can share dependency binaries either between local projects and the cloud.
For your particular case of editing a dependency locally, you want to use the technique of Overriding Dependencies to patch the source code locally. Cargo doesn't check for changes when the code is edited in-cache, and thus you won't see anything change from in-place patches.
Finally, the per-crate .rlib files Cargo generates in target/debug/deps are equivalent to C object files- they need to all be linked together to produce a valid executable or library. The ABI between them is dependent on the Rust version, which is why switching toolchains will cause them all to be rebuilt.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With