build: tolerate use of _Generic from glibc 2.43 with Clang (#6233)

The `linux-{asan-ubsan,sha256,reftable}` jobs run inside
`ubuntu:rolling`, which now resolves to Ubuntu 26.04 with glibc 2.43;
that pulls `_Generic` into `<sys/cdefs.h>` and breaks our `-std=gnu99
-Werror` Clang builds. Concrete failure:
https://github.com/git-for-windows/git/actions/runs/25390480083/job/74463338845.

Picking up Patrick Steinhardt's fix from
https://lore.kernel.org/git/20260505-b4-pks-ci-tolerate-glibc-generic-v1-1-5786386fe512@pks.im/
ahead of its upstream merge so the GfW CI goes green again. The diff
conflicts with `fe5704a3695c "mimalloc: offer a build-time option to
enable it"`, which wraps the affected `config.mak.dev` block in `ifndef
USE_MIMALLOC`; the resolution preserves that wrap on the `gcc6`-only
branch surviving Patrick's patch. `meson.build` auto-merged.
This commit is contained in:
Johannes Schindelin
2026-05-08 11:44:09 +02:00
2 changed files with 13 additions and 0 deletions

View File

@@ -98,6 +98,13 @@ endif
endif
endif
# glibc 2.43 headers unconditionally use _Generic even when we ask the
# compiler to stick to -std=gnu99 and unlike GCC, clang lacks a
# workaround to squelch warnings from system headers.
ifneq ($(filter clang1,$(COMPILER_FEATURES)),) # if we are using clang
DEVELOPER_CFLAGS += -Wno-c11-extensions
endif
# https://bugzilla.redhat.com/show_bug.cgi?id=2075786
ifneq ($(filter gcc12,$(COMPILER_FEATURES)),)
DEVELOPER_CFLAGS += -Wno-error=stringop-overread

View File

@@ -867,6 +867,12 @@ if get_option('warning_level') in ['2','3', 'everything'] and compiler.get_argum
libgit_c_args += cflag
endif
endforeach
# Clang generates warnings when compiling glibc 2.43 because of the use of
# _Generic.
if compiler.get_id() == 'clang'
libgit_c_args += '-Wno-c11-extensions'
endif
endif
if get_option('breaking_changes')