Compare commits

...

13 Commits

Author SHA1 Message Date
DubbleClick
fb2d676293 zig doesn't support windows (php doesn't support mingw, zig can only compile mingw) 2025-07-27 01:22:11 +07:00
DubbleClick
944cca709f use $AR in second part of command too 2025-07-27 01:10:21 +07:00
DubbleClick
5b4cbbb669 set permissions 2025-07-27 01:08:34 +07:00
DubbleClick
a8492f06bb use zig's linker too (ends up getting used automatically in most cases, anyway, but better be explicit) 2025-07-27 01:07:54 +07:00
DubbleClick
b6f673cd68 Use $AR instead of ar. Compatibility with -flto(=thin). 2025-07-27 00:59:32 +07:00
DubbleClick
42b4272965 idk 2025-07-26 23:46:36 +07:00
DubbleClick
5beb083c55 no musl check? 2025-07-26 23:39:32 +07:00
DubbleClick
cf529adc79 uh, oh, we forgot to do post init 2025-07-26 23:35:38 +07:00
DubbleClick
5a4da8ed5d install zig before doctor 2025-07-26 23:28:17 +07:00
DubbleClick
bd3092ae90 wtf? 2025-07-26 23:24:59 +07:00
DubbleClick
76094fd305 hello? 2025-07-26 23:20:27 +07:00
DubbleClick
e1edaa24cc "zig-cc" cannot create shared objects according to conftests... 2025-07-26 23:14:29 +07:00
DubbleClick
d0d51ccf82 trigger CI again after clearing cache 2025-07-26 22:23:00 +07:00
6 changed files with 38 additions and 17 deletions

View File

@@ -92,7 +92,7 @@ class LinuxBuilder extends UnixBuilderBase
'CFLAGS' => getenv('SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS'),
'CPPFLAGS' => '-I' . BUILD_INCLUDE_PATH,
'LDFLAGS' => '-L' . BUILD_LIB_PATH,
'LIBS' => SPCTarget::getRuntimeLibs(), // do not pass static libraries here yet, they may contain polyfills for libc functions!
// 'LIBS' => SPCTarget::getRuntimeLibs(), // do not pass static libraries here yet, they may contain polyfills for libc functions!
]);
$embed_type = getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') ?: 'static';
@@ -102,6 +102,11 @@ class LinuxBuilder extends UnixBuilderBase
'Change SPC_CMD_VAR_PHP_EMBED_TYPE to static.'
);
}
$extra = '';
if ($this->getPHPVersionID() < 84000 && $this->getExt('readline') && $this->getLib('libreadline') !== null) {
$extra = 'ac_cv_lib_readline_rl_pending_input=yes';
}
shell()->cd(SOURCE_PATH . '/php-src')
->exec(
$php_configure_env . ' ' .
@@ -116,8 +121,8 @@ class LinuxBuilder extends UnixBuilderBase
$json_74 .
$zts .
$maxExecutionTimers .
$this->makeStaticExtensionArgs() . ' '
// 'ac_cv_lib_readline_rl_pending_input=yes'
$this->makeStaticExtensionArgs() . ' ' .
$extra
);
$this->emitPatchPoint('before-php-make');
@@ -324,7 +329,8 @@ class LinuxBuilder extends UnixBuilderBase
}
if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'static') {
f_passthru('ar -t ' . BUILD_LIB_PATH . "/libphp.a | grep '\\.a$' | xargs -n1 ar d " . BUILD_LIB_PATH . '/libphp.a');
$AR = getenv('AR') ?: 'ar';
f_passthru("{$AR} -t " . BUILD_LIB_PATH . "/libphp.a | grep '\\.a$' | xargs -n1 {$AR} d " . BUILD_LIB_PATH . '/libphp.a');
}
if (!$this->getOption('no-strip', false) && file_exists(BUILD_LIB_PATH . '/' . $realLibName)) {

View File

@@ -267,7 +267,8 @@ class MacOSBuilder extends UnixBuilderBase
->exec(getenv('SPC_CMD_PREFIX_PHP_MAKE') . ' INSTALL_ROOT=' . BUILD_ROOT_PATH . " {$vars} install");
if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'static') {
f_passthru('ar -t ' . BUILD_LIB_PATH . "/libphp.a | grep '\\.a$' | xargs -n1 ar d " . BUILD_LIB_PATH . '/libphp.a');
$AR = getenv('AR') ?: 'ar';
f_passthru("{$AR} -t " . BUILD_LIB_PATH . "/libphp.a | grep '\\.a$' | xargs -n1 {$AR} d " . BUILD_LIB_PATH . '/libphp.a');
}
$this->patchPhpScripts();
}

View File

