Add mold preloading support
mold is a new linker, replacing ld, gold, or lld and it is amazingly fast. From their issue tracker, there is a feature request (#74) that actually belongs here:
mold supports object file preloading feature. In order to use it, someone has to run a linker command with
--preload
flag a few seconds prior to the actual linker invocation. And I think "someone" should be a build system, such as make or ninja executing CMake-generated ninja or Makefiles.As a starter, I think we should add the following feature to CMake:
- Detect if a linker is mold
- run a linker command with
--preload
if it is mold before invoking compiler instances to generate object files