[fpc-pascal] Compilation speed on Apple M1
jonas at freepascal.org
Sat Nov 21 17:18:11 CET 2020
On 21/11/2020 14:15, Florian Klämpfl via fpc-pascal wrote:
> Am 21.11.2020 um 12:54 schrieb Tobias Giesen via fpc-pascal:
>> According to Geekbench, the single core performance on the new Mac is
>> around 1.8x as fast as my Intel Mac. Multicore is also much faster. I
>> wonder why I don't see the speed increase in compiling though. Yes I am
>> using different FPC and XCode versions, but I wonder what else could
>> have an influence? My project is very large and not divided into
>> packages, so I frequently need to recompile the whole project.
> Large parts of FPC are memory throughput limited so I suspect the M1 is
> not that much better in this regard, not to mention that most likely the
> AAarch code generator is worse than the x86 one. x86 received a lot of
> work in this field.
> Maybe it's possible that you build using an LLVM compiler the FPC with
> native backend. As I do not use macOS, I have no clue how to do this
For compiling the compiler itself, excluding assembling and linking, a
compiler compiled using the LLVM backend (but that generates code using
our native code generator (*) ) is 18.85% faster than one compiled using
our native code generator (on a Developer Transition Kit, but I guess it
will be similar on the M1).
If you include assembling and linking (which you obviously always have
to do), the speed difference shrinks to 8.5%. So more time is spent in
the assembler (clang) and ld than in the compiler.
As to how to do build a compiler on macOS that uses the LLVM backend,
that's the same as on Linux, except that you don't need special command
line options to find libgcc: https://wiki.freepascal.org/LLVM
(*) using the LLVM backend is slower because clang's code generator is
much slower than FPC's.
More information about the fpc-pascal