On Tue, May 24, 2022 at 01:30:39PM -0700, Andres Freund wrote:
> On 2022-05-24 14:52:02 -0500, Justin Pryzby wrote:
> > > 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.
> 
> Did you report the issue? Should be simple enough to fix.
> 
> I seriously doubt it's a good idea to use CCACHE_COMPILER - there's no way
> meson (or autoconf or ..) can rely on the results of compiler tests that way,
> since CCACHE_COMPILER can change at any time.

This updated patch doesn't use CCACHE_COMPILER.

cache misses are several times slower (12 minute build time vs 2:30 with ninja,
without ccache), so it's possible that can be *slower* if the hit ratio is
inadequate.  ninja on cirrus builds 3x faster with ccache, but msbuild is only
~2x faster, so I recommend using it only with ninja.

There's still warts requires using "plain" with /Z7 /MDd.
>From 1c3823095eb9300fd0aae1fb569a3cc09b1346cc Mon Sep 17 00:00:00 2001
From: Justin Pryzby <pryz...@telsasoft.com>
Date: Sun, 22 May 2022 11:55:02 -0500
Subject: [PATCH] cirrus/windows: ccache

https://community.chocolatey.org/packages/ccache

https://www.postgresql.org/message-id/flat/20220522232606.GZ19626%40telsasoft.com
20220321001747.5o2zfoeqxvbjm...@alap3.anarazel.de
20211012083721.hvixq4pnh2pixr3j%40alap3.anarazel.de
CA%2BhUKGLs6ENKL4w1o%2B1RpcS4VLyLXSUMWRYJVaiLBOJtarW25g%40mail.gmail.com

https://cirrus-ci.com/task/5456827583299584
https://cirrus-ci.com/task/6019777536720896

ci-os-only: xindows, windows-meson-ninja, xindows-meson-msbuild
---
 .cirrus.yml | 34 +++++++++++++++++++++++++++-------
 1 file changed, 27 insertions(+), 7 deletions(-)

diff --git a/.cirrus.yml b/.cirrus.yml
index bf20f85f8ce..ed9e86557d7 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -814,6 +814,9 @@ windows_template: &windows_template
     # currently have a tool for that...
     CIRRUS_ESCAPING_PROCESSES: 1
 
+    CCACHE_DIR: $CIRRUS_WORKING_DIR/.ccache
+    CCACHE_LOGFILE: ccache.log
+
   only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*windows.*'
 
   windows_container:
@@ -828,12 +831,14 @@ windows_template: &windows_template
     set
 
   setup_additional_packages_script: |
-    REM choco install -y --no-progress ...
-
+    choco install -y --no-progress ccache --version 4.6.1
+    cp c:\ProgramData\chocolatey\lib\ccache\tools\ccache-4.6.1-windows-x86_64\ccache.exe \BuildTools\VC\Auxiliary\Build
+    cp c:\ProgramData\chocolatey\lib\ccache\tools\ccache-4.6.1-windows-x86_64\ccache.exe \ProgramData\chocolatey\bin\cl.exe
 
 task:
   <<: *windows_template
   name: Windows - Server 2019, VS 2019 - Homegrown
+  only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*windows-mkvcbuild'
 
   configure_script:
     # copy errors out when using forward slashes
@@ -901,14 +906,22 @@ task:
     - mkdir subprojects
     - meson wrap install lz4
     - meson wrap install zlib
-    - meson setup --buildtype debug --backend ninja  -Dcassert=true -Db_pch=true -Dssl=openssl -Dlz4=enabled -Dzlib=enabled -Dextra_lib_dirs=c:\openssl\1.1\lib -Dextra_include_dirs=c:\openssl\1.1\include -DTAR=c:/windows/system32/tar.exe build
+    - set CC=ccache.exe cl.exe
+    - meson setup --buildtype plain --backend ninja  -Dcassert=true -Db_pch=false -Dssl=openssl -Dlz4=enabled -Dzlib=enabled -Dextra_lib_dirs=c:\openssl\1.1\lib -Dextra_include_dirs=c:\openssl\1.1\include -DTAR=c:/windows/system32/tar.exe -Dc_args="/Z7 /MDd" build
+
+  ccache_cache:
+    folder: $CCACHE_DIR
 
   build_script:
+    - ccache.exe --zero-stats
     - vcvarsall x64
     - ninja -C build
+    - ccache.exe --show-stats
+
+  always:
+    upload_caches: ccache
 
   check_world_script:
-    - vcvarsall x64
     - meson test --no-rebuild -C build
 
   on_failure:
@@ -934,14 +947,21 @@ task:
     - mkdir subprojects
     - meson wrap install lz4
     - meson wrap install zlib
-    - meson setup --buildtype debug --backend vs -Dcassert=true -Db_pch=true -Dssl=openssl -Dlz4=enabled -Dzlib=enabled -Dextra_lib_dirs=c:\openssl\1.1\lib -Dextra_include_dirs=c:\openssl\1.1\include -DTAR=c:/windows/system32/tar.exe build
+    - meson setup --buildtype plain --backend vs -Dcassert=true -Db_pch=false -Dssl=openssl -Dlz4=enabled -Dzlib=enabled -Dextra_lib_dirs=c:\openssl\1.1\lib -Dextra_include_dirs=c:\openssl\1.1\include -DTAR=c:/windows/system32/tar.exe -Dc_args=/Z7 build
+
+  ccache_cache:
+    folder: $CCACHE_DIR
 
   build_script:
+    - ccache.exe --zero-stats
     - vcvarsall x64
-    - msbuild /p:UseMultiToolTask=true %MSBFLAGS% build\postgresql.sln
+    - msbuild /p:UseMultiToolTask=true /p:CLToolPath=c:\ProgramData\chocolatey\bin %MSBFLAGS% build\postgresql.sln
+    - ccache.exe --show-stats
+
+  always:
+    upload_caches: ccache
 
   check_world_script:
-    - vcvarsall x64
     - meson test --no-rebuild -C build
 
   always:
-- 
2.17.1

Reply via email to