Forum > Suggestions

Can we speed up the compiling by using ccache, and if yes, how?

(1/1)

att2:
Hello,
I have just accidentally found out that people use a "ccache" tool to speed up C compiling on a Linux raspi-clone hardware:

http://odroid.us/mediawiki/index.php?title=Speed_Builds_Using_Compiler_Cache

I wonder if we can also speed up FreePascal compiling using similar methods?
Has anyone done this? And if yes, how to install and get this to run?
Any help is greatly appreciated !

marcov:
No, FPC has incremental build and precompiled header system already built in, and thus wouldn't get  the bulk of the savings, if any at all, even in theory.

The ccache tools and philosophy are afaik also specific to a gcc like compiling and preprocessing model (which FPC doesn't as it compiles multiple files in one compiler invocation and doesn't work with headers in the same way)

FPC does have some scaling problems specially in the parallel compilation realm, where only carefully crafted parallel build is possible (as done for e.g. the packages/ tree), which doesn't scale embarrassingly like GCC does.

But to fix that, threading would have to be taken into the compiler which is a gigantic undertaking, specially multi platform. (and even then there would need to some arranging to do for best performance, like working with very large buildunits) and with uncertain overall speed ups.

That said, I've worked with both FPC in a terminal and lazarus on my rpi4/4GB, and for not too gigantic projects that worked fine. Even a FPC bootstrap would only take 4-8 minutes iirc.  Worthwhile to go for a coffee, but not THAT bad.

I assume a RPI5/8GB would even be better experience. (better storage speed is maybe even more important than better processor. And even more so on Windows. Both storage speed and  RAM are very important if you want to run Windows)

marcov:
(I quickly benchmarked), not the most optimized build did 10m38s on a RPI4/4GB running bookworm.

I don't know how long it would take to compile GCC on it, even with ccache.

Bogen85:

--- Quote from: att2 on October 25, 2023, 09:50:06 am ---I have just accidentally found out that people use a "ccache" tool to speed up C compiling on a Linux raspi-clone hardware:
...
I wonder if we can also speed up FreePascal compiling using similar methods?

--- End quote ---

In general, large C and C++ projects have to compile the same header files many times for just a single build. So, from one standpoint, the C/C++ compiler have to work harder and not smarter.

Free Pascal on the other hand only has to compile the equivalent "interface" header files once for a single build. So, the opposite, work smarter, not harder.

CCache provides a compromise for the work hard not smart approach and attempts to act as middleman to allow for reuse of what was already compiled, so the same header files don't need to be repeatably recompiled.

If C/C++ compilers worked smart rather than hard, then CCache would not be needed. Newer C++ compilers support modules that could in theory allow the compiler to work smart, not hard. But in practice I've not seen that actually play out, and it may take a while for toolchains and build tools to support C++ modules, and that would only benifit new projects, older projects would still be able to benefit from tools like CCache.

Navigation

[0] Message Index

Go to full version