From: SZEDER Gábor Date: Wed, 11 Mar 2026 23:27:49 GMT Subject: Re: [PATCH 7/8] meson: compile compatibility sources separately Message-ID: In-Reply-To: On Wed, Mar 11, 2026 at 02:56:24PM +0000, Phillip Wood wrote: > On 11/03/2026 14:32, Phillip Wood wrote: > > On 10/03/2026 17:52, Patrick Steinhardt wrote: > > > In the next commit we're about to introduce a precompiled header for > > > "git-compat-util.h". The consequence of this change is that we'll > > > implicitly include that header for every compilation unit that uses the > > > precompiled headers. > > > > Is that a meson thing? I know it defines precompiled headers on a per- > > target basis but does it somehow force each source file to include the > > precompiled header? Looking at the gcc documentation it seems like the > > precompiled header is only included where the original header is > > included. > > Answering my own question the precompiled header is included via "-include" > on the commandline. This is necessary in the general case because a > precompiled header cannot be used once the first C token is seen. > > As an aside in git we could probably get away without using "-include" > because if we include "git-compat-util.h" it is always the first thing we > do, or we inculde another file like "builtin.h" which immediately includes > "git-compat-util.h" and so it is included before the first C token is seen. I couldn't find this in the GCC docs, but Make's documentation states that "you cannot include a precompiled header from inside another header." [1] The strace of compiling a 'builtin/*.c' source file seems to confirm it, the compiler (gcc-12) does look for 'builtin.h.gch', but doesn't look for 'git-compat-util.h.gch': 592662 newfstatat(AT_FDCWD, "builtin/builtin.h.gch", 0x7fff2066e610, 0) = -1 ENOENT (No such file or directory) 592662 openat(AT_FDCWD, "builtin/builtin.h", O_RDONLY|O_NOCTTY) = -1 ENOENT (No such file or directory) 592662 newfstatat(AT_FDCWD, "./builtin.h.gch", 0x7fff2066e610, 0) = -1 ENOENT (No such file or directory) 592662 openat(AT_FDCWD, "./builtin.h", O_RDONLY|O_NOCTTY) = 4 592662 newfstatat(4, "", {st_mode=S_IFREG|0664, st_size=17968, ...}, AT_EMPTY_PATH) = 0 592662 read(4, "#ifndef BUILTIN_H\n#define BUILTI"..., 17968) = 17968 592662 close(4) = 0 592662 openat(AT_FDCWD, "./git-compat-util.h", O_RDONLY|O_NOCTTY) = 4 [1] Second bullet point at: https://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html