libvips / build-win64-mxe

73 stars 15 forks source link

Add imagequant v2.4.1 (BSD 2-Clause) #24

Closed lovell closed 3 years ago

lovell commented 3 years ago

To mirror the same addition in https://github.com/lovell/sharp-libvips/pull/91

kleisauke commented 3 years ago

Oh, I just did the same within the 8.10.6-beta1 branch. Sorry for causing double work.

lovell commented 3 years ago

Ha ha, no worries, great minds etc.

kleisauke commented 3 years ago

https://github.com/libvips/build-win64-mxe/releases/tag/v8.10.6-beta1 :tada:

lovell commented 3 years ago

Excellent, have made the switch https://github.com/lovell/sharp-libvips/commit/78d9ab42df0dc4cb6584690583ee0ac9e90b51fb

kleisauke commented 3 years ago

Noticed a regression in sharp with the https://github.com/lovell/sharp/runs/2057560209 run, I'll investigate.

lovell commented 3 years ago

Yes, the 'can passthrough AVIF' test is segfaulting on all flavours of Windows - https://github.com/lovell/sharp/blob/master/test/unit/avif.js#L15

To help narrow this down I can refactor/re-order these tests so it does AVIF read first, then AVIF write, then the passthrough test last.

kleisauke commented 3 years ago

I could reproduce this with:

$ vipsheader test/fixtures/sdr_cosmos12920_cicp1-13-6_yuv444_full_qp10.avif
$ echo Exit Code is %errorlevel%
Exit Code is -1073741819

But only for the -static builds (the shared builds are fine), which might suggest that this is a PIC versus non-PIC issue. I'm rebuilding aom with -DCONFIG_PIC=1 for the static builds now (it was only guarded for GCC). https://github.com/libvips/build-win64-mxe/blob/4ce672dcd884bd566f3ff2104daff4b15ecaeaa8/build/aom.mk#L19

kleisauke commented 3 years ago

Rebuilding aom with -DCONFIG_PIC=1 made no difference, but removing the link-time garbage collection flags for all dependencies seems to fix this. Here's a GDB backtrace:

(gdb) run copy sdr_cosmos12920_cicp1-13-6_yuv444_full_qp10.avif x.jpg
Starting program: C:\vips-dev-8.10\bin\vips.exe copy sdr_cosmos12920_cicp1-13-6_yuv444_full_qp10.avif x.jpg
[New Thread 7036.0x3244]
[New Thread 7036.0x2d4c]
[New Thread 7036.0x1c3c]

Thread 1 received signal SIGSEGV, Segmentation fault.
0x0000000180000000 in ?? ()
(gdb) set $pc = *(void **)$rsp
(gdb) set $rsp = $rsp + 8
(gdb) bt
#0  0x0000000180117943 in vips_foreign_load_heif_build (object=0x631000) at /data/mxe/tmp-vips-web-x86_64-w64-mingw32.static.posix.web/vips-8.10.6/libvips/foreign/heifload.c:239
#1  0x0000000000000004 in ?? () at /data/mxe/tmp-llvm-x86_64-w64-mingw32.static.posix.web/llvm-11.1.0.src/libcxx/src/thread.cpp:220
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(gdb) run copy image.jpg x.avif[compression=av1]
Starting program: C:\vips-dev-8.10\bin\vips.exe copy test.jpg x.avif[compression=av1]
[New Thread 1380.0x3610]
[New Thread 1380.0x307c]
[New Thread 1380.0x1ed8]

Thread 1 received signal SIGSEGV, Segmentation fault.
0x0000000180000000 in ?? ()
(gdb) set $pc = *(void **)$rsp
(gdb) set $rsp = $rsp + 8
(gdb) bt
#0  0x000000018011a39f in vips_foreign_save_heif_init (heif=0x603060) at /data/mxe/tmp-vips-web-x86_64-w64-mingw32.static.posix.web/vips-8.10.6/libvips/foreign/heifsave.c:485
#1  0x0000000000603060 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)

https://github.com/libvips/libvips/blob/v8.10.6-beta/libvips/foreign/heifload.c#L239 https://github.com/libvips/libvips/blob/v8.10.6-beta/libvips/foreign/heifsave.c#L485

So both seems to segfault on heif_context_alloc. I'm now trying to rebuild libcxx and libheif with these flags disabled.

kleisauke commented 3 years ago

Commit https://github.com/libvips/build-win64-mxe/commit/9604d79cc7aaa2451bfc2abd52b4ff0227de50d7 fixes this. This regression was introduced in https://github.com/libvips/build-win64-mxe/commit/66d314959ea0031eeb611dde3ab8aec44f751d34 to workaround a possible LLVM COFF linker bug (reported upstream) that causes non-export decorated functions to be discarded when building with link-time garbage collection enabled.

I'm rebuilding all binaries from the 8.10.6-beta2 branch, so expect a new release soon. After that, I'll archive the v8.10.6-beta1 release.

kleisauke commented 3 years ago

Released as https://github.com/libvips/build-win64-mxe/releases/tag/v8.10.6-beta2. It passes the sharp and libvips test suite for me.

lovell commented 3 years ago

Thank you Kleis!

kleisauke commented 3 years ago

Not sure about those Windows 32-bit composite test failures, those binaries worked on my Windows 64-bit PC (I also rely on CI to test these). Perhaps LLVM's C++ vector support (which composite uses) doesn't work properly on Windows 32-bit? I'll investigate it further tomorrow.

lovell commented 3 years ago

Thank you, what you suggest makes sense. Please don't spend too much time on this - dropping 32-bit support would be easier/simpler.