diff --git a/config/lib.json b/config/lib.json index 0d4941f0..36d93a6e 100644 --- a/config/lib.json +++ b/config/lib.json @@ -234,8 +234,8 @@ "ldap": { "source": "ldap", "static-libs-unix": [ - "liblber.a", - "libldap.a" + "libldap.a", + "liblber.a" ], "lib-depends": [ "openssl", diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index f4207dc6..c6342784 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -356,16 +356,18 @@ class Extension { $config = (new SPCConfigUtil($this->builder))->config([$this->getName()], with_dependencies: true); $sharedLibs = ''; - $staticLibs = ''; + $staticLibs = $this->getLibFilesString(); + $staticLibs = str_replace(BUILD_LIB_PATH . '/lib', '-l', $staticLibs); + $staticLibs = str_replace('.a', '', $staticLibs); foreach (explode('-l', $config['libs']) as $lib) { $lib = trim($lib); if ($lib === '') { continue; } $static_lib = 'lib' . $lib . '.a'; - if (file_exists(BUILD_LIB_PATH . '/' . $static_lib)) { + if (file_exists(BUILD_LIB_PATH . '/' . $static_lib) && !str_contains($staticLibs, '-llib')) { $staticLibs .= ' -l' . $lib; - } else { + } elseif (!str_contains($sharedLibs, '-l' . $lib)) { $sharedLibs .= ' -l' . $lib; } } @@ -373,7 +375,7 @@ class Extension 'CFLAGS' => $config['cflags'], 'CXXFLAGS' => $config['cflags'], 'LDFLAGS' => $config['ldflags'], - 'LIBS' => '-Wl,-Bstatic ' . $staticLibs . ' -Wl,-Bdynamic ' . $sharedLibs, + 'LIBS' => '-Wl,-Bstatic -Wl,--start-group ' . $staticLibs . ' -Wl,--end-group -Wl,-Bdynamic ' . $sharedLibs, 'LD_LIBRARY_PATH' => BUILD_LIB_PATH, ]; // prepare configure args diff --git a/src/SPC/builder/unix/library/libxslt.php b/src/SPC/builder/unix/library/libxslt.php index 53061276..8a9bafaa 100644 --- a/src/SPC/builder/unix/library/libxslt.php +++ b/src/SPC/builder/unix/library/libxslt.php @@ -49,5 +49,8 @@ trait libxslt ->execWithEnv('make install DESTDIR=' . escapeshellarg(BUILD_ROOT_PATH)); $this->patchPkgconfPrefix(['libexslt.pc']); $this->patchLaDependencyPrefix(['libxslt.la', 'libexslt.la']); + shell()->cd(BUILD_LIB_PATH) + ->exec("ar -t libxslt.a | grep '\\.a$' | xargs -n1 ar d libxslt.a") + ->exec("ar -t libexslt.a | grep '\\.a$' | xargs -n1 ar d libexslt.a"); } } diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index 6a42c29b..69907556 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -120,7 +120,7 @@ trait postgresql ->exec("rm -rf {$builddir}/lib/*.so") ->exec("rm -rf {$builddir}/lib/*.dylib"); - FileSystem::replaceFileStr(BUILD_LIB_PATH . '/libpq.pc', '-lldap', '-lldap -llber'); + FileSystem::replaceFileStr(BUILD_LIB_PATH . '/pkgconfig/libpq.pc', '-lldap', '-lldap -llber'); } private function getVersion(): string diff --git a/src/SPC/util/SPCConfigUtil.php b/src/SPC/util/SPCConfigUtil.php index 9f75b41f..60db9ba2 100644 --- a/src/SPC/util/SPCConfigUtil.php +++ b/src/SPC/util/SPCConfigUtil.php @@ -31,7 +31,7 @@ class SPCConfigUtil * @param array $libraries Additional library name list * @param bool $include_suggest_ext Include suggested extensions * @param bool $include_suggest_lib Include suggested libraries - * @param mixed $with_dependencies + * @param bool $with_dependencies * @return array{ * cflags: string, * ldflags: string, @@ -43,7 +43,7 @@ class SPCConfigUtil * @throws WrongUsageException * @throws \Throwable */ - public function config(array $extensions = [], array $libraries = [], bool $include_suggest_ext = false, bool $include_suggest_lib = false, $with_dependencies = false): array + public function config(array $extensions = [], array $libraries = [], bool $include_suggest_ext = false, bool $include_suggest_lib = false, bool $with_dependencies = false): array { [$extensions, $libraries] = DependencyUtil::getExtsAndLibs($extensions, $libraries, $include_suggest_ext, $include_suggest_lib);