* [PATCH] config.mak.dev: suppress C11 extension warning for Clang on Linux
@ 2026-05-07 2:16 Shardul Natu via GitGitGadget
2026-05-07 10:07 ` Pablo
0 siblings, 1 reply; 3+ messages in thread
From: Shardul Natu via GitGitGadget @ 2026-05-07 2:16 UTC (permalink / raw)
To: git; +Cc: Shnatu
From: Shnatu <snatu@google.com>
When building Git with Clang on Linux with DEVELOPER=1, the build fails
because Clang treats C11 features used in glibc headers as extensions
and raises errors due to -std=gnu99, -pedantic, and -Werror.
Specifically, glibc's string.h uses _Generic (a C11 feature) in macros
like strchr. When these macros are expanded in Git's C files, Clang
warns about them being C11 extensions.
GCC does not exhibit this behavior because it suppresses pedantic
warnings for macros defined in system headers.
To fix this, add -Wno-c11-extensions to DEVELOPER_CFLAGS when using
Clang, but restrict it to Linux (uname_S == Linux). This suppresses
the warning for glibc headers while keeping the build strict on other
platforms (like macOS) to catch accidental C11 usage in Git's own code.
Signed-off-by: Shnatu <snatu@google.com>
---
config.mak.dev: suppress C11 extension warning for Clang on Linux
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2291%2Fkiranani%2Fnext-2-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2291/kiranani/next-2-v1
Pull-Request: https://github.com/git/git/pull/2291
config.mak.dev | 3 +++
1 file changed, 3 insertions(+)
diff --git a/config.mak.dev b/config.mak.dev
index c8dcf78779..f1dcf4329a 100644
--- a/config.mak.dev
+++ b/config.mak.dev
@@ -87,6 +87,9 @@ endif
# The bug was fixed in Apple clang 12.
#
ifneq ($(filter clang1,$(COMPILER_FEATURES)),) # if we are using clang
+ifeq ($(uname_S),Linux)
+DEVELOPER_CFLAGS += -Wno-c11-extensions
+endif
ifeq ($(uname_S),Darwin) # if we are on darwin
ifeq ($(filter clang12,$(COMPILER_FEATURES)),) # if version < 12
DEVELOPER_CFLAGS += -Wno-missing-braces
base-commit: 4f69b47b940100b02630f745a52f9d9850f122b2
--
gitgitgadget
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] config.mak.dev: suppress C11 extension warning for Clang on Linux
2026-05-07 2:16 [PATCH] config.mak.dev: suppress C11 extension warning for Clang on Linux Shardul Natu via GitGitGadget
@ 2026-05-07 10:07 ` Pablo
2026-05-10 22:21 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Pablo @ 2026-05-07 10:07 UTC (permalink / raw)
To: Shardul Natu via GitGitGadget; +Cc: git, Shnatu
El jue, 7 may 2026 a las 4:16, Shardul Natu via GitGitGadget
(<gitgitgadget@gmail.com>) escribió:
>
> From: Shnatu <snatu@google.com>
>
> When building Git with Clang on Linux with DEVELOPER=1, the build fails
> because Clang treats C11 features used in glibc headers as extensions
> and raises errors due to -std=gnu99, -pedantic, and -Werror.
Hi Shnatu!
This is already being discussed at:
https://lore.kernel.org/git/20260505-b4-pks-ci-tolerate-glibc-generic-v1-1-5786386fe512@pks.im/T/#u
You might want to check out that thread.
Hope this helps,
--
Pablo
>
> Specifically, glibc's string.h uses _Generic (a C11 feature) in macros
> like strchr. When these macros are expanded in Git's C files, Clang
> warns about them being C11 extensions.
>
> GCC does not exhibit this behavior because it suppresses pedantic
> warnings for macros defined in system headers.
>
> To fix this, add -Wno-c11-extensions to DEVELOPER_CFLAGS when using
> Clang, but restrict it to Linux (uname_S == Linux). This suppresses
> the warning for glibc headers while keeping the build strict on other
> platforms (like macOS) to catch accidental C11 usage in Git's own code.
>
> Signed-off-by: Shnatu <snatu@google.com>
> ---
> config.mak.dev: suppress C11 extension warning for Clang on Linux
>
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2291%2Fkiranani%2Fnext-2-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2291/kiranani/next-2-v1
> Pull-Request: https://github.com/git/git/pull/2291
>
> config.mak.dev | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/config.mak.dev b/config.mak.dev
> index c8dcf78779..f1dcf4329a 100644
> --- a/config.mak.dev
> +++ b/config.mak.dev
> @@ -87,6 +87,9 @@ endif
> # The bug was fixed in Apple clang 12.
> #
> ifneq ($(filter clang1,$(COMPILER_FEATURES)),) # if we are using clang
> +ifeq ($(uname_S),Linux)
> +DEVELOPER_CFLAGS += -Wno-c11-extensions
> +endif
> ifeq ($(uname_S),Darwin) # if we are on darwin
> ifeq ($(filter clang12,$(COMPILER_FEATURES)),) # if version < 12
> DEVELOPER_CFLAGS += -Wno-missing-braces
>
> base-commit: 4f69b47b940100b02630f745a52f9d9850f122b2
> --
> gitgitgadget
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] config.mak.dev: suppress C11 extension warning for Clang on Linux
2026-05-07 10:07 ` Pablo
@ 2026-05-10 22:21 ` Junio C Hamano
0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2026-05-10 22:21 UTC (permalink / raw)
To: Pablo; +Cc: Shardul Natu via GitGitGadget, git, Shnatu
Pablo <pabloosabaterr@gmail.com> writes:
> El jue, 7 may 2026 a las 4:16, Shardul Natu via GitGitGadget
> (<gitgitgadget@gmail.com>) escribió:
>>
>> From: Shnatu <snatu@google.com>
>>
>> When building Git with Clang on Linux with DEVELOPER=1, the build fails
>> because Clang treats C11 features used in glibc headers as extensions
>> and raises errors due to -std=gnu99, -pedantic, and -Werror.
>
> Hi Shnatu!
> This is already being discussed at:
> https://lore.kernel.org/git/20260505-b4-pks-ci-tolerate-glibc-generic-v1-1-5786386fe512@pks.im/T/#u
>
> You might want to check out that thread.
>
> Hope this helps,
Yes, they aim to solve the same issue, but the approach taken by
this patch to use -Wno-c11-extensions on clang may be with less
damage than the other approach that drops -std=gnu99 from Makefile.
The other approach uses the equivalent of this patch on the meson
side, so it may be doubly so that we should use -Wno-c11-extensions
on both build systems, no?
>> Specifically, glibc's string.h uses _Generic (a C11 feature) in macros
>> like strchr. When these macros are expanded in Git's C files, Clang
>> warns about them being C11 extensions.
>>
>> GCC does not exhibit this behavior because it suppresses pedantic
>> warnings for macros defined in system headers.
>>
>> To fix this, add -Wno-c11-extensions to DEVELOPER_CFLAGS when using
>> Clang, but restrict it to Linux (uname_S == Linux). This suppresses
>> the warning for glibc headers while keeping the build strict on other
>> platforms (like macOS) to catch accidental C11 usage in Git's own code.
>>
>> Signed-off-by: Shnatu <snatu@google.com>
>> ---
>> config.mak.dev: suppress C11 extension warning for Clang on Linux
>>
>> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2291%2Fkiranani%2Fnext-2-v1
>> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2291/kiranani/next-2-v1
>> Pull-Request: https://github.com/git/git/pull/2291
>>
>> config.mak.dev | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/config.mak.dev b/config.mak.dev
>> index c8dcf78779..f1dcf4329a 100644
>> --- a/config.mak.dev
>> +++ b/config.mak.dev
>> @@ -87,6 +87,9 @@ endif
>> # The bug was fixed in Apple clang 12.
>> #
>> ifneq ($(filter clang1,$(COMPILER_FEATURES)),) # if we are using clang
>> +ifeq ($(uname_S),Linux)
>> +DEVELOPER_CFLAGS += -Wno-c11-extensions
>> +endif
>> ifeq ($(uname_S),Darwin) # if we are on darwin
>> ifeq ($(filter clang12,$(COMPILER_FEATURES)),) # if version < 12
>> DEVELOPER_CFLAGS += -Wno-missing-braces
>>
>> base-commit: 4f69b47b940100b02630f745a52f9d9850f122b2
>> --
>> gitgitgadget
>>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-10 22:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-07 2:16 [PATCH] config.mak.dev: suppress C11 extension warning for Clang on Linux Shardul Natu via GitGitGadget
2026-05-07 10:07 ` Pablo
2026-05-10 22:21 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox