mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-03 23:05:41 +08:00
fixes for thin lto
This commit is contained in:
@@ -10,13 +10,26 @@ use SPC\util\SPCTarget;
|
||||
|
||||
trait ncurses
|
||||
{
|
||||
public function patchBeforeBuild(): bool
|
||||
{
|
||||
// MKlib_gen.sh feeds preprocessor stdout through a sed/awk pipeline into lib_gen.c.
|
||||
// zig-cc/clang leaks the "N warning(s) generated." summary onto stdout (not stderr),
|
||||
// and that line ends up as invalid C in the generated source. Filter it out of the pipe.
|
||||
FileSystem::replaceFileStr(
|
||||
$this->source_dir . '/ncurses/base/MKlib_gen.sh',
|
||||
'$preprocessor $TMP 2>/dev/null \\',
|
||||
"\$preprocessor \$TMP 2>/dev/null \\\n| grep -v ' generated\\.\$' \\",
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function build(): void
|
||||
{
|
||||
$filelist = FileSystem::scanDirFiles(BUILD_BIN_PATH, relative: true);
|
||||
|
||||
UnixAutoconfExecutor::create($this)
|
||||
->appendEnv([
|
||||
'CFLAGS' => '-std=c17',
|
||||
'CFLAGS' => '-std=c17 -w',
|
||||
'LDFLAGS' => SPCTarget::isStatic() ? '-static' : '',
|
||||
])
|
||||
->configure(
|
||||
|
||||
@@ -21,6 +21,14 @@ trait unixodbc
|
||||
'Linux' => '/etc',
|
||||
default => throw new WrongUsageException('Unsupported OS: ' . PHP_OS_FAMILY),
|
||||
};
|
||||
// libltdl is incompatible with -flto (https://bugs.gentoo.org/532672)
|
||||
$stripLto = static fn ($s) => preg_replace('/(^|\s)-flto(=\S+)?(?=\s|$)/', ' ', (string) $s);
|
||||
$origC = $this->builder->arch_c_flags;
|
||||
$origCxx = $this->builder->arch_cxx_flags;
|
||||
$origLd = $this->builder->arch_ld_flags;
|
||||
$this->builder->arch_c_flags = clean_spaces($stripLto($origC));
|
||||
$this->builder->arch_cxx_flags = clean_spaces($stripLto($origCxx));
|
||||
$this->builder->arch_ld_flags = clean_spaces($stripLto($origLd));
|
||||
$make = UnixAutoconfExecutor::create($this)
|
||||
->configure(
|
||||
'--disable-debug',
|
||||
@@ -37,6 +45,10 @@ trait unixodbc
|
||||
);
|
||||
|
||||
$make->make();
|
||||
$this->builder->arch_c_flags = $origC;
|
||||
$this->builder->arch_cxx_flags = $origCxx;
|
||||
$this->builder->arch_ld_flags = $origLd;
|
||||
|
||||
$pkgConfigs = ['odbc.pc', 'odbccr.pc', 'odbcinst.pc'];
|
||||
$this->patchPkgconfPrefix($pkgConfigs);
|
||||
foreach ($pkgConfigs as $file) {
|
||||
|
||||
Reference in New Issue
Block a user