Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add aom and libheif as dependencies #64

Closed
lovell opened this issue Sep 15, 2020 · 17 comments
Closed

Add aom and libheif as dependencies #64

lovell opened this issue Sep 15, 2020 · 17 comments

Comments

@lovell
Copy link
Owner

lovell commented Sep 15, 2020

WIP branch at https://github.com/lovell/sharp-libvips/tree/aom

@lovell
Copy link
Owner Author

lovell commented Oct 2, 2020

Added via commit 942a585

@lovell lovell closed this as completed Oct 2, 2020
@lovell lovell reopened this Oct 2, 2020
@kleisauke
Copy link
Collaborator

It looks like the macOS build is failing due to a missing -laom link, perhaps this dependency has not been added to libheif.pc? The ARMv6 build is failing since it tries to compile aom with NEON instructions, which is unavailable for this architecture (I don't think we can switch -mfpu=vfp to -mfpu=neon).

@lovell
Copy link
Owner Author

lovell commented Oct 3, 2020

I'm preparing a PR for libheif to append its dependencies to Requires.private to allow static builds (such as this).

libaom has a -DENABLE_NEON=no flag we should be able to use to fix the ARMv6 build.

@lovell
Copy link
Owner Author

lovell commented Oct 3, 2020

Upstream PR to allow static builds of libheif at strukturag/libheif#354

@lovell
Copy link
Owner Author

lovell commented Oct 4, 2020

The Linux ARMv6 and macOS builds are now succeeding with the fixes/patches as above.

The ARM64 build failed due to what looks like a temporary networking problem - I'll add some retry logic.

@lovell
Copy link
Owner Author

lovell commented Oct 9, 2020

It looks like the macOS build is able to compile aom and libheif:

...
2020-10-04T11:12:24.3009540Z configure: libaom decoder: yes
2020-10-04T11:12:24.3009960Z configure: libaom encoder: yes
2020-10-04T11:12:24.3010290Z configure: rav1e encoder: no
2020-10-04T11:12:24.3010620Z configure: dav1d decoder: no
2020-10-04T11:12:24.3010970Z configure: libde265 decoder: no
2020-10-04T11:12:24.3011690Z configure: libx265 encoder: no
2020-10-04T11:12:24.3012720Z configure: JPEG output: yes
2020-10-04T11:12:24.3013060Z configure: PNG output: no
2020-10-04T11:12:24.3013810Z configure: GdkPixbuf2 loader: no
2020-10-04T11:12:24.3015150Z configure: Examples: no
2020-10-04T11:12:24.3016330Z configure: Tests:  (tests will cause 'visibility' to be turned off)
2020-10-04T11:12:26.0067890Z config.status: creating libheif.pc
...
2020-10-04T11:12:37.8859680Z  /usr/bin/install -c -m 644 libheif.pc '/Users/runner/work/sharp-libvips/sharp-libvips/target/lib/pkgconfig'

...but libvips can't find libheif:

2020-10-04T11:22:50.5620340Z checking for HEIF... no
2020-10-04T11:22:50.5825840Z configure: WARNING: libheif not found; disabling HEIF support

@kleisauke
Copy link
Collaborator

I think this is probably a mismatch between BSD/macOS sed and GNU sed making the .pc file of libheif unusable, see:
https://stackoverflow.com/a/24276470/10952119

Could you try this?:

diff --git a/build/lin.sh b/build/lin.sh
index 1111111..2222222 100644
--- a/build/lin.sh
+++ b/build/lin.sh
@@ -221,7 +221,7 @@ $CURL https://github.com/strukturag/libheif/releases/download/v${VERSION_HEIF}/l
 cd ${DEPS}/heif
 ./configure --host=${CHOST} --prefix=${TARGET} --enable-static --disable-shared --disable-dependency-tracking \
   --disable-gdk-pixbuf --disable-go --disable-examples --disable-libde265 --disable-x265
-sed -i'.bak' "s/Requires:/Requires:\nRequires.private: aom/" libheif.pc # https://github.com/strukturag/libheif/pull/354
+sed -i'.bak' '/^Requires:/a\'$'\n''Requires.private: aom' libheif.pc # https://github.com/strukturag/libheif/pull/354
 make install-strip
 
 mkdir ${DEPS}/jpeg

@lovell
Copy link
Owner Author

lovell commented Oct 11, 2020

@kleisauke Perfect, thank you, added in commit b771e04.

@kleisauke
Copy link
Collaborator

Oh, it still couldn't find libheif with b771e04, curious. I'll have a look.

@kleisauke
Copy link
Collaborator

Here's the content of libheif.pc when doing that sed append on macOS:

libheif.pc
prefix=/Users/runner/work/libvips-packaging/libvips-packaging/target
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
builtin_h265_decoder=no
builtin_h265_encoder=no
builtin_avif_decoder=yes
builtin_avif_encoder=yes

Name: libheif
Description: HEIF image codec.
URL: https://github.com/strukturag/libheif
Version: 1.9.1
Requires:
Requires.private: aomLibs: -L${exec_prefix}/lib -lheif
Libs.private: -lpthread  -lstdc++
Cflags: -I${prefix}/include

Notice that the append is not newline-terminated, somehow adding a explicit -e seems to resolve this. See kleisauke@2d28dd7 and relevant GitHub action run.

@lovell
Copy link
Owner Author

lovell commented Oct 12, 2020

Thanks, added via commit db3da89. As you say, I'm unsure why this change would fix it given other uses of sed in the same script appear to work as expected. Let's see what happens in https://github.com/lovell/sharp-libvips/actions/runs/301733673

@lovell
Copy link
Owner Author

lovell commented Oct 12, 2020

New AVIF unit tests in sharp are passing on macOS! https://travis-ci.org/github/lovell/sharp/jobs/734938685#L140

(I'm investigating the other failures - looks like libheif is having some C++ ABI compatibility problems segfaulting with musl-based Linux.)

@lovell
Copy link
Owner Author

lovell commented Oct 12, 2020

The segfaults on Alpine appear to relate to https://bugs.chromium.org/p/aomedia/issues/detail?id=2754

@lovell
Copy link
Owner Author

lovell commented Oct 12, 2020

Setting VIPS_MIN_STACK_SIZE=2m appears to fix the aom stack overflow, so it looks like it was a libvips-spawned thread rather than a aom-spawned thread causing this.

@kleisauke
Copy link
Collaborator

kleisauke commented Oct 12, 2020

Great! I'm currently building the Windows binaries for libvips v8.10.2, I expect these to be ready in about an hour three hours.

@kleisauke
Copy link
Collaborator

A bit later than expected; I just released the libvips v8.10.2 Windows binaries.
https://github.com/libvips/build-win64-mxe/releases/tag/v8.10.2

@lovell
Copy link
Owner Author

lovell commented Oct 13, 2020

Marvellous, Windows working perfectly, thanks Kleis! We're ready to request some feedback from others now, via the main sharp issue.

@lovell lovell closed this as completed Oct 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants