From ddff7252222f4509484e4dc62b88aa453d6f32c1 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 29 Mar 2025 18:25:38 +0800 Subject: [PATCH] Use fixed location of libgomp.a --- src/SPC/builder/extension/imagick.php | 8 +++++++- src/SPC/util/SPCConfigUtil.php | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/extension/imagick.php b/src/SPC/builder/extension/imagick.php index c8725cb1..5de6beb9 100644 --- a/src/SPC/builder/extension/imagick.php +++ b/src/SPC/builder/extension/imagick.php @@ -21,7 +21,13 @@ class imagick extends Extension $extra_libs = trim($extra_libs . ' -lgomp'); } if (getenv('SPC_LIBC') === 'glibc') { - $extra_libs = trim($extra_libs . ' -l:libgomp.a -l:libgomp_nonshared.a'); + $ld = f_exec('/usr/bin/gcc --print-file-name=libgomp.a', $output, $result_code); + if ($result_code !== 0) { + logger()->error('Cannot find libgomp.a, please install libgomp-dev'); + $extra_libs = trim($extra_libs . ' -l:libgomp.a'); + } else { + $extra_libs = trim($extra_libs . ' ' . $ld); + } } f_putenv('SPC_EXTRA_LIBS=' . $extra_libs); return true; diff --git a/src/SPC/util/SPCConfigUtil.php b/src/SPC/util/SPCConfigUtil.php index ba498d4a..a99ee558 100644 --- a/src/SPC/util/SPCConfigUtil.php +++ b/src/SPC/util/SPCConfigUtil.php @@ -93,7 +93,13 @@ class SPCConfigUtil // patch: imagick (imagemagick wrapper) for linux needs -lgomp if (in_array('imagemagick', $libraries) && PHP_OS_FAMILY === 'Linux') { if (getenv('SPC_LIBC') === 'glibc') { - $short_name[] = '-l:libgomp.a -l:libgomp_nonshared.a'; + $ld = f_exec('/usr/bin/gcc --print-file-name=libgomp.a', $output, $result_code); + if ($result_code !== 0) { + // logger()->error('Cannot find libgomp.a, please install libgomp-dev'); + $short_name[] = '-l:libgomp.a'; + } else { + $short_name[] = $ld; + } } else { $short_name[] = '-lgomp'; }