mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 04:44:53 +08:00
-fno-sanitize=undefined is enabled in zig by default, not in gcc and clang
This commit is contained in:
parent
ee0de6933f
commit
74849a8d48
@ -71,7 +71,7 @@ CXX=${SPC_LINUX_DEFAULT_CXX}
|
|||||||
AR=${SPC_LINUX_DEFAULT_AR}
|
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"
|
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"
|
||||||
; 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=
|
||||||
@ -98,11 +98,11 @@ 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}"
|
||||||
; LIBS for configuring php
|
; LIBS for configuring php
|
||||||
SPC_CMD_VAR_PHP_CONFIGURE_LIBS="-ldl -lpthread -lm"
|
SPC_CMD_VAR_PHP_CONFIGURE_LIBS="-ldl -lrt -lpthread -lm -lresolv -lutil"
|
||||||
; EXTRA_CFLAGS for `make` php
|
; EXTRA_CFLAGS for `make` php
|
||||||
SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -fno-ident -fPIE ${SPC_DEFAULT_C_FLAGS}"
|
SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -fno-ident -fPIE ${SPC_DEFAULT_C_FLAGS}"
|
||||||
; EXTRA_LIBS for `make` php
|
; EXTRA_LIBS for `make` php
|
||||||
SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS="-ldl -lpthread -lm"
|
SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS="-ldl -lrt -lpthread -lm -lresolv -lutil"
|
||||||
; EXTRA_LDFLAGS for `make` php, can use -release to set a soname for libphp.so
|
; EXTRA_LDFLAGS for `make` php, can use -release to set a soname for libphp.so
|
||||||
SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS=""
|
SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS=""
|
||||||
; EXTRA_LDFLAGS_PROGRAM for `make` php
|
; EXTRA_LDFLAGS_PROGRAM for `make` php
|
||||||
|
|||||||
@ -51,4 +51,15 @@ class opcache extends Extension
|
|||||||
{
|
{
|
||||||
return 'Zend Opcache';
|
return 'Zend Opcache';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function patchBeforeMake(): bool
|
||||||
|
{
|
||||||
|
if (!str_contains(getenv('CC'), 'zig')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// opcache requires -lunwind, the equivalent to -lgcc_s that gcc automatically links
|
||||||
|
$extra_libs = trim(getenv('SPC_EXTRA_LIBS') . ' -lunwind');
|
||||||
|
f_putenv('SPC_EXTRA_LIBS=' . $extra_libs);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -103,6 +103,10 @@ class LinuxBuilder extends UnixBuilderBase
|
|||||||
$zts = '';
|
$zts = '';
|
||||||
}
|
}
|
||||||
$disable_jit = $this->getOption('disable-opcache-jit', false) ? '--disable-opcache-jit ' : '';
|
$disable_jit = $this->getOption('disable-opcache-jit', false) ? '--disable-opcache-jit ' : '';
|
||||||
|
$cc = trim(getenv('CC'));
|
||||||
|
if (!$disable_jit && $this->getExt('opcache') && str_contains($cc, 'zig')) {
|
||||||
|
f_putenv("CC=$cc -fno-sanitize=undefined");
|
||||||
|
}
|
||||||
|
|
||||||
$config_file_path = $this->getOption('with-config-file-path', false) ?
|
$config_file_path = $this->getOption('with-config-file-path', false) ?
|
||||||
('--with-config-file-path=' . $this->getOption('with-config-file-path') . ' ') : '';
|
('--with-config-file-path=' . $this->getOption('with-config-file-path') . ' ') : '';
|
||||||
@ -175,6 +179,9 @@ class LinuxBuilder extends UnixBuilderBase
|
|||||||
}
|
}
|
||||||
$this->buildEmbed();
|
$this->buildEmbed();
|
||||||
}
|
}
|
||||||
|
if (!$disable_jit && $this->getExt('opcache') && str_contains($cc, 'zig')) {
|
||||||
|
f_putenv("CC=$cc");
|
||||||
|
}
|
||||||
if ($enableFrankenphp) {
|
if ($enableFrankenphp) {
|
||||||
logger()->info('building frankenphp');
|
logger()->info('building frankenphp');
|
||||||
$this->buildFrankenphp();
|
$this->buildFrankenphp();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user