msys2 / MINGW-packages

Package scripts for MinGW-w64 targets to build under MSYS2.
https://packages.msys2.org
BSD 3-Clause "New" or "Revised" License
2.24k stars 1.21k forks source link

Add libjxl support? #9670

Closed Jehan closed 2 years ago

Jehan commented 2 years ago

GIMP recently added JPEG XL support in its dev version, which uses libjxl.

We'd welcome if msys2 provided a package for libjxl. 😉

novomesk commented 2 years ago

Please wait with the request. I will provide some more information with my experiences with libjxl under MSYS2.

Jehan commented 2 years ago

For the record, @novomesk is the GIMP contributor who implemented the support. Please follow their lead/opinion on this matter rather than mine. 😉

novomesk commented 2 years ago

libjxl uses bundled dependencies, so after unpacking libjxl-0.5.tar.gz, ./deps.sh must be used to download the dependencies or everything should be downloaded with --recursive option.

git clone --depth 1 https://github.com/libjxl/libjxl.git --recursive

Prior building libjxl it is good to have following packages:

mingw64/mingw-w64-x86_64-highway
mingw64/mingw-w64-x86_64-brotli

Suggested configuration: cmake -G Ninja -DCMAKE_INSTALL_PREFIX=/mingw64 -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=OFF -DJPEGXL_ENABLE_MANPAGES=OFF -DJPEGXL_ENABLE_EXAMPLES=OFF -DJPEGXL_ENABLE_PLUGINS=ON -DJPEGXL_ENABLE_SJPEG=OFF -DJPEGXL_ENABLE_SKCMS=ON -DJPEGXL_FORCE_SYSTEM_BROTLI=ON -DJPEGXL_FORCE_SYSTEM_HWY=ON -DCMAKE_CXX_FLAGS="-DHWY_COMPILE_ONLY_SCALAR" ../libjxl-0.5/

I strongly recommend Ninja generator, Unix Makefiles doesn't always work.

libjxl can work with lcms2 or skcms color management systems, but it works better with skcms which is bundled dependency: -DJPEGXL_ENABLE_SKCMS=ON

-DJPEGXL_FORCE_SYSTEM_BROTLI=ON -DJPEGXL_FORCE_SYSTEM_HWY=ON - it will use highway and brotli packages from MSYS2 (instead of bundled dependencies).

-DJPEGXL_ENABLE_PLUGINS=ON this will install image-jxl.xml file for shared-mime-info and also builds GIMP 2.10 plug-in if mingw64/mingw-w64-x86_64-gimp 2.10.24-4 is present.

This plug-in works only for old/stable GIMP 2.10.x but it is incompatible with future GIMP 2.99 which has different plug-in API.

New GIMP 2.99 has different JXL plug-in which is in GIMP's repo now, while the plug-in for old GIMP 2.10 is in libjxl repo.

When we will build GIMP 2.99 we will need to install just libjxl, but it should not require to install old 2.10 mingw64/mingw-w64-x86_64-gimp. Could it be resolved somehow that people who want the plug-in, can get it but at the same time libjxl could be installed without old GIMP 2.10?

-DCMAKE_CXX_FLAGS="-DHWY_COMPILE_ONLY_SCALAR" This is very important to add. This avoids crashes on MSYS2 platform related SIMD AVX2 code.

Most important programs from libjxl are:

cjxl.exe - compressor djxl.exe - decompressor file-jxl.exe - plug-in for old!!! GIMP 2.10

libjxl.dll and libjxl_threads.dll are run-time libraries.

Other optional dependencies (beside libgif, libjpeg, libz, libpng) are: OpenEXR, libwebp.

Jehan commented 2 years ago

Would be nice if MSYS2 had the package. Today, our libjxl build suddenly broke and we have to investigate it now. I would gladly shift this burden to the awesome MSYS2 project! :stuck_out_tongue_closed_eyes:

Biswa96 commented 2 years ago

Can you provide the build recipe and what failed? An issue with libjxl has been reported in another repository.

Jehan commented 2 years ago

Sure.

The (now fixed) build rules: https://gitlab.gnome.org/GNOME/gimp/-/blob/master/build/windows/gitlab-ci/build-deps-msys2.sh#L101

The problem was that MSYS2 updated with a very new version of Highway which apparently did not work well with libjxl 0.6.1.

Therefore the fix was to use a bundled highway instead of the MSYS2 package: https://gitlab.gnome.org/GNOME/gimp/-/merge_requests/586

Biswa96 commented 2 years ago

libjxl can be provided as a mingw package. But if bundled highway is used then it is also installed in the package. A conflicts array can mitigate that. The install directories are not right, let me send a PR in upstream.

Biswa96 commented 2 years ago

I have added a pull request to add the package. Would you like to test the packages from GitHub Actions artifacts of that pull request? The test packages can be downloaded from here https://github.com/msys2/MINGW-packages/actions/runs/1897996417

Jehan commented 2 years ago

I'll need a few days to get to it. But maybe @novomesk will want to do it first (if so, go ahead @novomesk !).

novomesk commented 2 years ago

@Jehan I already wrote my feedback to https://github.com/msys2/MINGW-packages/pull/10859

kmilos commented 2 years ago

Btw, I updated highway to 0.16 as I knew there was no dependency on it at the time. As stated in #10859, I would prefer to package a newer version of libjxl with all the internal dependencies debundled...

Edit: Besides, there have been some not so small changes in the API, and I'd prefer MSYS2 started w/ a most recent/stable version.

Biswa96 commented 2 years ago

FYI. If the build-deps-msys2.sh script is run in msys2/mingw environment, the mingw-w64-$MSYS2_ARCH can be replaced with $MINGW_PACKAGE_PREFIX which is already defined.