Skip to content

Commit 93c0b86

Browse files
committed
Detect GCC vs Clang for compiler-specific warning flags
GCC-only flags (-Wno-format-truncation, -Wno-unused-result) are now conditionally added via __GNUC__ / __clang__ preprocessor detection. Fixes Clang rejecting unknown GCC flags with -Werror on CI runners.
1 parent 8f225a3 commit 93c0b86

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

Makefile.cbm

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,17 @@ LIBGIT2_FLAGS =
3333
LIBGIT2_LIBS =
3434
endif
3535

36+
# GCC-only warning suppressions (Clang rejects unknown -Wno-* with -Werror).
37+
# Detect GCC by checking for __GNUC__ without __clang__ — handles all versions.
38+
IS_GCC := $(shell echo | $(CC) -dM -E - 2>/dev/null | grep -q '__GNUC__' && ! echo | $(CC) -dM -E - 2>/dev/null | grep -q '__clang__' && echo yes || echo no)
39+
GCC_ONLY_FLAGS :=
40+
ifeq ($(IS_GCC),yes)
41+
GCC_ONLY_FLAGS := -Wno-format-truncation -Wno-unused-result
42+
endif
43+
3644
CFLAGS_COMMON = -std=c11 -D_DEFAULT_SOURCE -Wall -Wextra -Werror \
3745
-Wno-unused-parameter -Wno-sign-compare \
38-
-Wno-format-truncation -Wno-unused-result \
46+
$(GCC_ONLY_FLAGS) \
3947
-Isrc -Ivendored -Ivendored/sqlite3 \
4048
-Ivendored/mimalloc/include \
4149
-I$(CBM_DIR) -I$(TS_INCLUDE) \

0 commit comments

Comments
 (0)