diff --git a/src/SPC/builder/unix/library/ncurses.php b/src/SPC/builder/unix/library/ncurses.php index cb8c10df..5e1de86f 100644 --- a/src/SPC/builder/unix/library/ncurses.php +++ b/src/SPC/builder/unix/library/ncurses.php @@ -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( diff --git a/src/SPC/builder/unix/library/unixodbc.php b/src/SPC/builder/unix/library/unixodbc.php index da1fc88d..68f2b91d 100644 --- a/src/SPC/builder/unix/library/unixodbc.php +++ b/src/SPC/builder/unix/library/unixodbc.php @@ -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) { diff --git a/src/SPC/store/pkg/GoXcaddy.php b/src/SPC/store/pkg/GoXcaddy.php index 462342db..b4981ad9 100644 --- a/src/SPC/store/pkg/GoXcaddy.php +++ b/src/SPC/store/pkg/GoXcaddy.php @@ -85,7 +85,7 @@ class GoXcaddy extends CustomPackage 'GOBIN' => "{$pkgroot}/go-xcaddy/bin", 'GOPATH' => "{$pkgroot}/go", ]) - ->exec('CC=cc go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest'); + ->exec('CGO_ENABLED=0 go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest'); } public static function getEnvironment(): array diff --git a/src/SPC/toolchain/ClangNativeToolchain.php b/src/SPC/toolchain/ClangNativeToolchain.php index a57b2e8b..17bd8ad7 100644 --- a/src/SPC/toolchain/ClangNativeToolchain.php +++ b/src/SPC/toolchain/ClangNativeToolchain.php @@ -21,6 +21,7 @@ class ClangNativeToolchain implements ToolchainInterface GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_CC=clang'); GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_CXX=clang++'); GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_AR=ar'); + GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_RANLIB=ranlib'); GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_LD=ld'); } diff --git a/src/SPC/toolchain/GccNativeToolchain.php b/src/SPC/toolchain/GccNativeToolchain.php index d8eb8d1a..4da3e398 100644 --- a/src/SPC/toolchain/GccNativeToolchain.php +++ b/src/SPC/toolchain/GccNativeToolchain.php @@ -18,6 +18,7 @@ class GccNativeToolchain implements ToolchainInterface GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_CC=gcc'); GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_CXX=g++'); GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_AR=ar'); + GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_RANLIB=ranlib'); GlobalEnvManager::putenv('SPC_LINUX_DEFAULT_LD=ld'); }