Remove SPC_NO_MUSL_PATH, remove --libc, use SPC_LIBC instead (#642)

* Remove SPC_NO_MUSL_PATH, remove --libc, use SPC_LIBC instead

* Fix tests

* Internally use GNU_ARCH for unified

* Update EXTENSION_DIR comments for env.ini

* Remove redundant -fPIC cflags in curl
This commit is contained in:
Jerry Ma
2025-03-14 18:22:50 +08:00
committed by GitHub
parent 91a3a01c39
commit b4f3657323
32 changed files with 80 additions and 117 deletions

View File

@@ -16,7 +16,7 @@ class icu extends LinuxLibraryBase
{
$cppflags = 'CPPFLAGS="-DU_CHARSET_IS_UTF8=1 -DU_USING_ICU_NAMESPACE=1 -DU_STATIC_IMPLEMENTATION=1 -fPIC -fPIE -fno-ident"';
$cxxflags = 'CXXFLAGS="-std=c++17"';
$ldflags = $this->builder->libc !== 'glibc' ? 'LDFLAGS="-static"' : '';
$ldflags = getenv('SPC_LIBC') !== 'glibc' ? 'LDFLAGS="-static"' : '';
shell()->cd($this->source_dir . '/source')
->exec(
"{$cppflags} {$cxxflags} {$ldflags} " .

View File

@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace SPC\builder\linux\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
class libffi extends LinuxLibraryBase
@@ -12,28 +13,21 @@ class libffi extends LinuxLibraryBase
/**
* @throws RuntimeException
* @throws FileSystemException
*/
public function build(): void
{
[$lib, , $destdir] = SEPARATED_PATH;
/*$env = $this->builder->pkgconf_env . ' CFLAGS="' . $this->builder->arch_c_flags . '"';
$env .= match ($this->builder->libc) {
'musl_wrapper' => " CC='{$this->builder->getOption('cc')} --static -idirafter " . BUILD_INCLUDE_PATH .
($this->builder->getOption('arch') === php_uname('m') ? '-idirafter /usr/include/ ' : '') .
"-idirafter /usr/include/{$this->builder->getOption('arch')}-linux-gnu/'",
'musl', 'glibc' => " CC='{$this->builder->getOption('cc')}'",
default => throw new RuntimeException('unsupported libc: ' . $this->builder->libc),
};*/
$arch = getenv('SPC_ARCH');
shell()->cd($this->source_dir)
->exec(
'./configure ' .
'--enable-static ' .
'--disable-shared ' .
"--host={$this->builder->getOption('arch')}-unknown-linux " .
"--target={$this->builder->getOption('arch')}-unknown-linux " .
"--host={$arch}-unknown-linux " .
"--target={$arch}-unknown-linux " .
'--prefix= ' . // use prefix=/
"--libdir={$lib}"
)

View File

@@ -36,9 +36,9 @@ class libpng extends LinuxLibraryBase
*/
public function build(): void
{
$optimizations = match ($this->builder->getOption('arch')) {
$optimizations = match (getenv('SPC_ARCH')) {
'x86_64' => '--enable-intel-sse ',
'arm64' => '--enable-arm-neon ',
'aarch64' => '--enable-arm-neon ',
default => '',
};
shell()->cd($this->source_dir)

View File

@@ -42,10 +42,11 @@ class openssl extends LinuxLibraryBase
$extra = '';
$ex_lib = '-ldl -pthread';
$arch = getenv('SPC_ARCH');
$env = "CC='" . getenv('CC') . ' -idirafter ' . BUILD_INCLUDE_PATH .
' -idirafter /usr/include/ ' .
' -idirafter /usr/include/' . $this->builder->getOption('arch') . '-linux-gnu/ ' .
' -idirafter /usr/include/' . getenv('SPC_ARCH') . '-linux-gnu/ ' .
"' ";
// lib:zlib
$zlib = $this->builder->getLib('zlib');
@@ -72,7 +73,7 @@ class openssl extends LinuxLibraryBase
'--openssldir=/etc/ssl ' .
"{$zlib_extra}" .
'no-legacy ' .
"linux-{$this->builder->getOption('arch')}{$clang_postfix}"
"linux-{$arch}{$clang_postfix}"
)
->exec('make clean')
->execWithEnv("make -j{$this->builder->concurrency} CNF_EX_LIBS=\"{$ex_lib}\"")