mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-22 08:15:35 +08:00
link libgomp statically on glibc
This commit is contained in:
@@ -5,7 +5,6 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\builder\linux\LinuxBuilder;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('imagick')]
|
||||
@@ -13,10 +12,16 @@ class imagick extends Extension
|
||||
{
|
||||
public function patchBeforeMake(): bool
|
||||
{
|
||||
if (PHP_OS_FAMILY !== 'Linux') {
|
||||
return false;
|
||||
}
|
||||
// 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 ';
|
||||
if (getenv('SPC_LIBC') === 'musl') {
|
||||
$extra_libs = trim($extra_libs . ' -lgomp');
|
||||
}
|
||||
if (getenv('SPC_LIBC') === 'glibc') {
|
||||
$extra_libs = trim($extra_libs . ' -l:libgomp.a');
|
||||
}
|
||||
f_putenv('SPC_EXTRA_LIBS=' . $extra_libs);
|
||||
return true;
|
||||
|
||||
@@ -18,8 +18,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 --enable-openmp ';
|
||||
$required_libs = '';
|
||||
$optional_libs = [
|
||||
'libzip' => 'zip',
|
||||
@@ -31,6 +30,7 @@ trait imagemagick
|
||||
'xz' => 'lzma',
|
||||
'zstd' => 'zstd',
|
||||
'freetype' => 'freetype',
|
||||
'bzip2' => 'bzlib',
|
||||
];
|
||||
foreach ($optional_libs as $lib => $option) {
|
||||
$extra .= $this->builder->getLib($lib) ? "--with-{$option} " : "--without-{$option} ";
|
||||
|
||||
@@ -92,7 +92,11 @@ class SPCConfigUtil
|
||||
}
|
||||
// patch: imagick (imagemagick wrapper) for linux needs -lgomp
|
||||
if (in_array('imagemagick', $libraries) && PHP_OS_FAMILY === 'Linux') {
|
||||
$short_name[] = '-lgomp';
|
||||
if (getenv('SPC_LIBC') === 'glibc') {
|
||||
$short_name[] = '-l:libgomp.a';
|
||||
} else {
|
||||
$short_name[] = '-lgomp';
|
||||
}
|
||||
}
|
||||
return implode(' ', $short_name);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user