{"thread":{"id":"65605","subject":"[PATCH] config.mak.dev: suppress C11 extension warning for Clang on Linux","startedAt":"2026-05-07T02:16:35Z","lastAt":"2026-05-10T22:21:19Z","messageCount":3,"participants":["Shardul Natu via GitGitGadget","Pablo","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"542830","messageId":"pull.2291.git.git.1778120192298.gitgitgadget@gmail.com","threadId":"65605","inReplyTo":null,"subject":"[PATCH] config.mak.dev: suppress C11 extension warning for Clang on Linux","fromName":"Shardul Natu via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-05-07T02:16:32Z","receivedAt":"2026-05-07T02:16:35Z","isPatch":true,"body":"From: Shnatu <snatu@google.com>\n\nWhen building Git with Clang on Linux with DEVELOPER=1, the build fails\nbecause Clang treats C11 features used in glibc headers as extensions\nand raises errors due to -std=gnu99, -pedantic, and -Werror.\n\nSpecifically, glibc's string.h uses _Generic (a C11 feature) in macros\nlike strchr. When these macros are expanded in Git's C files, Clang\nwarns about them being C11 extensions.\n\nGCC does not exhibit this behavior because it suppresses pedantic\nwarnings for macros defined in system headers.\n\nTo fix this, add -Wno-c11-extensions to DEVELOPER_CFLAGS when using\nClang, but restrict it to Linux (uname_S == Linux). This suppresses\nthe warning for glibc headers while keeping the build strict on other\nplatforms (like macOS) to catch accidental C11 usage in Git's own code.\n\nSigned-off-by: Shnatu <snatu@google.com>\n---\n    config.mak.dev: suppress C11 extension warning for Clang on Linux\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2291%2Fkiranani%2Fnext-2-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2291/kiranani/next-2-v1\nPull-Request: https://github.com/git/git/pull/2291\n\n config.mak.dev | 3 +++\n 1 file changed, 3 insertions(+)\n\ndiff --git a/config.mak.dev b/config.mak.dev\nindex c8dcf78779..f1dcf4329a 100644\n--- a/config.mak.dev\n+++ b/config.mak.dev\n@@ -87,6 +87,9 @@ endif\n # The bug was fixed in Apple clang 12.\n #\n ifneq ($(filter clang1,$(COMPILER_FEATURES)),)     # if we are using clang\n+ifeq ($(uname_S),Linux)\n+DEVELOPER_CFLAGS += -Wno-c11-extensions\n+endif\n ifeq ($(uname_S),Darwin)                           # if we are on darwin\n ifeq ($(filter clang12,$(COMPILER_FEATURES)),)     # if version < 12\n DEVELOPER_CFLAGS += -Wno-missing-braces\n\nbase-commit: 4f69b47b940100b02630f745a52f9d9850f122b2\n-- \ngitgitgadget\n"},{"id":"542838","messageId":"CAN5EUNRn+SqALbGR3KE9zUKxUfuJrqvK+XJcq-t=biTw56m8kg@mail.gmail.com","threadId":"65605","inReplyTo":"pull.2291.git.git.1778120192298.gitgitgadget@gmail.com","subject":"Re: [PATCH] config.mak.dev: suppress C11 extension warning for Clang on Linux","fromName":"Pablo","fromEmail":"pabloosabaterr@gmail.com","sentAt":"2026-05-07T10:07:39Z","receivedAt":"2026-05-07T10:07:54Z","isPatch":true,"body":"El jue, 7 may 2026 a las 4:16, Shardul Natu via GitGitGadget\n(<gitgitgadget@gmail.com>) escribió:\n>\n> From: Shnatu <snatu@google.com>\n>\n> When building Git with Clang on Linux with DEVELOPER=1, the build fails\n> because Clang treats C11 features used in glibc headers as extensions\n> and raises errors due to -std=gnu99, -pedantic, and -Werror.\n\nHi Shnatu!\nThis is already being discussed at:\nhttps://lore.kernel.org/git/20260505-b4-pks-ci-tolerate-glibc-generic-v1-1-5786386fe512@pks.im/T/#u\n\nYou might want to check out that thread.\n\nHope this helps,\n\n--\nPablo\n\n>\n> Specifically, glibc's string.h uses _Generic (a C11 feature) in macros\n> like strchr. When these macros are expanded in Git's C files, Clang\n> warns about them being C11 extensions.\n>\n> GCC does not exhibit this behavior because it suppresses pedantic\n> warnings for macros defined in system headers.\n>\n> To fix this, add -Wno-c11-extensions to DEVELOPER_CFLAGS when using\n> Clang, but restrict it to Linux (uname_S == Linux). This suppresses\n> the warning for glibc headers while keeping the build strict on other\n> platforms (like macOS) to catch accidental C11 usage in Git's own code.\n>\n> Signed-off-by: Shnatu <snatu@google.com>\n> ---\n>     config.mak.dev: suppress C11 extension warning for Clang on Linux\n>\n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2291%2Fkiranani%2Fnext-2-v1\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2291/kiranani/next-2-v1\n> Pull-Request: https://github.com/git/git/pull/2291\n>\n>  config.mak.dev | 3 +++\n>  1 file changed, 3 insertions(+)\n>\n> diff --git a/config.mak.dev b/config.mak.dev\n> index c8dcf78779..f1dcf4329a 100644\n> --- a/config.mak.dev\n> +++ b/config.mak.dev\n> @@ -87,6 +87,9 @@ endif\n>  # The bug was fixed in Apple clang 12.\n>  #\n>  ifneq ($(filter clang1,$(COMPILER_FEATURES)),)     # if we are using clang\n> +ifeq ($(uname_S),Linux)\n> +DEVELOPER_CFLAGS += -Wno-c11-extensions\n> +endif\n>  ifeq ($(uname_S),Darwin)                           # if we are on darwin\n>  ifeq ($(filter clang12,$(COMPILER_FEATURES)),)     # if version < 12\n>  DEVELOPER_CFLAGS += -Wno-missing-braces\n>\n> base-commit: 4f69b47b940100b02630f745a52f9d9850f122b2\n> --\n> gitgitgadget\n>\n"},{"id":"542975","messageId":"xmqq5x4uaote.fsf@gitster.g","threadId":"65605","inReplyTo":"CAN5EUNRn+SqALbGR3KE9zUKxUfuJrqvK+XJcq-t=biTw56m8kg@mail.gmail.com","subject":"Re: [PATCH] config.mak.dev: suppress C11 extension warning for Clang on Linux","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-05-10T22:21:17Z","receivedAt":"2026-05-10T22:21:19Z","isPatch":true,"body":"Pablo <pabloosabaterr@gmail.com> writes:\n\n> El jue, 7 may 2026 a las 4:16, Shardul Natu via GitGitGadget\n> (<gitgitgadget@gmail.com>) escribió:\n>>\n>> From: Shnatu <snatu@google.com>\n>>\n>> When building Git with Clang on Linux with DEVELOPER=1, the build fails\n>> because Clang treats C11 features used in glibc headers as extensions\n>> and raises errors due to -std=gnu99, -pedantic, and -Werror.\n>\n> Hi Shnatu!\n> This is already being discussed at:\n> https://lore.kernel.org/git/20260505-b4-pks-ci-tolerate-glibc-generic-v1-1-5786386fe512@pks.im/T/#u\n>\n> You might want to check out that thread.\n>\n> Hope this helps,\n\nYes, they aim to solve the same issue, but the approach taken by\nthis patch to use -Wno-c11-extensions on clang may be with less\ndamage than the other approach that drops -std=gnu99 from Makefile.\n\nThe other approach uses the equivalent of this patch on the meson\nside, so it may be doubly so that we should use -Wno-c11-extensions\non both build systems, no?\n\n\n>> Specifically, glibc's string.h uses _Generic (a C11 feature) in macros\n>> like strchr. When these macros are expanded in Git's C files, Clang\n>> warns about them being C11 extensions.\n>>\n>> GCC does not exhibit this behavior because it suppresses pedantic\n>> warnings for macros defined in system headers.\n>>\n>> To fix this, add -Wno-c11-extensions to DEVELOPER_CFLAGS when using\n>> Clang, but restrict it to Linux (uname_S == Linux). This suppresses\n>> the warning for glibc headers while keeping the build strict on other\n>> platforms (like macOS) to catch accidental C11 usage in Git's own code.\n>>\n>> Signed-off-by: Shnatu <snatu@google.com>\n>> ---\n>>     config.mak.dev: suppress C11 extension warning for Clang on Linux\n>>\n>> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2291%2Fkiranani%2Fnext-2-v1\n>> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2291/kiranani/next-2-v1\n>> Pull-Request: https://github.com/git/git/pull/2291\n>>\n>>  config.mak.dev | 3 +++\n>>  1 file changed, 3 insertions(+)\n>>\n>> diff --git a/config.mak.dev b/config.mak.dev\n>> index c8dcf78779..f1dcf4329a 100644\n>> --- a/config.mak.dev\n>> +++ b/config.mak.dev\n>> @@ -87,6 +87,9 @@ endif\n>>  # The bug was fixed in Apple clang 12.\n>>  #\n>>  ifneq ($(filter clang1,$(COMPILER_FEATURES)),)     # if we are using clang\n>> +ifeq ($(uname_S),Linux)\n>> +DEVELOPER_CFLAGS += -Wno-c11-extensions\n>> +endif\n>>  ifeq ($(uname_S),Darwin)                           # if we are on darwin\n>>  ifeq ($(filter clang12,$(COMPILER_FEATURES)),)     # if version < 12\n>>  DEVELOPER_CFLAGS += -Wno-missing-braces\n>>\n>> base-commit: 4f69b47b940100b02630f745a52f9d9850f122b2\n>> --\n>> gitgitgadget\n>>\n"}]}