From: Patrick Steinhardt Date: Mon, 16 Mar 2026 08:09:16 GMT Subject: Re: [PATCH 7/8] meson: compile compatibility sources separately Message-ID: In-Reply-To: <3be0c711-5222-4faf-bd32-117230215490@gmail.com> On Fri, Mar 13, 2026 at 10:33:36AM +0000, Phillip Wood wrote: > On 12/03/2026 06:21, Patrick Steinhardt wrote: > > On Thu, Mar 12, 2026 at 12:27:49AM +0100, SZEDER Gábor wrote: > > > 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] > > > > I think you must have confused something, because the link _does_ point > > to GCC's documentation, which does contain the quote. > > > > But yes, overall there can only be one precompiled header, and it cannot > > be used after the first token indeed. The use of "-include" is also > > explicitly noted for "projects not designed with precompiled headers in > > mind", which fits Git. After all, we still have the ability to compile > > without precompiled headers, and I don't expect that to go away. > > Thanks to you both for the explanation. Should we explain this in the commit > message? Yeah, let's add a note for how this works internally. Let's also highlight that we typically only have a single precompiled header by not passing the headers as an array. Patrick