Skip to content

Commit 99cb679

Browse files
committed
Fix build error with gcc-8.5.0.
1 parent 50b5902 commit 99cb679

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

lib/Makefile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,18 @@ endif
130130
GCCVERGE12 = $(shell expr `gcc -dumpversion | cut -f1 -d.` \>= 12)
131131
ifeq "$(GCCVERGE12)" "1"
132132
CFLAGS+= -Wno-error=array-bounds
133-
CFLAGS+= -Wno-error=cast-qual
134-
CFLAGS+= -Wno-error=format
135-
CFLAGS+= -Wno-error=format-extra-args
136133
endif
137134

135+
# FreeBSD's kernel printf uses %D (hex dump format) which is unknown to GCC's
136+
# format checker. Disable -Werror=format and -Werror=format-extra-args on every
137+
# GCC version so the FreeBSD-derived sources still build.
138+
CFLAGS+= -Wno-error=format
139+
CFLAGS+= -Wno-error=format-extra-args
140+
141+
# cast-qual is triggered by FreeBSD's atomic_store_ptr macro on every supported
142+
# GCC version (including GCC 8), so disable -Werror=cast-qual unconditionally.
143+
CFLAGS+= -Wno-error=cast-qual
144+
138145
GCCVERGE13 = $(shell expr `gcc -dumpversion | cut -f1 -d.` \>= 13)
139146
ifeq "$(GCCVERGE13)" "1"
140147
CFLAGS+= -Wno-error=dangling-pointer

mk/kern.mk

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@ CWARNEXTRA?= -Wno-error-tautological-compare -Wno-error-empty-body \
3535
endif
3636

3737
ifeq (${COMPILER_TYPE},gcc)
38+
# -Wno-address-of-packed-member was added in GCC 9.0, omit it on older GCC
39+
GCCVER_GE9 := $(shell expr `gcc -dumpversion | cut -f1 -d.` \>= 9)
40+
ifeq "$(GCCVER_GE9)" "1"
3841
CWARNEXTRA?= -Wno-unused-but-set-variable -Wno-address-of-packed-member
42+
else
43+
CWARNEXTRA?= -Wno-unused-but-set-variable
44+
endif
3945
endif
4046

4147
#

0 commit comments

Comments
 (0)