Since linking is a huge part of incremental compilation time, would it be possible to instead dynamically link all dependencies and the main crate together?
I'm imagining that it could work like an additional compilation mode, in addition to --debug
and --release
, perhaps --dynamic
.
When compiling in --dynamic
mode, the compiler would generate dynamically loaded libraries for the main crate, as well as all dependencies. Linking would only require doing symbol table stuff, and not processing a bunch of machine code.
When running, the main binary could be a simplified main that would call the main function of the generated library for the main crate.
This could be supported purely as a way to do fast incremental compiles, and there would be no support for doing anything but running the generated main binary and library with cargo run
. (I.e. no way to deploy the collection of libs and main binary together somewhere else.)
It seems to me that this would make incremental compilation very fast.
Would this be a good approach to speeding up incremental compilation?