@@ -45,8 +45,9 @@ trait libxslt
$this->patchPkgconfPrefix(['libexslt.pc', 'libxslt.pc']);
$this->patchLaDependencyPrefix();
$AR = getenv('AR') ?: 'ar';
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");
->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");
}
}

View File

@@ -48,6 +48,7 @@ trait ngtcp2
// on macOS, the static library may contain other static libraries?
// ld: archive member 'libssl.a' not a mach-o file in libngtcp2_crypto_ossl.a
shell()->cd(BUILD_LIB_PATH)->exec("ar -t libngtcp2_crypto_ossl.a | grep '\\.a$' | xargs -n1 ar d libngtcp2_crypto_ossl.a");
$AR = getenv('AR') ?: 'ar';
shell()->cd(BUILD_LIB_PATH)->exec("{$AR} -t libngtcp2_crypto_ossl.a | grep '\\.a$' | xargs -n1 {$AR} d libngtcp2_crypto_ossl.a");
}
}

View File

@@ -16,7 +16,13 @@ class Zig extends CustomPackage
public static function isInstalled(): bool
{
$path = self::getPath();
return file_exists("{$path}/zig") && file_exists("{$path}/zig-cc") && file_exists("{$path}/zig-c++");
$files = ['zig', 'zig-cc', 'zig-c++', 'zig-ar', 'zig-ld.lld', 'zig-ranlib', 'zig-objcopy'];
foreach ($files as $file) {
if (!file_exists("{$path}/{$file}")) {
return false;
}
}
return true;
}
public function getSupportName(): array
@@ -98,12 +104,16 @@ class Zig extends CustomPackage
{
$pkgroot = PKG_ROOT_PATH;
$zig_bin_dir = "{$pkgroot}/{$name}";
$zig_exec = match (PHP_OS_FAMILY) {
'Windows' => "{$zig_bin_dir}/zig.exe",
default => "{$zig_bin_dir}/zig",
};
if (file_exists($zig_exec) && file_exists("{$zig_bin_dir}/zig-cc")) {
$files = ['zig', 'zig-cc', 'zig-c++', 'zig-ar', 'zig-ld.lld', 'zig-ranlib', 'zig-objcopy'];
$all_exist = true;
foreach ($files as $file) {
if (!file_exists("{$zig_bin_dir}/{$file}")) {
$all_exist = false;
break;
}
}
if ($all_exist) {
return;
}
@@ -163,10 +173,12 @@ class Zig extends CustomPackage
$script_content = str_replace('zig cc', 'zig c++', $script_content);
file_put_contents("{$bin_dir}/zig-c++", $script_content);
file_put_contents("{$bin_dir}/zig-ar", "#!/usr/bin/env bash\nexec zig ar $@");
file_put_contents("{$bin_dir}/zig-ld.lld", "#!/usr/bin/env bash\nexec zig ld.lld $@");
file_put_contents("{$bin_dir}/zig-ranlib", "#!/usr/bin/env bash\nexec zig ranlib $@");
file_put_contents("{$bin_dir}/zig-objcopy", "#!/usr/bin/env bash\nexec zig objcopy $@");
chmod("{$bin_dir}/zig-c++", 0755);
chmod("{$bin_dir}/zig-ar", 0755);
chmod("{$bin_dir}/zig-ld.lld", 0755);
chmod("{$bin_dir}/zig-ranlib", 0755);
chmod("{$bin_dir}/zig-objcopy", 0755);
}

View File

@@ -16,9 +16,7 @@ class ZigToolchain implements ToolchainInterface
GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_CC=zig-cc');
GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_CXX=zig-c++');
GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_AR=zig-ar');
GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_LD=zig-cc');
GlobalEnvManager::putenv('RANLIB=zig-ranlib');
GlobalEnvManager::putenv('OBJCOPY=zig-objcopy');
GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_LD=zig-ld.lld');
// Generate additional objects needed for zig toolchain
$paths = ['/usr/lib/gcc', '/usr/local/lib/gcc'];
@@ -61,6 +59,8 @@ class ZigToolchain implements ToolchainInterface
GlobalEnvManager::putenv("SPC_DEFAULT_C_FLAGS={$cflags}");
GlobalEnvManager::putenv("SPC_DEFAULT_CXX_FLAGS={$cxxflags}");
GlobalEnvManager::putenv("SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS={$extraCflags}");
GlobalEnvManager::putenv('RANLIB=zig-ranlib');
GlobalEnvManager::putenv('OBJCOPY=zig-objcopy');
$extra_libs = getenv('SPC_EXTRA_LIBS') ?: '';
if (!str_contains($extra_libs, '-lunwind')) {
// Add unwind library if not already present