Skip to content

Commit deb1c9d

Browse files
committed
Build libavif with -Os and with LTO enabled
1 parent 8a6e5af commit deb1c9d

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

.github/workflows/wheels-dependencies.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ function build_libavif {
129129
fi
130130
fi
131131

132+
local build_type=MinSizeRel
133+
134+
if [[ -z "$IS_ALPINE" ]] && [[ "$MB_ML_VER" == 2014 ]]; then
135+
build_type=Release
136+
fi
137+
132138
local out_dir=$(fetch_unpack https://github.com/AOMediaCodec/libavif/archive/refs/tags/v$LIBAVIF_VERSION.tar.gz libavif-$LIBAVIF_VERSION.tar.gz)
133139
# CONFIG_AV1_DECODER=0 is a flag for libaom (included as a subproject of
134140
# libavif) to disable the compilation and inclusion of aom's AV1 decoder.
@@ -138,14 +144,15 @@ function build_libavif {
138144
-DCMAKE_INSTALL_LIBDIR=$BUILD_PREFIX/lib \
139145
-DCMAKE_INSTALL_NAME_DIR=$BUILD_PREFIX/lib \
140146
-DCMAKE_MACOSX_RPATH=OFF \
141-
-DCMAKE_BUILD_TYPE=Release \
142147
-DBUILD_SHARED_LIBS=ON \
143148
-DAVIF_LIBSHARPYUV=LOCAL \
144149
-DAVIF_LIBYUV=LOCAL \
145150
-DAVIF_CODEC_AOM=LOCAL \
146151
-DCONFIG_AV1_DECODER=0 \
147152
-DAVIF_CODEC_AOM_DECODE=OFF \
148153
-DAVIF_CODEC_DAV1D=LOCAL \
154+
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \
155+
-DCMAKE_BUILD_TYPE=$build_type \
149156
. \
150157
&& make install)
151158
touch libavif-stamp

winbuild/build_prepare.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ def cmd_nmake(
5757

5858

5959
def cmds_cmake(
60-
target: str | tuple[str, ...] | list[str], *params: str, build_dir: str = "."
60+
target: str | tuple[str, ...] | list[str],
61+
*params: str,
62+
build_dir: str = ".",
63+
build_type: str = "Release",
6164
) -> list[str]:
6265
if not isinstance(target, str):
6366
target = " ".join(target)
@@ -66,7 +69,7 @@ def cmds_cmake(
6669
" ".join(
6770
[
6871
"{cmake}",
69-
"-DCMAKE_BUILD_TYPE=Release",
72+
f"-DCMAKE_BUILD_TYPE={build_type}",
7073
"-DCMAKE_VERBOSE_MAKEFILE=ON",
7174
"-DCMAKE_RULE_MESSAGES:BOOL=OFF", # for NMake
7275
"-DCMAKE_C_COMPILER=cl.exe", # for Ninja
@@ -396,6 +399,8 @@ def cmd_msbuild(
396399
"-DAVIF_CODEC_AOM_DECODE=OFF",
397400
"-DAVIF_CODEC_DAV1D=LOCAL",
398401
"-DCMAKE_POLICY_VERSION_MINIMUM=3.5",
402+
"-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON",
403+
build_type="MinSizeRel",
399404
),
400405
cmd_xcopy("include", "{inc_dir}"),
401406
],

0 commit comments

Comments
 (0)