From 9cd17fca1c6640111217660c8a95d3f6e3a724f8 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 7 Jul 2025 22:44:07 +0700 Subject: [PATCH] make sure that libargon2 is always linked in before libsodium --- src/SPC/builder/extension/password_argon2.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/SPC/builder/extension/password_argon2.php b/src/SPC/builder/extension/password_argon2.php index fd45ca7e..51d2afff 100644 --- a/src/SPC/builder/extension/password_argon2.php +++ b/src/SPC/builder/extension/password_argon2.php @@ -23,4 +23,21 @@ class password_argon2 extends Extension throw new RuntimeException('extension ' . $this->getName() . ' failed sanity check'); } } + + public function patchBeforeMake(): bool + { + if ($this->builder->getLib('libsodium') !== null) { + $extraLibs = getenv('SPC_EXTRA_LIBS'); + if ($extraLibs !== false) { + $extraLibs = str_replace( + [BUILD_LIB_PATH . '/libargon2.a', BUILD_LIB_PATH . '/libsodium.a'], + ['', BUILD_LIB_PATH . '/libargon2.a' . ' ' . BUILD_LIB_PATH . '/libsodium.a'], + $extraLibs, + ); + $extraLibs = trim(preg_replace('/\s+/', ' ', $extraLibs)); // normalize spacing + f_putenv('SPC_EXTRA_LIBS=' . $extraLibs); + } + } + return false; + } }