Description
A "static rust library" is simply just an 'rlib' file, which in turns is just an ar
archive. Right now the archive includes the crate.o
and all native static dependencies. There's no reason that this file couldn't also include crate.bc
to allow for LTO.
I would imagine that a --lto
option would be specified when creating an executable and for when creating a dynamic library (I don't think this makes sense for static libraries?). When --lto
is specified, then we don't load the bc
files from all of the upstream rlib
archives and throw it all into LLVM, then we tell LLVM to run its LTO passes.
Basically this would mean perhaps shoving more things into rlib
archives by default (need to make sure that using rlib files still works), and then implementing the --lto
option to load the bc
files from archives.
Note that native libraries should all still "just work" to the greatest extent possible.
Not quite an easy bug, but certainly an interesting project!