Skip to content

Remove openmp support for imagemagick #681

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Mar 31, 2025
Merged
12 changes: 4 additions & 8 deletions src/SPC/builder/extension/imagick.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,16 @@
namespace SPC\builder\extension;

use SPC\builder\Extension;
use SPC\builder\linux\LinuxBuilder;
use SPC\store\FileSystem;
use SPC\util\CustomExt;

#[CustomExt('imagick')]
class imagick extends Extension
{
public function patchBeforeMake(): bool
public function patchBeforeBuildconf(): bool
{
// imagick may call omp_pause_all which requires -lgomp
$extra_libs = getenv('SPC_EXTRA_LIBS') ?: '';
if ($this->builder instanceof LinuxBuilder) {
$extra_libs .= (empty($extra_libs) ? '' : ' ') . '-lgomp ';
}
f_putenv('SPC_EXTRA_LIBS=' . $extra_libs);
// destroy imagick build conf to avoid libgomp build error
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/imagick/config.m4', '#include <omp.h>', '#include <NEVER_INCLUDE_OMP_H>');
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/SPC/builder/unix/library/imagemagick.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 --enable-openmp --without-bzlib ';
$extra = '--without-jxl --without-x --disable-openmp --without-bzlib ';
$required_libs = '';
$optional_libs = [
'libzip' => 'zip',
Expand Down
4 changes: 0 additions & 4 deletions src/SPC/util/SPCConfigUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ private function getLibsString(array $libraries): string
}
}
}
// patch: imagick (imagemagick wrapper) for linux needs -lgomp
if (in_array('imagemagick', $libraries) && PHP_OS_FAMILY === 'Linux') {
$short_name[] = '-lgomp';
}
return implode(' ', $short_name);
}

Expand Down
4 changes: 2 additions & 2 deletions src/globals/test-extensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
// 'macos-13',
// 'macos-14',
'ubuntu-latest',
'windows-latest',
// 'windows-latest',
];

// whether enable thread safe
Expand All @@ -40,7 +40,7 @@

// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
$extensions = match (PHP_OS_FAMILY) {
'Linux', 'Darwin' => 'pgsql,pdo_pgsql',
'Linux', 'Darwin' => 'imagick',
'Windows' => 'pgsql,pdo_pgsql',
};

Expand Down