Skip to content

Commit cda0b14

Browse files
authored
build: bring the _Generic-from-glibc-2.43 patch in line with upstream (#6242)
Upstream has landed Patrick Steinhardt's patch [build: tolerate use of _Generic from glibc 2.43 with Clang](https://lore.kernel.org/git/xmqqecjischc.fsf@gitster.g) in a form that differs from what we currently carry as 74c3ea9 (a cherry-pick of Patrick's v1). The upstream variant on `next` (commit 0a6d290) carries the trailer `[jc: replaced Makefile side with Shardul's approach]` and is signed off by Junio. Concretely, instead of dropping `-std=gnu99` for Clang in `config.mak.dev`, the upstream variant keeps `-std=gnu99` and adds `-Wno-c11-extensions` for Clang in a dedicated top-level block, mirroring what Patrick already did on the Meson side. Keeping `-std=gnu99` is desirable because it still lets us catch accidental use of newer-than-C99 features in Git's own code. This PR is the amend! commit that brings our downstream pick in line with that upstream landing. Autosquashing onto the parent of 74c3ea9 produces a single commit whose tree state is identical to 0a6d290 (modulo our USE_MIMALLOC carry inside the gcc6/clang7 block on the Makefile side). The intended merge strategy is autosquash-then-force-push to `main`, not a regular merge commit, so the history mirrors what landed upstream. Junio's confirmation that he is fast-tracking the topic to `next` and `master` is at https://lore.kernel.org/git/xmqqecjischc.fsf@gitster.g.
2 parents 8846017 + 610f086 commit cda0b14

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

config.mak.dev

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,12 @@ endif
2121
endif
2222

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

3532
DEVELOPER_CFLAGS += -Wdeclaration-after-statement
@@ -101,6 +98,13 @@ endif
10198
endif
10299
endif
103100

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

0 commit comments

Comments
 (0)