Skip to content

Commit 0701bca

Browse files
authored
build: tolerate use of _Generic from glibc 2.43 with Clang (#911)
Same fix as git-for-windows#6233 in `git-for-windows/git`, cherry-picked here so the corresponding `microsoft/git` branch builds again on Ubuntu 26.04. The `ubuntu:rolling` containers used by `linux-{asan-ubsan,sha256,reftable}` now ship glibc 2.43, which puts `_Generic` into `<sys/cdefs.h>`; Clang under `-std=gnu99 -Werror` flags it as a C11 extension. Picking up Patrick Steinhardt's upstream-bound fix from https://lore.kernel.org/git/20260505-b4-pks-ci-tolerate-glibc-generic-v1-1-5786386fe512@pks.im/ ahead of its eventual merge (no list movement so far, not yet in `seen`). The diff conflicts with the `ifndef USE_MIMALLOC` wrap that this fork inherits from `git-for-windows/git`'s `fe5704a3695c "mimalloc: offer a build-time option to enable it"`; the resolution preserves that wrap on the `gcc6`-only branch surviving Patrick's patch. `meson.build` auto-merged.
2 parents 9ac4846 + 2d9e949 commit 0701bca

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

config.mak.dev

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,17 @@ endif
2121
endif
2222

2323
ifneq ($(uname_S),FreeBSD)
24-
ifneq ($(or $(filter gcc6,$(COMPILER_FEATURES)),$(filter clang7,$(COMPILER_FEATURES))),)
24+
ifneq ($(filter gcc6,$(COMPILER_FEATURES)),)
2525
ifndef USE_MIMALLOC
2626
DEVELOPER_CFLAGS += -std=gnu99
2727
endif
2828
endif
2929
else
3030
# FreeBSD cannot limit to C99 because its system headers unconditionally
3131
# rely on C11 features.
32+
#
33+
# Clang cannot limit to C99 when using glibc 2.43 because its system headers
34+
# depend on the _Generic C11 feature. This works with GCC though.
3235
endif
3336

3437
DEVELOPER_CFLAGS += -Wdeclaration-after-statement

meson.build

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,12 @@ if get_option('warning_level') in ['2','3', 'everything'] and compiler.get_argum
861861
libgit_c_args += cflag
862862
endif
863863
endforeach
864+
865+
# Clang generates warnings when compiling glibc 2.43 because of the use of
866+
# _Generic.
867+
if compiler.get_id() == 'clang'
868+
libgit_c_args += '-Wno-c11-extensions'
869+
endif
864870
endif
865871

866872
if get_option('breaking_changes')

0 commit comments

Comments
 (0)