To build src cleanly with clang-15 you'd need the diff below.  The
alternative would be to patch our three zlib copies and wait for
upstream to fix it.  A more comfortable alternative is to just neuter
the warning.  -Wno-unknown-warning-option prevents llvm 13 from
complaining that it doesn't know about -Wno-deprecated-non-prototype and
should ease the transition.  I took care to only add this workaround on
clang archs, and to respect the COMPILER_VERSION checks where due.

ok?


commit b439995c024854e130e7211b1afee5c1e3f0b1cd
Author: jca <j...@wxcvbn.org>
Date:   Sat Dec 17 19:30:28 2022 +0100

    sys/arch/*/stand: work around clang 15 error in zlib
    
    Upstream issue:
    https://github.com/madler/zlib/issues/633

diff --git a/sys/arch/amd64/stand/Makefile.inc 
b/sys/arch/amd64/stand/Makefile.inc
index 7e45fedcc49..d35dc33cb2d 100644
--- a/sys/arch/amd64/stand/Makefile.inc
+++ b/sys/arch/amd64/stand/Makefile.inc
@@ -1,6 +1,9 @@
 #      $OpenBSD: Makefile.inc,v 1.18 2017/07/25 13:32:14 robert Exp $
 
 CFLAGS=${DEBUG} ${COPTS} -Oz -Wall -Werror
+# XXX Workaround for zlib + clang 15
+# https://github.com/madler/zlib/issues/633
+CFLAGS+=       -Wno-deprecated-non-prototype -Wno-unknown-warning-option
 CFLAGS+=       -ffreestanding -fno-stack-protector -DMDRANDOM
 CPPFLAGS+=-I${S} -I${SADIR}/libsa -I. -I${.CURDIR}
 SACFLAGS=-D_STANDALONE
diff --git a/sys/arch/arm64/stand/efiboot/Makefile 
b/sys/arch/arm64/stand/efiboot/Makefile
index 6cbb987af65..93be268d3bf 100644
--- a/sys/arch/arm64/stand/efiboot/Makefile
+++ b/sys/arch/arm64/stand/efiboot/Makefile
@@ -53,6 +53,9 @@ COPTS+=               -Wno-attributes -Wno-format
 COPTS+=                -ffreestanding -fno-stack-protector
 COPTS+=                -fshort-wchar -fPIC -fno-builtin
 COPTS+=                -Wall -Werror
+# XXX Workaround for zlib + clang 15
+# https://github.com/madler/zlib/issues/633
+COPTS+=                -Wno-deprecated-non-prototype 
-Wno-unknown-warning-option
 
 PROG.elf=      ${PROG:S/.EFI/.elf/}
 CLEANFILES+=   ${PROG.elf} ${PROG.elf}.tmp
diff --git a/sys/arch/armv7/stand/efiboot/Makefile 
b/sys/arch/armv7/stand/efiboot/Makefile
index d6ffc41bf38..fd78e744cd3 100644
--- a/sys/arch/armv7/stand/efiboot/Makefile
+++ b/sys/arch/armv7/stand/efiboot/Makefile
@@ -51,6 +51,9 @@ COPTS+=               -ffreestanding -fno-stack-protector
 COPTS+=                -fshort-wchar -fPIC -fno-builtin
 COPTS+=                -Wall -Werror
 COPTS+=                -mfloat-abi=soft
+# XXX Workaround for zlib + clang 15
+# https://github.com/madler/zlib/issues/633
+COPTS+=                -Wno-deprecated-non-prototype 
-Wno-unknown-warning-option
 
 PROG.elf=      ${PROG:S/.EFI/.elf/}
 CLEANFILES+=   ${PROG.elf} ${PROG.elf}.tmp
diff --git a/sys/arch/i386/stand/Makefile.inc b/sys/arch/i386/stand/Makefile.inc
index cd14f5b8954..ca70fed2124 100644
--- a/sys/arch/i386/stand/Makefile.inc
+++ b/sys/arch/i386/stand/Makefile.inc
@@ -2,6 +2,9 @@
 
 CFLAGS=${DEBUG} ${COPTS} -Oz -Wall -Werror
 CFLAGS+=       -ffreestanding -fno-stack-protector -DMDRANDOM
+# XXX Workaround for zlib + clang 15
+# https://github.com/madler/zlib/issues/633
+CFLAGS+=       -Wno-deprecated-non-prototype -Wno-unknown-warning-option
 CPPFLAGS+=-I${S} -I${SADIR}/libsa -I. -I${.CURDIR}
 SACFLAGS=-D_STANDALONE
 DEBUGFLAGS=
diff --git a/sys/arch/riscv64/stand/efiboot/Makefile 
b/sys/arch/riscv64/stand/efiboot/Makefile
index a9906d58a01..36f84cf29df 100644
--- a/sys/arch/riscv64/stand/efiboot/Makefile
+++ b/sys/arch/riscv64/stand/efiboot/Makefile
@@ -54,6 +54,9 @@ COPTS+=               -Wno-attributes -Wno-format
 COPTS+=                -ffreestanding -fno-stack-protector
 COPTS+=                -fshort-wchar -fPIC -fno-builtin
 COPTS+=                -Wall -Werror
+# XXX Workaround for zlib + clang 15
+# https://github.com/madler/zlib/issues/633
+COPTS+=                -Wno-deprecated-non-prototype 
-Wno-unknown-warning-option
 
 PROG.elf=      ${PROG:S/.EFI/.elf/}
 CLEANFILES+=   ${PROG.elf} ${PROG.elf}.tmp

commit 57a9510544cc42e91487b43363f5f9ba429829b0
Author: jca <j...@wxcvbn.org>
Date:   Mon Dec 19 18:05:54 2022 +0100

    sys: fix clang 15 errors with zlib
    
    While here, add -Wno-unknown-warning-option so that it's possible to build
    kernels with llvm 13 which doesn't understand -Wno-deprecated-non-prototype.
    
    Upstream zlib issue:
    https://github.com/madler/zlib/issues/633

diff --git a/sys/arch/amd64/conf/Makefile.amd64 
b/sys/arch/amd64/conf/Makefile.amd64
index d2704424f34..e77c296313f 100644
--- a/sys/arch/amd64/conf/Makefile.amd64
+++ b/sys/arch/amd64/conf/Makefile.amd64
@@ -72,6 +72,9 @@ CMACHFLAGS+=  -mno-retpoline
 NO_INTEGR_AS=  -no-integrated-as
 CWARNFLAGS+=   -Wno-address-of-packed-member -Wno-constant-conversion \
                -Wno-unused-but-set-variable -Wno-gnu-folding-constant
+# XXX Workaround for zlib + clang 15
+# https://github.com/madler/zlib/issues/633
+CWARNFLAGS+=   -Wno-deprecated-non-prototype -Wno-unknown-warning-option
 .endif
 
 DEBUG?=                -g
diff --git a/sys/arch/arm64/conf/Makefile.arm64 
b/sys/arch/arm64/conf/Makefile.arm64
index 47227b8d425..7321aaa246a 100644
--- a/sys/arch/arm64/conf/Makefile.arm64
+++ b/sys/arch/arm64/conf/Makefile.arm64
@@ -51,6 +51,9 @@ CWARNFLAGS=   -Werror -Wall -Wimplicit-function-declaration \
                -Wno-constant-conversion -Wno-address-of-packed-member \
                -Wno-unused-but-set-variable -Wno-gnu-folding-constant \
                -Wframe-larger-than=2047
+# XXX Workaround for zlib + clang 15
+# https://github.com/madler/zlib/issues/633
+CWARNFLAGS+=   -Wno-deprecated-non-prototype -Wno-unknown-warning-option
 
 CMACHFLAGS=    -march=armv8-a+nofp+nosimd \
                -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer \
diff --git a/sys/arch/armv7/conf/Makefile.armv7 
b/sys/arch/armv7/conf/Makefile.armv7
index d8fc7710cd6..9ddebf1fbf5 100644
--- a/sys/arch/armv7/conf/Makefile.armv7
+++ b/sys/arch/armv7/conf/Makefile.armv7
@@ -28,6 +28,9 @@ CWARNFLAGS=   -Werror -Wall -Wimplicit-function-declaration \
                -Wno-constant-conversion -Wno-address-of-packed-member \
                -Wno-unused-but-set-variable -Wno-gnu-folding-constant \
                -Wframe-larger-than=2047
+# XXX Workaround for zlib + clang 15
+# https://github.com/madler/zlib/issues/633
+CWARNFLAGS+=   -Wno-deprecated-non-prototype -Wno-unknown-warning-option
 
 CMACHFLAGS=    -msoft-float -march=armv7a
 CMACHFLAGS+=   -ffreestanding ${NOPIE_FLAGS}
diff --git a/sys/arch/i386/conf/Makefile.i386 b/sys/arch/i386/conf/Makefile.i386
index 4dbf184eff0..def71beca31 100644
--- a/sys/arch/i386/conf/Makefile.i386
+++ b/sys/arch/i386/conf/Makefile.i386
@@ -46,6 +46,9 @@ CMACHFLAGS+=  -mretpoline
 NO_INTEGR_AS=  -no-integrated-as
 CWARNFLAGS+=   -Wno-address-of-packed-member -Wno-constant-conversion \
                -Wno-unused-but-set-variable -Wno-gnu-folding-constant
+# XXX Workaround for zlib + clang 15
+# https://github.com/madler/zlib/issues/633
+CWARNFLAGS+=   -Wno-deprecated-non-prototype -Wno-unknown-warning-option
 .endif
 
 DEBUG?=                -g
diff --git a/sys/arch/loongson/conf/Makefile.loongson 
b/sys/arch/loongson/conf/Makefile.loongson
index c34f616551f..9ad17382958 100644
--- a/sys/arch/loongson/conf/Makefile.loongson
+++ b/sys/arch/loongson/conf/Makefile.loongson
@@ -51,6 +51,9 @@ NO_INTEGR_AS= -no-integrated-as
 CMACHFLAGS+=   -fomit-frame-pointer
 CWARNFLAGS+=   -Wno-address-of-packed-member -Wno-constant-conversion \
                -Wno-unused-but-set-variable -Wno-gnu-folding-constant
+# XXX Workaround for zlib + clang 15
+# https://github.com/madler/zlib/issues/633
+CWARNFLAGS+=   -Wno-deprecated-non-prototype -Wno-unknown-warning-option
 .endif
 
 DEBUG?=                -g
diff --git a/sys/arch/macppc/conf/Makefile.macppc 
b/sys/arch/macppc/conf/Makefile.macppc
index bd233e2fdac..f5f9d2fcfb6 100644
--- a/sys/arch/macppc/conf/Makefile.macppc
+++ b/sys/arch/macppc/conf/Makefile.macppc
@@ -46,6 +46,9 @@ COPTIMIZE?=   -Oz
 NO_INTEGR_AS=  -no-integrated-as
 CWARNFLAGS+=   -Wno-address-of-packed-member -Wno-constant-conversion \
                -Wno-unused-but-set-variable -Wno-gnu-folding-constant
+# XXX Workaround for zlib + clang 15
+# https://github.com/madler/zlib/issues/633
+CWARNFLAGS+=   -Wno-deprecated-non-prototype -Wno-unknown-warning-option
 .endif
 
 DEBUG?=                -g
diff --git a/sys/arch/octeon/conf/Makefile.octeon 
b/sys/arch/octeon/conf/Makefile.octeon
index 2af14224682..e0a1279e7fb 100644
--- a/sys/arch/octeon/conf/Makefile.octeon
+++ b/sys/arch/octeon/conf/Makefile.octeon
@@ -49,6 +49,9 @@ NO_INTEGR_AS= -no-integrated-as
 CMACHFLAGS+=   -fomit-frame-pointer
 CWARNFLAGS+=   -Wno-address-of-packed-member -Wno-constant-conversion \
                -Wno-unused-but-set-variable -Wno-gnu-folding-constant
+# XXX Workaround for zlib + clang 15
+# https://github.com/madler/zlib/issues/633
+CWARNFLAGS+=   -Wno-deprecated-non-prototype -Wno-unknown-warning-option
 .endif
 
 DEBUG?=                -g
diff --git a/sys/arch/powerpc64/conf/Makefile.powerpc64 
b/sys/arch/powerpc64/conf/Makefile.powerpc64
index 8e1d768b591..2121e393981 100644
--- a/sys/arch/powerpc64/conf/Makefile.powerpc64
+++ b/sys/arch/powerpc64/conf/Makefile.powerpc64
@@ -51,6 +51,9 @@ CWARNFLAGS=   -Werror -Wall -Wimplicit-function-declaration \
                -Wno-constant-conversion -Wno-address-of-packed-member \
                -Wno-unused-but-set-variable -Wno-gnu-folding-constant \
                -Wframe-larger-than=2047
+# XXX Workaround for zlib + clang 15
+# https://github.com/madler/zlib/issues/633
+CWARNFLAGS+=   -Wno-deprecated-non-prototype -Wno-unknown-warning-option
 
 CMACHFLAGS=    -mabi=elfv2 -msoft-float -mno-altivec -mno-vsx
 CMACHFLAGS+=   -ffreestanding
diff --git a/sys/arch/riscv64/conf/Makefile.riscv64 
b/sys/arch/riscv64/conf/Makefile.riscv64
index 3f3336d0559..365ad14291d 100644
--- a/sys/arch/riscv64/conf/Makefile.riscv64
+++ b/sys/arch/riscv64/conf/Makefile.riscv64
@@ -30,6 +30,9 @@ CWARNFLAGS=   -Werror -Wall -Wimplicit-function-declaration \
                -Wno-constant-conversion -Wno-address-of-packed-member \
                -Wno-unused-but-set-variable -Wno-gnu-folding-constant \
                -Wframe-larger-than=2047
+# XXX Workaround for zlib + clang 15
+# https://github.com/madler/zlib/issues/633
+CWARNFLAGS+=   -Wno-deprecated-non-prototype -Wno-unknown-warning-option
 
 CMACHFLAGS=    -march=rv64gc -mcmodel=medany -mno-relax \
                -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer
diff --git a/sys/arch/sparc64/conf/Makefile.sparc64 
b/sys/arch/sparc64/conf/Makefile.sparc64
index 90913acf125..2de7da222ed 100644
--- a/sys/arch/sparc64/conf/Makefile.sparc64
+++ b/sys/arch/sparc64/conf/Makefile.sparc64
@@ -47,6 +47,9 @@ COPTIMIZE?=   -Oz
 CWARNFLAGS+=   -Wno-unused-command-line-argument
 CWARNFLAGS+=   -Wno-address-of-packed-member -Wno-constant-conversion \
                -Wno-unused-but-set-variable -Wno-gnu-folding-constant
+# XXX Workaround for zlib + clang 15
+# https://github.com/madler/zlib/issues/633
+CWARNFLAGS+=   -Wno-deprecated-non-prototype -Wno-unknown-warning-option
 .endif
 
 DEBUG?=                -g


-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Reply via email to