Subject: Re: [PATCH 7/8] meson: compile compatibility sources separately

From: Phillip Wood <[email-masked]>
Date: Fri, 13 Mar 2026 10:33:36 +0000

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?

Thanks

Phillip

> Patrick
> 
>> [1] Second bullet point at:
>>      https://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html