Sharing compiled libraries across cargo builds


#1

Hello,

i was looking today at a release build taking 100% of my cores, and noted some of the crates being built were actually the same.

Does cargo have a way to store the binaries build from external crates, so that they aren’t build every single time a project on the same computer needs them?

If not, is this eventually planned?

Thanks in advance


#2

Different projects may have different codegen options, etc. As such, the source is stored globally, but the output is stored per-project.

But, it seems like you’re talking about within a project, not across different projects? Can you show the output you were talking about?


#3

It was briefly brought up by @eddyb on this thread:


#4

Different projects may have different codegen options, etc. As such, the source is stored globally, but the output is stored per-project.

Well, I can do this in C++.

For example, the last company I actually did heavy use of C++, we were using Clearcase builds on HP-UX, which shared .o and .a files across all projects.

So I would do clearmake clean all at the repository root and be assured each shared .o and .a files would be built exactly once.

Hence why I was starring at the way cargo works, just with source dependencies, and wondering about the time wasted compiling common dependencies.