From 2ffb12fa2aa3209b78bfaf5b7c9c7854ec620656 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 22 Feb 2021 11:20:54 +0100 Subject: build against ImageMagick6 and new soname --- 375.patch | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++ PHPINFO | 10 +++--- REFLECTION | 12 +++++++ php-pecl-imagick.spec | 26 ++++++++++++--- 4 files changed, 130 insertions(+), 8 deletions(-) create mode 100644 375.patch diff --git a/375.patch b/375.patch new file mode 100644 index 0000000..80d138d --- /dev/null +++ b/375.patch @@ -0,0 +1,90 @@ +From 8e305b0035df336620f66d0ca4bb2a162a4977ed Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Mon, 25 Jan 2021 08:39:31 +0100 +Subject: [PATCH 1/2] call omp_pause_resource_all when available + +--- + config.m4 | 2 ++ + imagick.c | 8 ++++++++ + 2 files changed, 10 insertions(+) + +diff --git a/config.m4 b/config.m4 +index 15260dc..dfb73a1 100644 +--- a/config.m4 ++++ b/config.m4 +@@ -58,6 +58,8 @@ IM_FIND_IMAGEMAGICK([6.2.4], [$PHP_IMAGICK]) + + LIBS=$old_LIBS + ++ PHP_CHECK_FUNC(omp_pause_resource_all, gomp) ++ + PHP_SUBST(IMAGICK_SHARED_LIBADD) + AC_DEFINE(HAVE_IMAGICK,1,[ ]) + PHP_NEW_EXTENSION(imagick, imagick_file.c imagick_class.c imagickdraw_class.c imagickpixel_class.c imagickpixeliterator_class.c imagick_helpers.c imagick.c imagickkernel_class.c shim_im6_to_im7.c, $ext_shared,, $IM_IMAGEMAGICK_CFLAGS) +diff --git a/imagick.c b/imagick.c +index cd7f98e..5822b36 100644 +--- a/imagick.c ++++ b/imagick.c +@@ -35,6 +35,10 @@ + /* For the countable interface */ + #include "ext/spl/spl_iterators.h" + ++#if HAVE_OMP_PAUSE_RESOURCE_ALL ++#include ++#endif ++ + ZEND_DECLARE_MODULE_GLOBALS(imagick) + + #ifdef IMAGICK_WITH_KERNEL +@@ -3953,6 +3957,9 @@ PHP_MSHUTDOWN_FUNCTION(imagick) + + MagickWandTerminus(); + ++#if HAVE_OMP_PAUSE_RESOURCE_ALL ++ omp_pause_resource_all(omp_pause_hard); ++#else + // Sleep for a bit to hopefully allow OpenMP to + // shut down the threads it created, and avoid a segfault + // This hack won't be needed once everyone is compiling ImageMagick +@@ -3960,6 +3967,7 @@ PHP_MSHUTDOWN_FUNCTION(imagick) + for (i = 0; i < 100 && i < IMAGICK_G(shutdown_sleep_count); i += 1) { + usleep(1000); + } ++#endif + + #if defined(ZTS) && defined(PHP_WIN32) + tsrm_mutex_free(imagick_mutex); + +From 071d6441ba02664e50cf021f8653b8e4d3014608 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Mon, 25 Jan 2021 15:15:14 +0100 +Subject: [PATCH 2/2] improve check + +--- + config.m4 | 13 ++++++++++++- + 1 file changed, 12 insertions(+), 1 deletion(-) + +diff --git a/config.m4 b/config.m4 +index dfb73a1..b92db01 100644 +--- a/config.m4 ++++ b/config.m4 +@@ -58,7 +58,18 @@ IM_FIND_IMAGEMAGICK([6.2.4], [$PHP_IMAGICK]) + + LIBS=$old_LIBS + +- PHP_CHECK_FUNC(omp_pause_resource_all, gomp) ++ AC_MSG_CHECKING(omp_pause_resource_all usability) ++ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ++ #include ++ ]],[[ ++ omp_pause_resource_all(omp_pause_hard); ++ ]])],[ ++ AC_MSG_RESULT(yes) ++ PHP_CHECK_FUNC(omp_pause_resource_all, gomp) ++ PHP_ADD_LIBRARY(gomp,, GMAGICK_SHARED_LIBADD) ++ ],[ ++ AC_MSG_RESULT(no) ++ ]) + + PHP_SUBST(IMAGICK_SHARED_LIBADD) + AC_DEFINE(HAVE_IMAGICK,1,[ ]) diff --git a/PHPINFO b/PHPINFO index b8c0526..9d3d653 100644 --- a/PHPINFO +++ b/PHPINFO @@ -4,10 +4,10 @@ imagick imagick module => enabled imagick module version => 3.4.4 imagick classes => Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator, ImagickKernel -Imagick compiled with ImageMagick version => ImageMagick 6.9.11-27 Q16 x86_64 2020-08-11 https://imagemagick.org -Imagick using ImageMagick library version => ImageMagick 6.9.11-52 Q16 x86_64 2020-12-21 https://imagemagick.org -ImageMagick copyright => © 1999-2020 ImageMagick Studio LLC -ImageMagick release date => 2020-12-21 +Imagick compiled with ImageMagick version => ImageMagick 6.9.12-1 Q16 x86_64 2021-02-21 https://imagemagick.org +Imagick using ImageMagick library version => ImageMagick 6.9.12-1 Q16 x86_64 2021-02-21 https://imagemagick.org +ImageMagick copyright => (C) 1999-2021 ImageMagick Studio LLC +ImageMagick release date => 2021-02-21 ImageMagick number of supported formats: => 247 ImageMagick supported formats => 3FR, 3G2, 3GP, AAI, AI, APNG, ART, ARW, AVI, AVIF, AVS, BGR, BGRA, BGRO, BIE, BMP, BMP2, BMP3, BRF, CAL, CALS, CANVAS, CAPTION, CIN, CIP, CLIP, CMYK, CMYKA, CR2, CR3, CRW, CUR, CUT, DATA, DCM, DCR, DCX, DDS, DFONT, DJVU, DNG, DOT, DPX, DXT1, DXT5, EPDF, EPI, EPS, EPS2, EPS3, EPSF, EPSI, EPT, EPT2, EPT3, ERF, EXR, FAX, FILE, FITS, FRACTAL, FTP, FTS, G3, G4, GIF, GIF87, GRADIENT, GRAY, GRAYA, GROUP4, GV, H, HALD, HDR, HEIC, HISTOGRAM, HRZ, HTM, HTML, HTTP, HTTPS, ICB, ICO, ICON, IIQ, INFO, INLINE, IPL, ISOBRL, ISOBRL6, J2C, J2K, JBG, JBIG, JNG, JNX, JP2, JPC, JPE, JPEG, JPG, JPM, JPS, JPT, JSON, K25, KDC, LABEL, M2V, M4V, MAC, MAGICK, MAP, MASK, MAT, MATTE, MEF, MIFF, MKV, MNG, MONO, MOV, MP4, MPC, MPG, MRW, MSL, MSVG, MTV, MVG, NEF, NRW, NULL, ORF, OTB, OTF, PAL, PALM, PAM, PANGO, PATTERN, PBM, PCD, PCDS, PCL, PCT, PCX, PDB, PDF, PDFA, PEF, PES, PFA, PFB, PFM, PGM, PGX, PICON, PICT, PIX, PJPEG, PLASMA, PNG, PNG00, PNG24, PNG32, PNG48, PNG64, PNG8, PNM, POCKETMOD, PPM, PREVIEW, PS, PS2, PS3, PSB, PSD, PTIF, PWP, RADIAL-GRADIENT, RAF, RAS, RAW, RGB, RGBA, RGBO, RGF, RLA, RLE, RMF, RW2, SCR, SCT, SFW, SGI, SHTML, SIX, SIXEL, SPARSE-COLOR, SR2, SRF, STEGANO, SUN, SVG, SVGZ, TEXT, TGA, THUMBNAIL, TIFF, TIFF64, TILE, TIM, TTC, TTF, TXT, UBRL, UBRL6, UIL, UYVY, VDA, VICAR, VID, VIDEO, VIFF, VIPS, VST, WBMP, WEBM, WEBP, WMF, WMV, WMZ, WPG, X, X3F, XBM, XC, XCF, XPM, XPS, XV, XWD, YCbCr, YCbCrA, YUV @@ -15,3 +15,5 @@ Directive => Local Value => Master Value imagick.locale_fix => 0 => 0 imagick.skip_version_check => 1 => 1 imagick.progress_monitor => 0 => 0 +imagick.set_single_thread => 1 => 1 +imagick.shutdown_sleep_count => 10 => 10 diff --git a/REFLECTION b/REFLECTION index 9f06ef9..d2d66bd 100644 --- a/REFLECTION +++ b/REFLECTION @@ -16,6 +16,12 @@ Extension [ extension #77 imagick version 3.4.4 ] { Entry [ imagick.progress_monitor ] Current = '0' } + Entry [ imagick.set_single_thread ] + Current = '1' + } + Entry [ imagick.shutdown_sleep_count ] + Current = '10' + } } - Classes [10] { @@ -1736,6 +1742,9 @@ Extension [ extension #77 imagick version 3.4.4 ] { } Method [ public method __tostring ] { + + - Parameters [0] { + } } Method [ public method count ] { @@ -2862,6 +2871,9 @@ Extension [ extension #77 imagick version 3.4.4 ] { } Method [ public method getimagehistogram ] { + + - Parameters [0] { + } } Method [ public method getimageinterlacescheme ] { diff --git a/php-pecl-imagick.spec b/php-pecl-imagick.spec index 268876a..96cebdf 100644 --- a/php-pecl-imagick.spec +++ b/php-pecl-imagick.spec @@ -39,7 +39,7 @@ Version: %{upstream_version}%{?upstream_prever:~%{upstream_prever}} Release: 0.9.%{gh_date}git%{gh_short}%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} Source0: https://github.com/%{gh_owner}/%{gh_project}/archive/%{gh_commit}/%{pecl_name}-%{version}-%{gh_short}.tar.gz %else -Release: 15%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} +Release: 17%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} Source0: https://pecl.php.net/get/%{pecl_name}-%{upstream_version}%{?upstream_prever}.tgz %endif License: PHP @@ -50,16 +50,22 @@ Patch1: https://patch-diff.githubusercontent.com/raw/Imagick/imagick/pull Patch2: https://patch-diff.githubusercontent.com/raw/Imagick/imagick/pull/347.patch Patch3: https://patch-diff.githubusercontent.com/raw/Imagick/imagick/pull/348.patch Patch4: https://patch-diff.githubusercontent.com/raw/Imagick/imagick/pull/350.patch +Patch5: https://patch-diff.githubusercontent.com/raw/Imagick/imagick/pull/375.patch BuildRequires: make BuildRequires: %{?dtsprefix}gcc -BuildRequires: %{?scl_prefix}php-devel > 5.4 +BuildRequires: %{?scl_prefix}php-devel BuildRequires: %{?scl_prefix}php-pear BuildRequires: pcre-devel %if %{with im7} BuildRequires: ImageMagick7-devel %else +# Ensure we use the more recent version from remi repo +%if 0%{?fedora} >= 99 || 0%{?rhel} >= 99 BuildRequires: ImageMagick-devel +%else +BuildRequires: ImageMagick6-devel +%endif %endif Requires: %{?scl_prefix}php(zend-abi) = %{php_zend_api} @@ -165,6 +171,7 @@ cd NTS %patch2 -p1 -b .pr347 %patch3 -p1 -b .pr348 %patch4 -p1 -b .pr350 +%patch5 -p1 -b .pr375 extver=$(sed -n '/#define PHP_IMAGICK_VERSION/{s/.* "//;s/".*$//;p}' php_imagick.h) if test "x${extver}" != "x%{upstream_version}%{?upstream_prever}"; then @@ -187,6 +194,10 @@ imagick.skip_version_check=1 ; Used to enable the image progress monitor. ;imagick.progress_monitor=0 + +; multi-thread management +;imagick.set_single_thread => 1 => 1 +;imagick.shutdown_sleep_count => 10 => 10 EOF %if %{with_zts} @@ -271,7 +282,7 @@ cd NTS %{__php} --no-php-ini \ --define extension_dir=%{buildroot}%{php_extdir} \ --define extension=%{pecl_name}.so \ - --modules | grep %{pecl_name} + --modules | grep '^%{pecl_name}$' : upstream test suite for NTS extension TEST_PHP_EXECUTABLE=%{__php} \ @@ -284,7 +295,7 @@ cd ../ZTS %{__ztsphp} --no-php-ini \ --define extension_dir=%{buildroot}%{php_ztsextdir} \ --define extension=%{pecl_name}.so \ - --modules | grep %{pecl_name} + --modules | grep '^%{pecl_name}$' %endif @@ -311,6 +322,13 @@ cd ../ZTS %changelog +* Mon Feb 22 2021 Remi Collet - 3.4.4-17 +- build against ImageMagick6 and new soname + +* Mon Jan 25 2021 Remi Collet - 3.4.4-16 +- add real fix for thread issue from + https://github.com/Imagick/imagick/pull/375 + * Mon Jan 4 2021 Remi Collet - 3.4.4-15 - allow to use ImageMagick7 using --with im7 build option -- cgit