Skip to content

Commit e1028b0

Browse files
committed
swoole has date time conversion error in c++ code, clang needs -lunwind
1 parent 2433752 commit e1028b0

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

config/env.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ AR=${SPC_LINUX_DEFAULT_AR}
7272
LD=${SPC_LINUX_DEFAULT_LD}
7373
; default compiler flags, used in CMake toolchain file, openssl and pkg-config build
7474
SPC_DEFAULT_C_FLAGS="-fPIC -Os -Wno-error=date-time -fno-sanitize=undefined"
75-
SPC_DEFAULT_CXX_FLAGS="-fPIC -Os"
75+
SPC_DEFAULT_CXX_FLAGS="-fPIC -Os -Wno-error=date-time"
7676
; extra libs for building php executable, used in `make` command for building php (this value may changed by extension build process, space separated)
7777
SPC_EXTRA_LIBS=
7878
; upx executable path
@@ -96,7 +96,7 @@ SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS="${SPC_DEFAULT_C_FLAGS} -fPIE"
9696
; CPPFLAGS for configuring php
9797
SPC_CMD_VAR_PHP_CONFIGURE_CPPFLAGS="-I${BUILD_INCLUDE_PATH}"
9898
; LDFLAGS for configuring php
99-
SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS="-L${BUILD_LIB_PATH}"
99+
SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS="-L${BUILD_LIB_PATH} -L/usr/lib64"
100100
; LIBS for configuring php
101101
SPC_CMD_VAR_PHP_CONFIGURE_LIBS="-ldl -lrt -lpthread -lm -lresolv -lutil"
102102
; EXTRA_CFLAGS for `make` php

src/SPC/builder/linux/LinuxBuilder.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
8080
}
8181
// add libstdc++, some extensions or libraries need it
8282
$extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCpp() ? '-lstdc++ ' : '');
83+
$extra_libs .= (SystemUtil::getCCType(getenv('CC')) === 'clang' ? ' -lunwind' : '');
8384
f_putenv('SPC_EXTRA_LIBS=' . $extra_libs);
8485
$cflags = $this->arch_c_flags;
8586
f_putenv('CFLAGS=' . $cflags);
@@ -337,12 +338,16 @@ protected function buildEmbed(): void
337338

338339
private function getMakeExtraVars(): array
339340
{
340-
return [
341+
$env = [
341342
'EXTRA_CFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'),
342343
'EXTRA_LIBS' => getenv('SPC_EXTRA_LIBS') . ' ' . getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS'),
343344
'EXTRA_LDFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS'),
344345
'EXTRA_LDFLAGS_PROGRAM' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM'),
345346
];
347+
if (str_contains(getenv('CC'), 'zig')) {
348+
$env['LDFLAGS'] = getenv('LDFLAGS') . ' -L/usr/lib64';
349+
}
350+
return $env;
346351
}
347352

348353
/**

src/SPC/util/SPCConfigUtil.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use SPC\builder\BuilderBase;
88
use SPC\builder\BuilderProvider;
9+
use SPC\builder\linux\SystemUtil;
910
use SPC\builder\macos\MacOSBuilder;
1011
use SPC\exception\FileSystemException;
1112
use SPC\exception\RuntimeException;
@@ -70,6 +71,9 @@ public function config(array $extensions = [], array $libraries = [], bool $incl
7071
if ($this->builder->hasCpp()) {
7172
$libs .= $this->builder instanceof MacOSBuilder ? ' -lc++' : ' -lstdc++';
7273
}
74+
if (SystemUtil::getCCType(getenv('CC')) === 'clang') {
75+
$libs .= ' -lunwind';
76+
}
7377
// mimalloc must come first
7478
if (str_contains($libs, BUILD_LIB_PATH . '/mimalloc.o')) {
7579
$libs = BUILD_LIB_PATH . '/mimalloc.o ' . str_replace(BUILD_LIB_PATH . '/mimalloc.o', '', $libs);

0 commit comments

Comments
 (0)