During an exp-run for llvm 14 (see bug 261742), it turned out that graphics/libavif fails to build with clang 14: /wrkdirs/usr/ports/graphics/libavif/work/libavif-0.9.3/src/alpha.c:227:35: error: mixing declarations and code is incompatible with standards before C99 [-Werror,-Wdeclaration-after-statement] float alphaF = (float)srcAlpha / srcMaxChannelF; ^ /wrkdirs/usr/ports/graphics/libavif/work/libavif-0.9.3/src/alpha.c:242:35: error: mixing declarations and code is incompatible with standards before C99 [-Werror,-Wdeclaration-after-statement] float alphaF = (float)srcAlpha / srcMaxChannelF; ^ /wrkdirs/usr/ports/graphics/libavif/work/libavif-0.9.3/src/alpha.c:258:31: error: mixing declarations and code is incompatible with standards before C99 [-Werror,-Wdeclaration-after-statement] float alphaF = (float)srcAlpha / srcMaxChannelF; ^ /wrkdirs/usr/ports/graphics/libavif/work/libavif-0.9.3/src/alpha.c:335:35: error: mixing declarations and code is incompatible with standards before C99 [-Werror,-Wdeclaration-after-statement] float alphaF = (float)srcAlpha / srcMaxChannelF; ^ /wrkdirs/usr/ports/graphics/libavif/work/libavif-0.9.3/src/alpha.c:351:35: error: mixing declarations and code is incompatible with standards before C99 [-Werror,-Wdeclaration-after-statement] float alphaF = (float)srcAlpha / srcMaxChannelF; ^ /wrkdirs/usr/ports/graphics/libavif/work/libavif-0.9.3/src/alpha.c:368:31: error: mixing declarations and code is incompatible with standards before C99 [-Werror,-Wdeclaration-after-statement] float alphaF = (float)srcAlpha / srcMaxChannelF; ^ /wrkdirs/usr/ports/graphics/libavif/work/libavif-0.9.3/src/alpha.c:397:16: error: mixing declarations and code is incompatible with standards before C99 [-Werror,-Wdeclaration-after-statement] avifResult libyuvResult = avifRGBImagePremultiplyAlphaLibYUV(rgb); ^ /wrkdirs/usr/ports/graphics/libavif/work/libavif-0.9.3/src/alpha.c:508:16: error: mixing declarations and code is incompatible with standards before C99 [-Werror,-Wdeclaration-after-statement] avifResult libyuvResult = avifRGBImageUnpremultiplyAlphaLibYUV(rgb); ^ 8 errors generated. This is because libavif foolishly uses -Weverything, and thus has to chase every new warning introduced by newer compiler versions. I submitted https://github.com/AOMediaCodec/libavif/pull/886 upstream to fix this, and added the corresponding patch to the port.
Created attachment 232532 [details] Fix build with clang 14
Comment on attachment 232532 [details] Fix build with clang 14 Looks OK. Note, attach patches in "git am" compatible format to save time on feedback roundtrips without accidentally losing metadata.
Upstream PR has been merged, so you may want to change f8fbe288e050 to c18228ff746a then re-run "make makesum". That'd implicitly re-approved.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=48c0caf10662a52b27757f20c23f49b35720be15 commit 48c0caf10662a52b27757f20c23f49b35720be15 Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2022-03-19 20:42:57 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2022-03-19 20:47:05 +0000 graphics/libavif: fix build with clang 14 Clang >= 14 warns that mixing declarations and code is incompatible with standards before C99, even if you compile with -std=c99 or -std=gnu99. Add `-Wno-declaration-after-statement` if it is supported, to silence the warning. PR: 262634 Approved by: jbeich (maintainer) Obtained from: https://github.com/AOMediaCodec/libavif/pull/886 MFH: 2022Q1 graphics/libavif/Makefile | 1 + graphics/libavif/distinfo | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-)