From: Toon Claes <toon@iotcl.com>
To: Patrick Steinhardt <ps@pks.im>, git@vger.kernel.org
Cc: "SZEDER Gábor" <szeder.dev@gmail.com>,
"Junio C Hamano" <gitster@pobox.com>,
"Kristoffer Haugsbakk" <kristofferhaugsbakk@fastmail.com>,
"Phillip Wood" <phillip.wood@dunelm.org.uk>
Subject: Re: [PATCH v3 6/8] git-compat-util.h: move warning infra to prepare for PCHs
Date: Fri, 20 Mar 2026 13:34:50 +0100 [thread overview]
Message-ID: <87y0jm1xxx.fsf@iotcl.com> (raw)
In-Reply-To: <20260319-b4-pks-build-infra-improvements-v3-6-82f5fb3edc3f@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
> The "git-compat-util.h" header is supposed to be the first header
> included by every code compilation unit. As such, a subsequent commit
> will start to precompile this header to speed up compilation of Git.
>
> This will cause an issue though with the way that we have set up the
> "-Wsign-compare" warnings. It is expected that any compilation unit that
> fails with that compiler warning sets `DISABLE_SIGN_COMPARE_WARNINGS`
> before including "git-compat-util.h". If so, we'll disable the warning
> right away via a compiler pragma.
>
> But with precompiled headers we do not know ahead of time whether the
> code unit wants to disable those warnings, and thus we'll have to
> precompile the header without defining `DISABLE_SIGN_COMPARE_WARNINGS`.
> But as the pragma statement is wrapped by our include guards, the second
> include of that file will not have the desired effect of disabling the
> warnings anymore.
>
> We could fix this issue by declaring a new macro that compilation units
> are expected to invoke after having included the file. In retrospect,
> that would have been the better way to handle this as it allows for
> more flexibility: we could for example toggle the warning for specific
> code blocks, only. But changing this now would require a bunch of
> changes, and the churn feels excessive for what we gain.
>
> Instead, prepare for the precompiled headers by moving the code outside
> of the include guards.
>
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
> git-compat-util.h | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/git-compat-util.h b/git-compat-util.h
> index bebcf9f698..4b4ea2498f 100644
> --- a/git-compat-util.h
> +++ b/git-compat-util.h
> @@ -34,10 +34,6 @@ struct strbuf;
> # define DISABLE_WARNING(warning)
> #endif
>
> -#ifdef DISABLE_SIGN_COMPARE_WARNINGS
> -DISABLE_WARNING(-Wsign-compare)
> -#endif
> -
> #undef FLEX_ARRAY
> #define FLEX_ARRAY /* empty - weather balloon to require C99 FAM */
>
> @@ -1099,3 +1095,7 @@ extern int not_supposed_to_survive;
> #endif /* CHECK_ASSERTION_SIDE_EFFECTS */
>
> #endif
> +
> +#ifdef DISABLE_SIGN_COMPARE_WARNINGS
> +DISABLE_WARNING(-Wsign-compare)
> +#endif
Okay, so with all patches applied, when a .c file is compiled,
tools/precompiled.h is included as the first one. That one includes
git-compat-util.h and processes everything inside the include guards.
Then it starts processing the contents of that files and that file might
#define DISABLE_SIGN_COMPARE_WARNINGS. Usually git-compat-util.h is then
included again, but thanks to the include guards, most of it is ignored,
except for this last bit.
Okay, makes sense.
--
Cheers,
Toon
next prev parent reply other threads:[~2026-03-20 12:34 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-10 17:52 [PATCH 0/8] Some build system improvements Patrick Steinhardt
2026-03-10 17:52 ` [PATCH 1/8] Introduce new "tools/" directory Patrick Steinhardt
2026-03-10 17:52 ` [PATCH 2/8] contrib: move "coccinelle/" directory into "tools/" Patrick Steinhardt
2026-03-10 17:52 ` [PATCH 3/8] contrib: move "coverage-diff.sh" script " Patrick Steinhardt
2026-03-10 17:52 ` [PATCH 4/8] contrib: move "update-unicode.sh" " Patrick Steinhardt
2026-03-10 17:52 ` [PATCH 5/8] builds: move build scripts " Patrick Steinhardt
2026-03-10 17:52 ` [PATCH 6/8] git-compat-util.h: move warning infra to prepare for PCHs Patrick Steinhardt
2026-03-10 17:52 ` [PATCH 7/8] meson: compile compatibility sources separately Patrick Steinhardt
2026-03-11 14:32 ` Phillip Wood
2026-03-11 14:56 ` Phillip Wood
2026-03-11 23:27 ` SZEDER Gábor
2026-03-12 6:21 ` Patrick Steinhardt
2026-03-13 10:33 ` Phillip Wood
2026-03-16 8:09 ` Patrick Steinhardt
2026-04-10 15:17 ` SZEDER Gábor
2026-03-12 6:22 ` Patrick Steinhardt
2026-03-13 10:33 ` Phillip Wood
2026-03-16 8:09 ` Patrick Steinhardt
2026-03-16 10:52 ` Phillip Wood
2026-03-17 15:38 ` Kristoffer Haugsbakk
2026-03-19 5:32 ` Patrick Steinhardt
2026-03-10 17:52 ` [PATCH 8/8] meson: precompile "git-compat-util.h" Patrick Steinhardt
2026-03-11 14:32 ` Phillip Wood
2026-03-12 6:21 ` Patrick Steinhardt
2026-03-10 18:23 ` [PATCH 0/8] Some build system improvements Junio C Hamano
2026-03-11 7:32 ` Patrick Steinhardt
2026-03-13 22:21 ` Junio C Hamano
2026-03-16 8:09 ` Patrick Steinhardt
2026-03-16 10:07 ` [PATCH v2 " Patrick Steinhardt
2026-03-16 10:07 ` [PATCH v2 1/8] Introduce new "tools/" directory Patrick Steinhardt
2026-03-16 10:07 ` [PATCH v2 2/8] contrib: move "coccinelle/" directory into "tools/" Patrick Steinhardt
2026-03-16 10:07 ` [PATCH v2 3/8] contrib: move "coverage-diff.sh" script " Patrick Steinhardt
2026-03-16 10:07 ` [PATCH v2 4/8] contrib: move "update-unicode.sh" " Patrick Steinhardt
2026-03-16 10:08 ` [PATCH v2 5/8] builds: move build scripts " Patrick Steinhardt
2026-03-16 10:08 ` [PATCH v2 6/8] git-compat-util.h: move warning infra to prepare for PCHs Patrick Steinhardt
2026-03-16 10:08 ` [PATCH v2 7/8] meson: compile compatibility sources separately Patrick Steinhardt
2026-03-16 10:08 ` [PATCH v2 8/8] meson: precompile "git-compat-util.h" Patrick Steinhardt
2026-03-16 10:54 ` [PATCH v2 0/8] Some build system improvements Phillip Wood
2026-03-19 5:33 ` [PATCH v3 " Patrick Steinhardt
2026-03-19 5:33 ` [PATCH v3 1/8] Introduce new "tools/" directory Patrick Steinhardt
2026-03-19 5:33 ` [PATCH v3 2/8] contrib: move "coccinelle/" directory into "tools/" Patrick Steinhardt
2026-03-19 5:33 ` [PATCH v3 3/8] contrib: move "coverage-diff.sh" script " Patrick Steinhardt
2026-03-20 12:15 ` Toon Claes
2026-03-19 5:33 ` [PATCH v3 4/8] contrib: move "update-unicode.sh" " Patrick Steinhardt
2026-03-19 5:33 ` [PATCH v3 5/8] builds: move build scripts " Patrick Steinhardt
2026-03-19 5:33 ` [PATCH v3 6/8] git-compat-util.h: move warning infra to prepare for PCHs Patrick Steinhardt
2026-03-20 12:34 ` Toon Claes [this message]
2026-03-19 5:33 ` [PATCH v3 7/8] meson: compile compatibility sources separately Patrick Steinhardt
2026-03-19 5:33 ` [PATCH v3 8/8] meson: precompile "git-compat-util.h" Patrick Steinhardt
2026-03-20 12:37 ` Toon Claes
2026-04-10 15:36 ` SZEDER Gábor
2026-04-10 15:46 ` Phillip Wood
2026-04-10 16:05 ` SZEDER Gábor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y0jm1xxx.fsf@iotcl.com \
--to=toon@iotcl.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=kristofferhaugsbakk@fastmail.com \
--cc=phillip.wood@dunelm.org.uk \
--cc=ps@pks.im \
--cc=szeder.dev@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.