Feature Request: Native support for mold linker
Description:
Summary
Requesting native support or a dedicated switch (e.g., -fuse-mold) to utilize the mold linker, similar to how GCC and Clang allow -fuse-ld=mold.
Context & Motivation
The mold linker is a modern drop-in replacement for GNU ld and gold that offers significantly faster linking speeds (often 3x-10x faster on large projects). For large Lazarus/FPC projects, the linking stage is currently a major bottleneck in the "Code -> Compile -> Test" loop.
Current Workaround
Currently, users must manually override the linker path using the -FD switch (e.g., fpc -FD/usr/bin/mold ...). While this works because mold accepts standard ld arguments, it requires absolute paths and manual configuration per project/environment.
Proposed Solution
-
Dedicated Switch: Introduce a switch (e.g.,
-use-moldor extend-koptions) that instructs the compiler to look formoldin the standard path without requiring absolute paths. -
Detection: If possible, allow FPC to detect if
moldis available and prioritized, or provide a cleaner configuration option infpc.cfg.
Benefits
- Performance: Drastically reduces link times for large binaries (Lazarus IDE, games, large server apps).
-
Modernization: Aligns FPC with modern C++ toolchains (Rust, Clang) that are adopting
moldfor improved developer experience.
Environment
-
OS: Linux / Unix-like systems (primary target for
mold). - Architecture: x86_64 (primary), AArch64.