From aaa4510f25307fd4d3fae2bc70cd7ea6c9f0cffb Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Fri, 26 Apr 2024 11:00:33 +0800 Subject: [PATCH] Fix linux imagick openmp linking issue (#424) --- src/SPC/builder/extension/imagick.php | 6 +++--- src/SPC/builder/unix/library/imagemagick.php | 2 +- src/globals/test-extensions.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/SPC/builder/extension/imagick.php b/src/SPC/builder/extension/imagick.php index d7721a24..7becb143 100644 --- a/src/SPC/builder/extension/imagick.php +++ b/src/SPC/builder/extension/imagick.php @@ -14,11 +14,11 @@ class imagick extends Extension public function patchBeforeMake(): bool { // imagick may call omp_pause_all which requires -lgomp - $extra_libs = $this->builder->getOption('extra-libs', ''); + $extra_libs = getenv('SPC_EXTRA_LIBS') ?: ''; if ($this->builder instanceof LinuxBuilder) { - $extra_libs .= ' -lgomp '; + $extra_libs .= (empty($extra_libs) ? '' : ' ') . '-lgomp '; } - $this->builder->setOption('extra-libs', $extra_libs); + f_putenv('SPC_EXTRA_LIBS=' . $extra_libs); return true; } diff --git a/src/SPC/builder/unix/library/imagemagick.php b/src/SPC/builder/unix/library/imagemagick.php index ac011e5f..ed08c667 100644 --- a/src/SPC/builder/unix/library/imagemagick.php +++ b/src/SPC/builder/unix/library/imagemagick.php @@ -19,7 +19,7 @@ trait imagemagick protected function build(): void { // TODO: imagemagick build with bzip2 failed with bugs, we need to fix it in the future - $extra = '--without-jxl --without-x --disable-openmp --without-bzlib '; + $extra = '--without-jxl --without-x --enable-openmp --without-bzlib '; $required_libs = ''; $optional_libs = [ 'libzip' => 'zip', diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 4c91a420..a94d50e4 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,8 +13,8 @@ // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'intl,posix', - 'Windows' => 'mbstring,pdo_sqlite,mbregex,curl', + 'Linux', 'Darwin' => 'imagick', + 'Windows' => 'mbstring,pdo_sqlite,mbregex', }; // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`).