mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-19 13:24:51 +08:00
swoole has date time conversion error in c++ code, clang needs -lunwind
This commit is contained in:
parent
2433752273
commit
e1028b0348
@ -72,7 +72,7 @@ AR=${SPC_LINUX_DEFAULT_AR}
|
|||||||
LD=${SPC_LINUX_DEFAULT_LD}
|
LD=${SPC_LINUX_DEFAULT_LD}
|
||||||
; default compiler flags, used in CMake toolchain file, openssl and pkg-config build
|
; default compiler flags, used in CMake toolchain file, openssl and pkg-config build
|
||||||
SPC_DEFAULT_C_FLAGS="-fPIC -Os -Wno-error=date-time -fno-sanitize=undefined"
|
SPC_DEFAULT_C_FLAGS="-fPIC -Os -Wno-error=date-time -fno-sanitize=undefined"
|
||||||
SPC_DEFAULT_CXX_FLAGS="-fPIC -Os"
|
SPC_DEFAULT_CXX_FLAGS="-fPIC -Os -Wno-error=date-time"
|
||||||
; extra libs for building php executable, used in `make` command for building php (this value may changed by extension build process, space separated)
|
; extra libs for building php executable, used in `make` command for building php (this value may changed by extension build process, space separated)
|
||||||
SPC_EXTRA_LIBS=
|
SPC_EXTRA_LIBS=
|
||||||
; upx executable path
|
; upx executable path
|
||||||
@ -96,7 +96,7 @@ SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS="${SPC_DEFAULT_C_FLAGS} -fPIE"
|
|||||||
; CPPFLAGS for configuring php
|
; CPPFLAGS for configuring php
|
||||||
SPC_CMD_VAR_PHP_CONFIGURE_CPPFLAGS="-I${BUILD_INCLUDE_PATH}"
|
SPC_CMD_VAR_PHP_CONFIGURE_CPPFLAGS="-I${BUILD_INCLUDE_PATH}"
|
||||||
; LDFLAGS for configuring php
|
; LDFLAGS for configuring php
|
||||||
SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS="-L${BUILD_LIB_PATH}"
|
SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS="-L${BUILD_LIB_PATH} -L/usr/lib64"
|
||||||
; LIBS for configuring php
|
; LIBS for configuring php
|
||||||
SPC_CMD_VAR_PHP_CONFIGURE_LIBS="-ldl -lrt -lpthread -lm -lresolv -lutil"
|
SPC_CMD_VAR_PHP_CONFIGURE_LIBS="-ldl -lrt -lpthread -lm -lresolv -lutil"
|
||||||
; EXTRA_CFLAGS for `make` php
|
; EXTRA_CFLAGS for `make` php
|
||||||
|
|||||||
@ -80,6 +80,7 @@ class LinuxBuilder extends UnixBuilderBase
|
|||||||
}
|
}
|
||||||
// add libstdc++, some extensions or libraries need it
|
// add libstdc++, some extensions or libraries need it
|
||||||
$extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCpp() ? '-lstdc++ ' : '');
|
$extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCpp() ? '-lstdc++ ' : '');
|
||||||
|
$extra_libs .= (SystemUtil::getCCType(getenv('CC')) === 'clang' ? ' -lunwind' : '');
|
||||||
f_putenv('SPC_EXTRA_LIBS=' . $extra_libs);
|
f_putenv('SPC_EXTRA_LIBS=' . $extra_libs);
|
||||||
$cflags = $this->arch_c_flags;
|
$cflags = $this->arch_c_flags;
|
||||||
f_putenv('CFLAGS=' . $cflags);
|
f_putenv('CFLAGS=' . $cflags);
|
||||||
@ -337,12 +338,16 @@ class LinuxBuilder extends UnixBuilderBase
|
|||||||
|
|
||||||
private function getMakeExtraVars(): array
|
private function getMakeExtraVars(): array
|
||||||
{
|
{
|
||||||
return [
|
$env = [
|
||||||
'EXTRA_CFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'),
|
'EXTRA_CFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'),
|
||||||
'EXTRA_LIBS' => getenv('SPC_EXTRA_LIBS') . ' ' . getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS'),
|
'EXTRA_LIBS' => getenv('SPC_EXTRA_LIBS') . ' ' . getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS'),
|
||||||
'EXTRA_LDFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS'),
|
'EXTRA_LDFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS'),
|
||||||
'EXTRA_LDFLAGS_PROGRAM' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM'),
|
'EXTRA_LDFLAGS_PROGRAM' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM'),
|
||||||
];
|
];
|
||||||
|
if (str_contains(getenv('CC'), 'zig')) {
|
||||||
|
$env['LDFLAGS'] = getenv('LDFLAGS') . ' -L/usr/lib64';
|
||||||
|
}
|
||||||
|
return $env;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -6,6 +6,7 @@ namespace SPC\util;
|
|||||||
|
|
||||||
use SPC\builder\BuilderBase;
|
use SPC\builder\BuilderBase;
|
||||||
use SPC\builder\BuilderProvider;
|
use SPC\builder\BuilderProvider;
|
||||||
|
use SPC\builder\linux\SystemUtil;
|
||||||
use SPC\builder\macos\MacOSBuilder;
|
use SPC\builder\macos\MacOSBuilder;
|
||||||
use SPC\exception\FileSystemException;
|
use SPC\exception\FileSystemException;
|
||||||
use SPC\exception\RuntimeException;
|
use SPC\exception\RuntimeException;
|
||||||
@ -70,6 +71,9 @@ class SPCConfigUtil
|
|||||||
if ($this->builder->hasCpp()) {
|
if ($this->builder->hasCpp()) {
|
||||||
$libs .= $this->builder instanceof MacOSBuilder ? ' -lc++' : ' -lstdc++';
|
$libs .= $this->builder instanceof MacOSBuilder ? ' -lc++' : ' -lstdc++';
|
||||||
}
|
}
|
||||||
|
if (SystemUtil::getCCType(getenv('CC')) === 'clang') {
|
||||||
|
$libs .= ' -lunwind';
|
||||||
|
}
|
||||||
// mimalloc must come first
|
// mimalloc must come first
|
||||||
if (str_contains($libs, BUILD_LIB_PATH . '/mimalloc.o')) {
|
if (str_contains($libs, BUILD_LIB_PATH . '/mimalloc.o')) {
|
||||||
$libs = BUILD_LIB_PATH . '/mimalloc.o ' . str_replace(BUILD_LIB_PATH . '/mimalloc.o', '', $libs);
|
$libs = BUILD_LIB_PATH . '/mimalloc.o ' . str_replace(BUILD_LIB_PATH . '/mimalloc.o', '', $libs);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user