Bug 262634 - graphics/libavif: Fix build with clang 14
Summary: graphics/libavif: Fix build with clang 14
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Dimitry Andric
URL:
Keywords:
Depends on:
Blocks: 261742
  Show dependency treegraph
 
Reported: 2022-03-17 21:07 UTC by Dimitry Andric
Modified: 2022-03-20 22:38 UTC (History)
1 user (show)

See Also:
jbeich: maintainer-feedback+


Attachments
Fix build with clang 14 (2.05 KB, patch)
2022-03-17 21:08 UTC, Dimitry Andric
jbeich: maintainer-approval+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dimitry Andric freebsd_committer freebsd_triage 2022-03-17 21:07:45 UTC
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.
Comment 1 Dimitry Andric freebsd_committer freebsd_triage 2022-03-17 21:08:34 UTC
Created attachment 232532 [details]
Fix build with clang 14
Comment 2 Jan Beich freebsd_committer freebsd_triage 2022-03-17 21:29:57 UTC
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.
Comment 3 Jan Beich freebsd_committer freebsd_triage 2022-03-17 21:56:22 UTC
Upstream PR has been merged, so you may want to change f8fbe288e050 to c18228ff746a then re-run "make makesum". That'd implicitly re-approved.
Comment 4 commit-hook freebsd_committer freebsd_triage 2022-03-19 20:48:20 UTC
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(-)