Re: ccache, MSVC, and meson

From: Justin Pryzby <pryzby(at)telsasoft(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, pgsql-hackers(at)postgresql(dot)org, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, Melanie Plageman <melanieplageman(at)gmail(dot)com>, Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, Daniel Gustafsson <daniel(at)yesql(dot)se>
Subject: Re: ccache, MSVC, and meson
Date: 2022-05-24 19:52:02
Message-ID: 20220524195202.GK19626@telsasoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, May 24, 2022 at 12:30:59PM -0700, Andres Freund wrote:
> Hi,
>
> On 2022-05-22 18:26:06 -0500, Justin Pryzby wrote:
> > forking: <20220307191054(dot)n5enrlf6kdn7zc42(at)alap3(dot)anarazel(dot)de>
> >
> > An update.
> >
> > ccache 4.6.1 was released which allows compiling postgres
> > I submitted a request to update the package in chocolatey.
> >
> > But with the existing build system, it's no faster anyway, I guess due to poor
> > use of parallelism.
> > https://cirrus-ci.com/task/5972008205811712
>
> No, because it never uses caching, because the way we set the output director
> causes ccache to never cache.

I think you're referring to the trailing backslash in the MSVC project file,
meaning "write to a filename under this directory":

src/tools/msvc/MSBuildProject.pm:
<ObjectFileName>.\\$cfgname\\$self->{name}\\</ObjectFileName>

ccache was fixed to handle that in 4.6, and could be worked around before that
by adding "%(Filename).obj".

https://github.com/ccache/ccache/issues/1018

In any case, it really is caching, but without any positive effect:

[17:02:01.555] Hits: 1398 / 1398 (100.0 %)
[17:02:01.555] Direct: 1398 / 1398 (100.0 %)
[17:02:01.555] Preprocessed: 0 / 0
[17:02:01.555] Misses: 0
[17:02:01.555] Direct: 0
[17:02:01.555] Preprocessed: 0
[17:02:01.555] Primary storage:
[17:02:01.555] Hits: 2796 / 2796 (100.0 %)
[17:02:01.555] Misses: 0

> > Currently, meson doesn't (automatically) use ccache with MSVC - see
> > mesonbuild/environment.py.
> >
> > And CC=ccache gives an error - I suppose it should not try to pop ccache off the
> > compiler list if the list has only one element.
> > [...]
>
> > But it can be convinced to use ccache by renaming the executable to "pgccache".
> > Which builds in 46sec: https://cirrus-ci.com/task/4862234995195904
> > This requires ccache 4.6, released in Feburary and already in choco.
> > Note that ccache supports neither /Zi debugging nor precompiled headers.
> > I'm not sure, but -Dc_args=/Z7 may do what's wanted here.
>
> The spurious message should be fixed, of course. I suspect you dont need a
> wrapper, you can just set CC='ccache cl.exe' or similar? Afaics it's not
> meaningful to do 'CC=ccache.exe' alone, because then it'll interpret arguments
> as ccache options, rather than compiler options.

if meson didn't crash CC=ccache.exe might have worked, because I had set
CCACHE_COMPILER.

As I recall, CC='ccache cl.exe' didn't work because it didn't attempt to do any
argument splitting.

The copy of ccache.exe is necessary because otherwise ccache "skips" over any
leading "ccache[.exe]" components while searching for the real compiler.

This is the only way I've gotten it to work (but feel free to comment at:
https://github.com/ccache/ccache/issues/1039)

--
Justin

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Zhihong Yu 2022-05-24 20:17:58 Re: adding status for COPY progress report
Previous Message Matthias van de Meent 2022-05-24 19:37:46 Re: adding status for COPY progress report