Hi, On 2026-07-07 13:35:34 -0400, Andres Freund wrote: > On 2026-07-06 09:52:19 +0200, Peter Eisentraut wrote: > > On 03.07.26 16:26, Nazir Bilal Yavuz wrote: > > > Hi, > > > > > > When the Postgres major version is updated, CI fails with [1]: > > > > > > 2026-07-02 17:01:01.938 UTC [828] FATAL: incompatible library > > > "D:/a/postgresql/postgresql/build/tmp_install/usr/local/pgsql/lib/utf8_and_win.dll": > > > version mismatch > > > 2026-07-02 17:01:01.938 UTC [828] DETAIL: Server is version 20, > > > library is version 19. > > > > > > This happens because the GitHub Actions ccache is restored across a > > > version bump, so objects built against the previous version can be > > > reused, producing libraries that no longer match the server version. > > > > > > Here is an attempt to solve this problem by namespacing ccache by > > > Postgres major version. I added a 'PG_MAJOR_VERSION' variable to the > > > CI file and used that as a prefix to ccache key. I made this > > > 'PG_MAJOR_VERSION' variable automatically updated by > > > 'version_stamp.pl' script. > > > > > > Another solution could be reading the version from build files (e.g > > > meson.build), but then this read needs to be done at each CI run. > > > > I'm suspicious about this direction. The major version is not the only > > piece of data that determines ABI compatibility between the server and > > extensions. This would only be a partial information. The ABI information > > exists in the code, and so changes should be visible to ccache. Maybe we > > are using ccache in the wrong mode or something (see "depend mode", "direct > > mode", etc.). > > Yea, I don't think that's the right answer. I'm reasonably sure I debugged > this issue a while ago: > > https://postgr.es/m/phsrssp75npoyalqsolcd7fmnmlbzbmquc2p7w7mqjlw7432jk%40bzskz3luyjvb > > Not a lot has happened on the ccache front, so I suspect we should start > adding the -fpch-deps flag I mentioned in that thread. > > We could make adding -fpch-deps conditional on pch support being enabled, but > given that it doesn't do anything when pch is not used, I'd just add it when > supported by the compiler.
Attached is the change I propose. Greetings, Andres
>From 77df912a3172bbd3ea672708469d02ca938f79ee Mon Sep 17 00:00:00 2001 From: Andres Freund <[email protected]> Date: Wed, 15 Jul 2026 15:27:16 -0400 Subject: [PATCH v2] meson: Fix ccache issues when using precompiled headers with gcc Unfortunately the combination of gcc, precompiled headers, ccache and meson currently is not safe without further options. The dependencies emitted by gcc are insufficient to trigger rebuilds when headers "below" the precompiled headers are changed. Whether that's a ccache, gcc or meson bug is debatable. Luckily gcc's -fpch-deps option fixes the issue. This problem occasionally leads to build failures, e.g. if only c.h, postgres.h or pg_config_manual.h change. That's e.g. the case when creating a new major version branch. Discussion: https://postgr.es/m/CAN55FZ0tqR6Xz%3DiVFLc1BBoLOEHU775ARhcGYwggHA3XLA%3DoQg%40mail.gmail.com Discussion: https://postgr.es/m/ca+hukg+s7yvt0punsquejcjysv-7-51n9b1h468le3vji0x...@mail.gmail.com Discussion: https://postgr.es/m/phsrssp75npoyalqsolcd7fmnmlbzbmquc2p7w7mqjlw7432jk@bzskz3luyjvb Discussion: https://github.com/ccache/ccache/issues/1686 Backpatch-through: 16, where meson support was added --- meson.build | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/meson.build b/meson.build index 61b5681851e..f4cde249242 100644 --- a/meson.build +++ b/meson.build @@ -2185,6 +2185,12 @@ common_functional_flags = [ # Disable optimizations that assume no overflow; needed for gcc 4.3+ '-fwrapv', '-fexcess-precision=standard', + # Without -fpch-deps gcc emits dependencies that are insufficient for ccache + # to trigger a rebuild when the precompiled header changes. We could make + # this depend on using gcc and precompiled headers being enabled, but that's + # probably not worth it. See also + # https://github.com/ccache/ccache/issues/1686 + '-fpch-deps', ] cflags += cc.get_supported_arguments(common_functional_flags) -- 2.54.0.450.g9ac3f193c0
