mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-13 20:05:35 +08:00
pass proper optimization flags to a few libs that ignored them
This commit is contained in:
@@ -15,9 +15,11 @@ class icu extends LinuxLibraryBase
|
|||||||
|
|
||||||
protected function build(): void
|
protected function build(): void
|
||||||
{
|
{
|
||||||
|
$userCxxFlags = trim((string) getenv('SPC_DEFAULT_CXX_FLAGS'));
|
||||||
|
$userLdFlags = trim((string) getenv('SPC_DEFAULT_LD_FLAGS'));
|
||||||
$cppflags = 'CPPFLAGS="-DU_CHARSET_IS_UTF8=1 -DU_USING_ICU_NAMESPACE=1 -DU_STATIC_IMPLEMENTATION=1 -DPIC -fPIC"';
|
$cppflags = 'CPPFLAGS="-DU_CHARSET_IS_UTF8=1 -DU_USING_ICU_NAMESPACE=1 -DU_STATIC_IMPLEMENTATION=1 -DPIC -fPIC"';
|
||||||
$cxxflags = 'CXXFLAGS="-std=c++17 -DPIC -fPIC -fno-ident"';
|
$cxxflags = "CXXFLAGS=\"-std=c++17 -DPIC -fPIC -fno-ident {$userCxxFlags}\"";
|
||||||
$ldflags = SPCTarget::isStatic() ? 'LDFLAGS="-static"' : '';
|
$ldflags = SPCTarget::isStatic() ? "LDFLAGS=\"-static {$userLdFlags}\"" : "LDFLAGS=\"{$userLdFlags}\"";
|
||||||
shell()->cd($this->source_dir . '/source')->initializeEnv($this)
|
shell()->cd($this->source_dir . '/source')->initializeEnv($this)
|
||||||
->exec(
|
->exec(
|
||||||
"{$cppflags} {$cxxflags} {$ldflags} " .
|
"{$cppflags} {$cxxflags} {$ldflags} " .
|
||||||
|
|||||||
@@ -57,6 +57,11 @@ class openssl extends LinuxLibraryBase
|
|||||||
$openssl_dir ??= '/etc/ssl';
|
$openssl_dir ??= '/etc/ssl';
|
||||||
$ex_lib = trim($ex_lib);
|
$ex_lib = trim($ex_lib);
|
||||||
|
|
||||||
|
// OpenSSL's Configure ignores env CFLAGS for its target template; pass our flags as extra args after the target.
|
||||||
|
$userCFlags = trim((string) getenv('SPC_DEFAULT_C_FLAGS'));
|
||||||
|
$userLdFlags = trim((string) getenv('SPC_DEFAULT_LD_FLAGS'));
|
||||||
|
$userExtraFlags = trim($userCFlags . ' ' . $userLdFlags);
|
||||||
|
|
||||||
shell()->cd($this->source_dir)->initializeEnv($this)
|
shell()->cd($this->source_dir)->initializeEnv($this)
|
||||||
->exec(
|
->exec(
|
||||||
"{$env} ./Configure no-shared {$extra} " .
|
"{$env} ./Configure no-shared {$extra} " .
|
||||||
@@ -67,7 +72,8 @@ class openssl extends LinuxLibraryBase
|
|||||||
'enable-pie ' .
|
'enable-pie ' .
|
||||||
'no-legacy ' .
|
'no-legacy ' .
|
||||||
'no-tests ' .
|
'no-tests ' .
|
||||||
"linux-{$arch}"
|
"linux-{$arch} " .
|
||||||
|
$userExtraFlags
|
||||||
)
|
)
|
||||||
->exec('make clean')
|
->exec('make clean')
|
||||||
->exec("make -j{$this->builder->concurrency} CNF_EX_LIBS=\"{$ex_lib}\"")
|
->exec("make -j{$this->builder->concurrency} CNF_EX_LIBS=\"{$ex_lib}\"")
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ trait bzip2
|
|||||||
{
|
{
|
||||||
public function patchBeforeBuild(): bool
|
public function patchBeforeBuild(): bool
|
||||||
{
|
{
|
||||||
FileSystem::replaceFileStr($this->source_dir . '/Makefile', 'CFLAGS=-Wall', 'CFLAGS=-fPIC -Wall');
|
$extra = trim((string) getenv('SPC_DEFAULT_C_FLAGS'));
|
||||||
|
FileSystem::replaceFileStr($this->source_dir . '/Makefile', 'CFLAGS=-Wall', "CFLAGS=-Wall {$extra}");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,9 @@ class CraftCommand extends BuildCommand
|
|||||||
public function configure(): void
|
public function configure(): void
|
||||||
{
|
{
|
||||||
$this->addArgument('craft', null, 'Path to craft.yml file', WORKING_DIR . '/craft.yml');
|
$this->addArgument('craft', null, 'Path to craft.yml file', WORKING_DIR . '/craft.yml');
|
||||||
|
$this->addOption('pgi', null, null, 'Forward --pgi to the inner build (instrumented binaries).');
|
||||||
|
$this->addOption('cs-pgi', null, null, 'Forward --cs-pgi to the inner build (cs-instrumented binaries).');
|
||||||
|
$this->addOption('pgo', null, null, 'Forward --pgo to the inner build (use collected profile data).');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle(): int
|
public function handle(): int
|
||||||
@@ -105,6 +108,11 @@ class CraftCommand extends BuildCommand
|
|||||||
if ($craft['craft-options']['build']) {
|
if ($craft['craft-options']['build']) {
|
||||||
$args = [$static_extensions, "--with-libs={$libs}", "--build-shared={$shared_extensions}", ...array_map(fn ($x) => "--build-{$x}", $craft['sapi'])];
|
$args = [$static_extensions, "--with-libs={$libs}", "--build-shared={$shared_extensions}", ...array_map(fn ($x) => "--build-{$x}", $craft['sapi'])];
|
||||||
$this->optionsToArguments($craft['build-options'], $args);
|
$this->optionsToArguments($craft['build-options'], $args);
|
||||||
|
foreach (['pgi', 'cs-pgi', 'pgo'] as $pgoFlag) {
|
||||||
|
if ($this->getOption($pgoFlag)) {
|
||||||
|
$args[] = "--{$pgoFlag}";
|
||||||
|
}
|
||||||
|
}
|
||||||
$retcode = $this->runCommand('build', ...$args);
|
$retcode = $this->runCommand('build', ...$args);
|
||||||
if ($retcode !== 0) {
|
if ($retcode !== 0) {
|
||||||
$this->output->writeln('<error>craft build failed</error>');
|
$this->output->writeln('<error>craft build failed</error>');
|
||||||
|
|||||||
Reference in New Issue
Block a user