Slow ld during doctests

There were some nice improvements in compilation speed. But all that seems to be the speed of rustc generating object files.

Now, I have a project with a lot of dependencies. The dependencies don't get recompiled on each change, so that is not really a problem during compilation. But the linking takes a long time.

This is especially annoying during doctests, because each one is a separate program that links everything in. Furthermore, they seem to recompile and relink every time they are run even if no code at all changed.

Did anyone know of some tricks or tweaks that could make linking faster?

If that matters, I'm on Linux, using mostly current nightly (usually not more than few days behind).

You can try using the gold linker, which should be faster: RUSTFLAGS="-Clink-arg=-fuse-ld=gold"

Thanks for the tip, but unfortunately this didn't seem to help :-(. Maybe my system already uses gold by default or something maybe it's not that faster to be visible.

Does removing debug info help? In my case on macOS sometimes writing of the debug info files takes lion share of the time.

Yes, that seems to have helped a bit (25% of the cargo test --all run when no files changed). Thank you :slight_smile: