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