Using ccache and jom to speed up Windows builds

Hossein Nourikhah hossein at
Mon May 22 01:07:52 UTC 2023


With the effort from Luboš Luňák in 2021, building LibreOffice master 
with ccache/VS on Windows became possible. But, as discussed in 2021, 
and also a few days ago, the conclusion was that it is not helpful. The 
recommendation in the TDF Wiki is also not to use ccache:

2021 discussion:
FYI: ccache for MSVC/Windows

Building LibreOffice on Windows with Cygwin and MSVC: Tips and Tricks

Last week, I tried to build again, and this time not using binaries of 
the patched ccache for Cygwin, but with the official Windows binaries. 
The binary of the patched Cygwin ccache was no longer working with the 
latest Cygwin, and I was expecting that the latest binaries should 
contain the patches from Luboš.
In addition, I expected that the Windows binary built with MSVC can 
possibly perform better, because it is a single binary without reliance 
on Cygwin, and without its overhead.

I downloaded ccache from the below link, and put the ccache.exe in 
Cygwin binary folder:

cccache 4.8.1 (4.7.5 also work)
Windows x86_64 binary release

I also downloaded jom from the below link, and also put it in the Cygwin 
binary folder. As you may know, it is a parallel drop-in replacement for 

jom 1.1.3

A small change (adding missing double quotes) is needed to compile 
OpenSSL, as it gives error with ccache. This change does not build the 
rest of LibreOffice, so a fix is needed. But, the quick and dirty change 
works to show the performance difference:

diff --git a/external/openssl/ 
index e44ccf5f3436..dcb49c8d2dc4 100644
--- a/external/openssl/
+++ b/external/openssl/
@@ -65,7 +65,7 @@ $(call 
         $(call gb_ExternalProject_run,build,\
                 CONFIGURE_INSIST=1 $(PERL) Configure $(OPENSSL_PLATFORM) 
no-tests no-multilib \
                 && export PERL="$(shell cygpath -w $(PERL))" \
-               && nmake -f makefile \
+               && jom -f makefile \
                         $(if $(call 
         $(call gb_Trace_EndRange,openssl,EXTERNAL)
diff --git a/solenv/gbuild/platform/ 
index ba42b0ba48df..69f5b00b56c5 100644
--- a/solenv/gbuild/platform/
+++ b/solenv/gbuild/platform/
@@ -665,7 +665,7 @@ gb_ExternalProject_INCLUDE := \
         $(subst -I,,$(subst $(WHITESPACE),;,$(SOLARINC)))

  gb_NMAKE_VARS = \
-       CC="$(shell cygpath -w $(filter-out -%,$(CC))) $(filter 
-%,$(CC))" \
+       CC="ccache\" \"$(shell cygpath -w $(lastword $(filter-out 
-%,$(CC))))" \
         INCLUDE="$(gb_ExternalProject_INCLUDE)" \
         LIB="$(ILIB)" \
         MAKEFLAGS= \

I build with this configuration:


Without ccache, my build finishes in 30 minutes:

$ make
real    30m8.900s
user    0m0.109s
sys     0m0.078s

To give an overview on build performance difference, I've compared the 
time needed to build OpenSSL:

openssl, jom, ccache (warm)
real    0m27.745s
user    0m0.000s
sys     0m0.000s

openssl, nmake, ccache (warm)
real    1m33.791s
user    0m0.000s
sys     0m0.015s

openssl: jom, no ccache
real    2m1.111s
user    0m0.000s
sys     0m0.000s

openssl: nmake, no ccache
real    8m4.923s
user    0m0.000s
sys     0m0.015s

Without ccache, the rest of build (excluding OpenSSL) takes ~25 minutes, 
and this will lead to the ~30 minutes time needed to do a full re-build 
after 'make clean'.

real    24m40.578s
user    0m0.156s
sys     0m0.109s

On the other hand, full rebuild (make) with jom for OpenSSL and ccache 
(warm) finishes in 18 minutes, and that is a considerable improvement!

real    17m57.119s
user    0m0.015s
sys     0m0.031s

Please note that with ccache, the build sleeps for a while while showing 
sd, and several MSBuild.exe processes active in the background. The 
build finishes anyway, and the built LibreOffice is usable. Fixing the 
problem there may save a few more minutes:

[build MOD] sc

There may be possible drawbacks. As OpenSSL in not always built and 
tested with jom instead of nmake, there is a chance that it may fail 
with some future changes. But anyway, it is a a good optimization.

I think it worth trying ccache + jom on Windows CI. Also, using jom in 
every external library that is built with nmake can provide more 
performance improvement. One can take a look into:

$ git grep nmake "external/*/*.mk"


Hossein Nourikhah, Ph.D., Developer Community Architect
Tel: +49 30 5557992-65 | Email: hossein at
The Document Foundation, Winterfeldtstraße 52, 10781 Berlin, DE
Gemeinnützige rechtsfähige Stiftung des bürgerlichen Rechts
Legal details:

More information about the LibreOffice mailing list