swoole.php and LinuxBuilder.php revert

This commit is contained in:
jingjingxyk 2023-11-29 22:28:20 +08:00
parent 7ee431725c
commit 930849758c
2 changed files with 18 additions and 64 deletions

View File

@ -12,24 +12,13 @@ class swoole extends Extension
{
public function getUnixConfigureArg(): string
{
$arg = ' --enable-swoole ';
$options = '';
if ($this->builder->getLib('postgresql')) {
if (!$this->builder->getExt('pdo_pgsql')) {
$options .= ' --enable-swoole-pgsql ';
}
} else {
$options .= ' --disable-swoole-pgsql ';
}
$arg .= $options;
$arg .= $this->builder->getLib('openssl') ? ' --enable-openssl ' : ' --disable-openssl --without-openssl ';
$arg .= $this->builder->getLib(
'brotli'
) ? (' --enable-brotli --with-brotli-dir=' . BUILD_ROOT_PATH) : ' --disable-brotli ';
$arg = '--enable-swoole';
// pgsql hook is buggy for static php
$arg .= ' --disable-swoole-pgsql';
$arg .= $this->builder->getLib('openssl') ? ' --enable-openssl' : ' --disable-openssl --without-openssl';
$arg .= $this->builder->getLib('brotli') ? (' --enable-brotli --with-brotli-dir=' . BUILD_ROOT_PATH) : ' --disable-brotli';
// swoole curl hook is buggy for php 8.0
$arg .= $this->builder->getExt('curl') && $this->builder->getPHPVersionID(
) >= 80100 ? ' --enable-swoole-curl' : ' --disable-swoole-curl ';
$arg .= $this->builder->getExt('curl') && $this->builder->getPHPVersionID() >= 80100 ? ' --enable-swoole-curl' : ' --disable-swoole-curl';
return $arg;
}
}

View File

@ -46,23 +46,15 @@ class LinuxBuilder extends BuilderBase
f_putenv("CXX={$this->getOption('cxx', "{$arch}-linux-musl-g++")}");
f_putenv("AR={$this->getOption('ar', "{$arch}-linux-musl-ar")}");
f_putenv("LD={$this->getOption('ld', 'ld.gold')}");
f_putenv(
"PATH=/usr/local/musl/bin:/usr/local/musl/{$arch}-linux-musl/bin:" . BUILD_ROOT_PATH . '/bin:' . getenv(
'PATH'
)
);
f_putenv("PATH=/usr/local/musl/bin:/usr/local/musl/{$arch}-linux-musl/bin:" . BUILD_ROOT_PATH . '/bin:' . getenv('PATH'));
// set library path, some libraries need it. (We cannot use `putenv` here, because cmake will be confused)
$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");
// check musl-cross make installed if we use musl-cross-make
if (str_ends_with(getenv('CC'), 'linux-musl-gcc') && !file_exists(
"/usr/local/musl/bin/{$arch}-linux-musl-gcc"
)) {
throw new WrongUsageException(
'musl-cross-make not installed, please install it first. (You can use `doctor` command to install it)'
);
if (str_ends_with(getenv('CC'), 'linux-musl-gcc') && !file_exists("/usr/local/musl/bin/{$arch}-linux-musl-gcc")) {
throw new WrongUsageException('musl-cross-make not installed, please install it first. (You can use `doctor` command to install it)');
}
}
@ -80,10 +72,7 @@ class LinuxBuilder extends BuilderBase
// cflags
$this->arch_c_flags = SystemUtil::getArchCFlags(getenv('CC'), $this->getOption('arch'));
$this->arch_cxx_flags = SystemUtil::getArchCFlags(getenv('CXX'), $this->getOption('arch'));
$this->tune_c_flags = SystemUtil::checkCCFlags(
SystemUtil::getTuneCFlags($this->getOption('arch')),
getenv('CC')
);
$this->tune_c_flags = SystemUtil::checkCCFlags(SystemUtil::getTuneCFlags($this->getOption('arch')), getenv('CC'));
// cmake toolchain
$this->cmake_toolchain_file = SystemUtil::makeCmakeToolchainFile(
'Linux',
@ -144,10 +133,7 @@ class LinuxBuilder extends BuilderBase
if (!$this->getOption('bloat', false)) {
$extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', $this->getAllStaticLibFiles());
} else {
$extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(
' ',
array_map(fn ($x) => "-Xcompiler {$x}", array_filter($this->getAllStaticLibFiles()))
);
$extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", array_filter($this->getAllStaticLibFiles())));
}
// add libstdc++, some extensions or libraries need it
$extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCpp() ? '-lstdc++ ' : '');
@ -226,11 +212,7 @@ class LinuxBuilder extends BuilderBase
if ($enableEmbed) {
logger()->info('building embed');
if ($enableMicro) {
FileSystem::replaceFileStr(
SOURCE_PATH . '/php-src/Makefile',
'OVERALL_TARGET =',
'OVERALL_TARGET = libphp.la'
);
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/Makefile', 'OVERALL_TARGET =', 'OVERALL_TARGET = libphp.la');
}
$this->buildEmbed();
}
@ -277,11 +259,9 @@ class LinuxBuilder extends BuilderBase
SourcePatcher::patchMicro(['phar']);
}
$vars = SystemUtil::makeEnvVarString(
$this->getBuildVars([
'EXTRA_CFLAGS' => $this->getOption('with-micro-fake-cli', false) ? ' -DPHP_MICRO_FAKE_CLI' : '',
])
);
$vars = SystemUtil::makeEnvVarString($this->getBuildVars([
'EXTRA_CFLAGS' => $this->getOption('with-micro-fake-cli', false) ? ' -DPHP_MICRO_FAKE_CLI' : '',
]));
shell()->cd(SOURCE_PATH . '/php-src')
->exec('sed -i "s|//lib|/lib|g" Makefile')
->exec("make -j{$this->concurrency} {$vars} micro");
@ -342,25 +322,10 @@ class LinuxBuilder extends BuilderBase
$cflags = isset($input['EXTRA_CFLAGS']) && $input['EXTRA_CFLAGS'] ? " {$input['EXTRA_CFLAGS']}" : '';
$libs = isset($input['EXTRA_LIBS']) && $input['EXTRA_LIBS'] ? " {$input['EXTRA_LIBS']}" : '';
$ldflags = isset($input['EXTRA_LDFLAGS_PROGRAM']) && $input['EXTRA_LDFLAGS_PROGRAM'] ? " {$input['EXTRA_LDFLAGS_PROGRAM']}" : '';
$export_variables = [];
if ($this->getLib('postgresql') && $this->getExt('swoole')) {
$output = shell()->execWithResult('pkg-config --cflags --static libpq');
if (!empty($output[1][0])) {
$export_variables['LIBPQ_CFLAGS'] = $output[1][0];
}
$output = shell()->execWithResult('pkg-config --libs --static libpq');
if (!empty($output[1][0])) {
$export_variables['LIBPQ_LIBS'] = $output[1][0];
}
}
return array_merge($export_variables, [
'EXTRA_CFLAGS' => "{$optimization} -fno-ident -fPIE " . implode(
' ',
array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)
) . $cflags,
return [
'EXTRA_CFLAGS' => "{$optimization} -fno-ident -fPIE " . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)) . $cflags,
'EXTRA_LIBS' => $this->getOption('extra-libs', '') . $libs,
'EXTRA_LDFLAGS_PROGRAM' => "{$use_lld} -all-static" . $ldflags,
]);
];
}
}