Build libavif with -Os and with LTO enabled

This commit is contained in:
Frankie Dintino 2025-04-04 17:21:13 -04:00
parent 8a6e5affa1
commit deb1c9dd4a
No known key found for this signature in database
GPG Key ID: 97E295AACFBABD9E
2 changed files with 15 additions and 3 deletions

View File

@ -129,6 +129,12 @@ function build_libavif {
fi
fi
local build_type=MinSizeRel
if [[ -z "$IS_ALPINE" ]] && [[ "$MB_ML_VER" == 2014 ]]; then
build_type=Release
fi
local out_dir=$(fetch_unpack https://github.com/AOMediaCodec/libavif/archive/refs/tags/v$LIBAVIF_VERSION.tar.gz libavif-$LIBAVIF_VERSION.tar.gz)
# CONFIG_AV1_DECODER=0 is a flag for libaom (included as a subproject of
# libavif) to disable the compilation and inclusion of aom's AV1 decoder.
@ -138,7 +144,6 @@ function build_libavif {
-DCMAKE_INSTALL_LIBDIR=$BUILD_PREFIX/lib \
-DCMAKE_INSTALL_NAME_DIR=$BUILD_PREFIX/lib \
-DCMAKE_MACOSX_RPATH=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=ON \
-DAVIF_LIBSHARPYUV=LOCAL \
-DAVIF_LIBYUV=LOCAL \
@ -146,6 +151,8 @@ function build_libavif {
-DCONFIG_AV1_DECODER=0 \
-DAVIF_CODEC_AOM_DECODE=OFF \
-DAVIF_CODEC_DAV1D=LOCAL \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \
-DCMAKE_BUILD_TYPE=$build_type \
. \
&& make install)
touch libavif-stamp

View File

@ -57,7 +57,10 @@ def cmd_nmake(
def cmds_cmake(
target: str | tuple[str, ...] | list[str], *params: str, build_dir: str = "."
target: str | tuple[str, ...] | list[str],
*params: str,
build_dir: str = ".",
build_type: str = "Release",
) -> list[str]:
if not isinstance(target, str):
target = " ".join(target)
@ -66,7 +69,7 @@ def cmds_cmake(
" ".join(
[
"{cmake}",
"-DCMAKE_BUILD_TYPE=Release",
f"-DCMAKE_BUILD_TYPE={build_type}",
"-DCMAKE_VERBOSE_MAKEFILE=ON",
"-DCMAKE_RULE_MESSAGES:BOOL=OFF", # for NMake
"-DCMAKE_C_COMPILER=cl.exe", # for Ninja
@ -396,6 +399,8 @@ DEPS: dict[str, dict[str, Any]] = {
"-DAVIF_CODEC_AOM_DECODE=OFF",
"-DAVIF_CODEC_DAV1D=LOCAL",
"-DCMAKE_POLICY_VERSION_MINIMUM=3.5",
"-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON",
build_type="MinSizeRel",
),
cmd_xcopy("include", "{inc_dir}"),
],