From 00e78dd84fbde9581ce3eb1074d59fb8c2525c66 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 25 Jul 2025 09:59:24 +0700 Subject: [PATCH] fix imagick problem, for some reason it must be in the --start-group --end-group --- src/SPC/builder/Extension.php | 2 +- src/SPC/builder/extension/imagick.php | 10 ++++++++++ src/SPC/builder/linux/LinuxBuilder.php | 2 +- src/SPC/util/SPCConfigUtil.php | 15 ++++++--------- src/globals/functions.php | 9 +++++++++ 5 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index b035412c..e83f9dcd 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -529,7 +529,7 @@ class Extension return []; } - private function getStaticAndSharedLibs(string $allLibs): array + protected function getStaticAndSharedLibs(string $allLibs): array { $staticLibString = ''; $sharedLibString = ''; diff --git a/src/SPC/builder/extension/imagick.php b/src/SPC/builder/extension/imagick.php index 514e79b3..3c940289 100644 --- a/src/SPC/builder/extension/imagick.php +++ b/src/SPC/builder/extension/imagick.php @@ -15,4 +15,14 @@ class imagick extends Extension $disable_omp = ' ac_cv_func_omp_pause_resource_all=no'; return '--with-imagick=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH . $disable_omp; } + + protected function getStaticAndSharedLibs(string $allLibs): array + { + [$static, $shared] = parent::getStaticAndSharedLibs($allLibs); + if (str_contains(getenv('PATH'), 'rh/devtoolset-10')) { + $static .= ' -l:libstdc++.a'; + $shared = str_replace('-lstdc++', '', $shared); + } + return [deduplicate_spaces($static), deduplicate_spaces($shared)]; + } } diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 2b79d0f7..d2445892 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -338,7 +338,7 @@ class LinuxBuilder extends UnixBuilderBase $config = (new SPCConfigUtil($this, ['libs_only_deps' => true, 'absolute_libs' => true]))->config($this->ext_list, $this->lib_list, $this->getOption('with-suggested-exts'), $this->getOption('with-suggested-libs')); return [ 'EXTRA_CFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'), - 'EXTRA_LIBS' => $config['libs'] . ' ' . SPCTarget::getRuntimeLibs(), + 'EXTRA_LIBS' => $config['libs'], 'EXTRA_LDFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS'), 'EXTRA_LDFLAGS_PROGRAM' => SPCTarget::isStatic() ? '-all-static -pie' : '-pie', ]; diff --git a/src/SPC/util/SPCConfigUtil.php b/src/SPC/util/SPCConfigUtil.php index 59dfb36f..cf2b4ce4 100644 --- a/src/SPC/util/SPCConfigUtil.php +++ b/src/SPC/util/SPCConfigUtil.php @@ -90,9 +90,6 @@ class SPCConfigUtil if (!str_contains($libs, $libcpp)) { $libs .= " {$libcpp}"; } - if (str_contains(getenv('PATH'), 'rh/devtoolset-10')) { - str_replace('-lstdc++', '-l:libstdc++.a', $libs); - } } if ($this->libs_only_deps) { @@ -101,9 +98,9 @@ class SPCConfigUtil $libs = BUILD_LIB_PATH . '/mimalloc.o ' . str_replace(BUILD_LIB_PATH . '/mimalloc.o', '', $libs); } return [ - 'cflags' => trim(getenv('CFLAGS') . ' ' . $cflags), - 'ldflags' => trim(getenv('LDFLAGS') . ' ' . $ldflags), - 'libs' => trim(getenv('LIBS') . ' ' . $libs), + 'cflags' => deduplicate_spaces(getenv('CFLAGS') . ' ' . $cflags), + 'ldflags' => deduplicate_spaces(getenv('LDFLAGS') . ' ' . $ldflags), + 'libs' => deduplicate_spaces(getenv('LIBS') . ' ' . $libs), ]; } @@ -120,9 +117,9 @@ class SPCConfigUtil } return [ - 'cflags' => trim(getenv('CFLAGS') . ' ' . $cflags), - 'ldflags' => trim(getenv('LDFLAGS') . ' ' . $ldflags), - 'libs' => trim($allLibs), + 'cflags' => deduplicate_spaces(getenv('CFLAGS') . ' ' . $cflags), + 'ldflags' => deduplicate_spaces(getenv('LDFLAGS') . ' ' . $ldflags), + 'libs' => deduplicate_spaces($allLibs), ]; } diff --git a/src/globals/functions.php b/src/globals/functions.php index b45d8c5e..1ad115fc 100644 --- a/src/globals/functions.php +++ b/src/globals/functions.php @@ -242,3 +242,12 @@ function get_pack_replace(): array BUILD_ROOT_PATH => '@build_root_path@', ]; } + +/** + * @param $string + * @return string without double spaces + */ +function deduplicate_spaces($string): string +{ + return trim(preg_replace('/\s+/', ' ', $string)); +}