SHA256
1
0
forked from pool/libjxl

Accepting request 1043745 from home:alarrosa:branches:graphics

I tested this in a Leap 15.4 system with kimageformats 5.100.0
and gwenview5 and it could open/save jxl files correctly.
The test was built in 
home:alarrosa:branches:openSUSE:Backports:SLE-15-SP4:kimageformats

With this, we can submit jxl support to Backports for SLE15-SP5/
Leap 15.5

- Add patch (applied reversed) to revert the requirement for an
  updated liblcms2 library when we have an older one. This allows
  libjxl to build in SLE15 SP4/SP5 (and Leap 15.4/15.5):
  * 0001-Remove-LCMS-mutex.patch

OBS-URL: https://build.opensuse.org/request/show/1043745
OBS-URL: https://build.opensuse.org/package/show/graphics/libjxl?expand=0&rev=11
This commit is contained in:
Jan Engelhardt 2022-12-19 12:01:00 +00:00 committed by Git OBS Bridge
parent 70e6f6b709
commit 4958be5d5b
3 changed files with 142 additions and 2 deletions

View File

@ -0,0 +1,125 @@
From 057cd06c19875bcf8b5d34d41d92a8abdb856b7c Mon Sep 17 00:00:00 2001
From: Kleis Auke Wolthuizen <github@kleisauke.nl>
Date: Fri, 11 Mar 2022 21:11:24 +0100
Subject: [PATCH] Remove LCMS mutex (#112)
* Remove LCMS mutex
Requires mm2/Little-CMS@a35bacd, which is released in LCMS v2.11.
* Use a threadsafe alternative of gmtime in LCMS
Requires mm2/Little-CMS@68ee2ff, which is released in LCMS v2.13.
LCMS submodule was updated to version 2.13.1 instead.
---
lib/jxl/enc_color_management.cc | 15 ---------------
third_party/CMakeLists.txt | 2 +-
third_party/lcms | 2 +-
third_party/lcms2.cmake | 14 ++++++++++++++
4 files changed, 16 insertions(+), 17 deletions(-)
diff --git a/lib/jxl/enc_color_management.cc b/lib/jxl/enc_color_management.cc
index 419a2b6b68..0a7e21f3ba 100644
--- a/lib/jxl/enc_color_management.cc
+++ b/lib/jxl/enc_color_management.cc
@@ -18,7 +18,6 @@
#include <array>
#include <atomic>
#include <memory>
-#include <mutex>
#include <string>
#include <utility>
@@ -307,14 +306,6 @@ int DoColorSpaceTransform(void* t, size_t thread, const float* buf_src,
// Define to 1 on OS X as a workaround for older LCMS lacking MD5.
#define JXL_CMS_OLD_VERSION 0
-// cms functions (even *THR) are not thread-safe, except cmsDoTransform.
-// To ensure all functions are covered without frequent lock-taking nor risk of
-// recursive lock, we lock in the top-level APIs.
-static std::mutex& LcmsMutex() {
- static std::mutex m;
- return m;
-}
-
#if JPEGXL_ENABLE_SKCMS
JXL_MUST_USE_RESULT CIExy CIExyFromXYZ(const float XYZ[3]) {
@@ -816,9 +807,6 @@ Status ApplyHlgOotf(JxlCms* t, float* JXL_RESTRICT buf, size_t xsize,
} // namespace
-// All functions that call lcms directly (except ColorSpaceTransform::Run) must
-// lock LcmsMutex().
-
Status ColorEncoding::SetFieldsFromICC() {
// In case parsing fails, mark the ColorEncoding as invalid.
SetColorSpace(ColorSpace::kUnknown);
@@ -858,7 +846,6 @@ Status ColorEncoding::SetFieldsFromICC() {
rendering_intent = static_cast<RenderingIntent>(rendering_intent32);
#else // JPEGXL_ENABLE_SKCMS
- std::lock_guard<std::mutex> guard(LcmsMutex());
const cmsContext context = GetContext();
Profile profile;
@@ -920,7 +907,6 @@ void JxlCmsDestroy(void* cms_data) {
if (cms_data == nullptr) return;
JxlCms* t = reinterpret_cast<JxlCms*>(cms_data);
#if !JPEGXL_ENABLE_SKCMS
- std::lock_guard<std::mutex> guard(LcmsMutex());
TransformDeleter()(t->lcms_transform);
#endif
delete t;
@@ -957,7 +943,6 @@ void* JxlCmsInit(void* init_data, size_t num_threads, size_t xsize,
return nullptr;
}
#else // JPEGXL_ENABLE_SKCMS
- std::lock_guard<std::mutex> guard(LcmsMutex());
const cmsContext context = GetContext();
Profile profile_src, profile_dst;
if (!DecodeProfile(context, c_src.ICC(), &profile_src)) {
diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt
index afefbaa80b..095d5a5430 100644
--- a/third_party/CMakeLists.txt
+++ b/third_party/CMakeLists.txt
@@ -146,7 +146,7 @@ if (JPEGXL_ENABLE_SKCMS OR JPEGXL_ENABLE_PLUGINS)
endif ()
if (JPEGXL_ENABLE_VIEWERS OR NOT JPEGXL_ENABLE_SKCMS)
if( NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/lcms/.git" OR JPEGXL_FORCE_SYSTEM_LCMS2 )
- find_package(LCMS2 2.10)
+ find_package(LCMS2 2.13)
if ( NOT LCMS2_FOUND )
message(FATAL_ERROR "Please install lcms2 or run git submodule update --init")
endif ()
#diff --git a/third_party/lcms b/third_party/lcms
#index 65c63bf549..233004ae26 160000
#--- a/third_party/lcms
#+++ b/third_party/lcms
#@@ -1 +1 @@
#-Subproject commit 65c63bf549d78253c14b30b3d62cb668bbbe612c
#+Subproject commit 233004ae26b238b2831ff60eea9e753b99d97906
diff --git a/third_party/lcms2.cmake b/third_party/lcms2.cmake
index 906e777305..c33f877659 100644
--- a/third_party/lcms2.cmake
+++ b/third_party/lcms2.cmake
@@ -60,4 +60,18 @@ target_compile_definitions(lcms2
target_compile_definitions(lcms2
PUBLIC "-DCMS_NO_REGISTER_KEYWORD=1")
+# Ensure that a thread safe alternative of gmtime is used in LCMS
+include(CheckSymbolExists)
+check_symbol_exists(gmtime_r "time.h" HAVE_GMTIME_R)
+if (HAVE_GMTIME_R)
+ target_compile_definitions(lcms2
+ PUBLIC "-DHAVE_GMTIME_R=1")
+else()
+ check_symbol_exists(gmtime_s "time.h" HAVE_GMTIME_S)
+ if (HAVE_GMTIME_S)
+ target_compile_definitions(lcms2
+ PUBLIC "-DHAVE_GMTIME_S=1")
+ endif()
+endif()
+
set_property(TARGET lcms2 PROPERTY POSITION_INDEPENDENT_CODE ON)

View File

@ -1,3 +1,11 @@
-------------------------------------------------------------------
Mon Dec 19 12:35:30 UTC 2022 - Antonio Larrosa <alarrosa@suse.com>
- Add patch (applied reversed) to revert the requirement for an
updated liblcms2 library when we have an older one. This allows
libjxl to build in SLE15 SP4/SP5 (and Leap 15.4/15.5):
* 0001-Remove-LCMS-mutex.patch
-------------------------------------------------------------------
Thu Dec 15 11:32:45 UTC 2022 - Simon Vogl <simon.vogl@gmx.net>

View File

@ -26,10 +26,11 @@ URL: https://jpegxl.info/
#Git-Clone: https://github.com/libjxl/libjxl
Source: https://github.com/libjxl/libjxl/archive/refs/tags/v%version.tar.gz
Source1: baselibs.conf
Patch0: 0001-Remove-LCMS-mutex.patch
BuildRequires: c++_compiler
BuildRequires: cmake
BuildRequires: pkg-config
BuildRequires: pkgconfig(lcms2)
BuildRequires: pkgconfig(lcms2) >= 2.10
BuildRequires: pkgconfig(libbrotlicommon)
BuildRequires: pkgconfig(libbrotlidec)
BuildRequires: pkgconfig(libbrotlienc)
@ -65,7 +66,13 @@ Summary: Command-line utilities to convert from/to JPEG XL
Command-line utilities to convert from/to JPEG XL.
%prep
%autosetup -p1
%setup -q
# libjxl 0.7.0 requires lcms2 >= 2.13, so if we have an older version
# (as in SLE15/Leap) just reverse the patch that adds that dependency
%if %{pkg_vcmp liblcms2-2 < 2.13}
%patch0 -p1 -R
%endif
%build
%cmake -DJPEGXL_FORCE_SYSTEM_HWY=ON -DJPEGXL_FORCE_SYSTEM_BROTLI=ON \