Using the mold linker for fun and 3x-8x link time speedups
productive-cpp.com
productive-cpp.com
> As we aim to the 1-second goal for Chromium, every millisecond counts. We can't ignore the latency of process exit. If we mmap a lot of files, _exit(2) is not instantaneous but takes a few hundred milliseconds because the kernel has to clean up a lot of resources. As a workaround, we should organize the linker command as two processes; the first process forks the second process, and the second process does the actual work. As soon as the second process writes a result file to a filesystem, it notifies the first process, and the first process exits. The second process can take time to exit, because it is not an interactive process.
Never heard about this trick before, but it's the rare combination of "genius" and "obvious in retrospect".
[1]: https://github.com/rui314/mold/blob/main/docs/design.md
I wish blender folks would try to switch to mold, linking Blender is the singler biggest bottleneck to dev speed when writing Blender code.
(I tend to prefix PATH with the folder I build it into for the specific project I need it for)
But off the top - No lto support, missing some flags that we use when building drivers, valgrind (cachegrind etc) fail to load symbols, some linker stuff is case senstive etc.
Can also add it to PATH, instead of hardcoding it like op did here.
But it's well worth it in some projects - In my case it shaved over a minute from incremental builds, resulting in sub 10 second builds!
(Alsp note you can cache indexes in gdb by default)
https://github.com/blender/blender/commit/8b3d798374a2c6b502...
What the fresh hell is this, giving him more money. You should be contributing to Zig or serenityOS
https://clojure.org/reference/compilation
(also see the eval definition at https://github.com/clojure/clojure/blob/master/src/clj/cloju... - it calls into the compiler).
The JVM could still just interpret the JVM bytecode instead of JIT compiling first of course.
Python is also technically compiled like this
The important thing is to have people using both so you make sure the jit path can be dumb enough to be fast.
mkdir -p .cargo
cat > .cargo/config.toml <<EOF
[target.x86_64-unknown-linux-gnu]
linker = "/usr/bin/clang"
rustflags = ["-Clink-arg=-fuse-ld=/usr/bin/mold"]
EOF
(the above assumes a Linux target, and that the binaries are under `/usr/bin`)It's certainly true that the default linker is sloooooooow; I wonder which are the challenges in making mold/lld the default.
I would guess that mold doesn't have the necessary support for the second step, running the compiler again on the IL during linking.
It does have support for linker plugins now (I was following the github issue somewhat), I just wasn't sure whether I shouldn't bother testing it to see if I can use it without performance regressions because I didn't understand how it works.
Might give it a shot one of these days.
Dozens of companies use them. Google has an extremely demanding linking environment and developed and used Gold for a long time for it’s primary linker. It has since moved on to LLD. It is unlikely to adopt mold at the moment due to licensing issues.
All the compatibility issues were solved a long time ago with LLD and Gold. Probably only a matter of time for Mold.
The more obscure the target OS and architecture, the more likely gnu ld is the only linker capable of doing the job. But most users won’t notice. Gnu ld has the best linker script support by a wide margin too, so if you are doing really really wacky things with your layout where you need 100% total control, you have to use gnu ld also.
But those are obscure edge cases these days, and very uncommon in normal practice.