From a90cc14d624c50b65cff588ddcd982a3a195eb35 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 17 Oct 2023 00:52:49 +0200 Subject: [PATCH] introduce library_path and ld_library_path options to linuxbuilder (some libs require it to load -lstdc++) --- config/lib.json | 8 +++++--- src/SPC/builder/linux/LinuxBuilder.php | 6 +++++- src/SPC/builder/unix/library/libxslt.php | 17 ++++++++++++++++- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/config/lib.json b/config/lib.json index 73f280ab3..98406cfed 100644 --- a/config/lib.json +++ b/config/lib.json @@ -434,7 +434,10 @@ "readline" ], "lib-suggests": [ - "icu" + "icu", + "libxslt", + "ldap", + "zstd" ] }, "pthreads4w": { @@ -464,10 +467,9 @@ "libsnappy.a" ], "headers-unix": [ + "snappy.h", "snappy-c.h", "snappy-sinksource.h", - "snappy.h", - "snappy-stubs-internal.h", "snappy-stubs-public.h" ], "lib-depends": [ diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 5c0770730..d084d1310 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -41,10 +41,14 @@ public function __construct(array $options = []) if (SystemUtil::isMuslDist()) { $this->setOptionIfNotExist('cc', 'gcc'); $this->setOptionIfNotExist('cxx', 'g++'); + $this->setOptionIfNotExist('library_path', ''); + $this->setOptionIfNotExist('ld_library_path', ''); } else { $arch = arch2gnu(php_uname('m')); $this->setOptionIfNotExist('cc', "{$arch}-linux-musl-gcc"); $this->setOptionIfNotExist('cxx', "{$arch}-linux-musl-g++"); + $this->setOptionIfNotExist('library_path', "LIBRARY_PATH=/usr/local/musl/{$arch}-linux-musl/lib"); + $this->setOptionIfNotExist('ld_library_path', "LD_LIBRARY_PATH=/usr/local/musl/{$arch}-linux-musl/lib"); } // set arch (default: current) $this->setOptionIfNotExist('arch', php_uname('m')); @@ -174,7 +178,7 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void shell()->cd(SOURCE_PATH . '/php-src') ->exec( - (!SystemUtil::isMuslDist() ? "LD_LIBRARY_PATH=/usr/local/musl/{$arch}-linux-musl/lib " : '') . + "{$this->getOption('ld_library_path')} " . './configure ' . '--prefix= ' . '--with-valgrind=no ' . diff --git a/src/SPC/builder/unix/library/libxslt.php b/src/SPC/builder/unix/library/libxslt.php index d9e2d0300..847c30e0d 100644 --- a/src/SPC/builder/unix/library/libxslt.php +++ b/src/SPC/builder/unix/library/libxslt.php @@ -4,20 +4,35 @@ namespace SPC\builder\unix\library; +use SPC\builder\linux\library\LinuxLibraryBase; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; +use SPC\exception\WrongUsageException; trait libxslt { /** * @throws FileSystemException * @throws RuntimeException + * @throws WrongUsageException */ protected function build(): void { + $required_libs = ''; + foreach ($this->getDependencies() as $dep) { + if ($dep instanceof LinuxLibraryBase) { + $required_libs .= ' ' . $dep->getStaticLibFiles(); + } + } shell()->cd($this->source_dir) ->exec( - "{$this->builder->configure_env} ./configure " . + "{$this->builder->configure_env} " . + 'CFLAGS="-I' . BUILD_INCLUDE_PATH . '" ' . + "{$this->builder->getOption('library_path')} " . + "{$this->builder->getOption('ld_library_path')} " . + 'LDFLAGS="-L' . BUILD_LIB_PATH . '" ' . + "LIBS='{$required_libs} -lstdc++' " . + './configure ' . '--enable-static --disable-shared ' . '--without-python ' . '--without-mem-debug ' .