mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 04:44:53 +08:00
bring back openmp for musl, add TODO to add it back in on glibc
This commit is contained in:
parent
16d82212dd
commit
d21980170e
@ -5,25 +5,25 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\store\FileSystem;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('imagick')]
|
||||
class imagick extends Extension
|
||||
{
|
||||
/**
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function patchBeforeMake(): bool
|
||||
{
|
||||
// replace php_config.h HAVE_OMP_PAUSE_RESOURCE_ALL line to #define HAVE_OMP_PAUSE_RESOURCE_ALL 0
|
||||
FileSystem::replaceFileLineContainsString(SOURCE_PATH . '/php-src/main/php_config.h', 'HAVE_OMP_PAUSE_RESOURCE_ALL', '#define HAVE_OMP_PAUSE_RESOURCE_ALL 0');
|
||||
if (getenv('SPC_LIBC') !== 'musl') {
|
||||
return false;
|
||||
}
|
||||
// imagick with calls omp_pause_all which requires -lgomp, on non-musl we build imagick without openmp
|
||||
$extra_libs = trim(getenv('SPC_EXTRA_LIBS') . ' -lgomp');
|
||||
f_putenv('SPC_EXTRA_LIBS=' . $extra_libs);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getUnixConfigureArg(): string
|
||||
{
|
||||
return '--with-imagick=' . BUILD_ROOT_PATH;
|
||||
$disable_omp = getenv('SPC_LIBC') === 'musl' ? '' : ' ac_cv_func_omp_pause_resource_all=no';
|
||||
return '--with-imagick=' . BUILD_ROOT_PATH . $disable_omp;
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,8 +18,9 @@ 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 ';
|
||||
// TODO: glibc rh 10 toolset's libgomp.a was built without -fPIC -fPIE so we can't use openmp without depending on libgomp.so
|
||||
$openmp = getenv('SPC_LIBC') === 'musl' ? '--enable-openmp' : '--disable-openmp';
|
||||
$extra = "--without-jxl --without-x {$openmp} ";
|
||||
$required_libs = '';
|
||||
$optional_libs = [
|
||||
'libzip' => 'zip',
|
||||
|
||||
@ -90,6 +90,10 @@ class SPCConfigUtil
|
||||
}
|
||||
}
|
||||
}
|
||||
// patch: imagick (imagemagick wrapper) for linux needs libgomp
|
||||
if (in_array('imagemagick', $libraries) && PHP_OS_FAMILY === 'Linux' && getenv('SPC_LIBC') === 'musl') {
|
||||
$short_name[] = '-lgomp';
|
||||
}
|
||||
return implode(' ', $short_name);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user