Skip to content
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
215 commits
Select commit Hold shift + click to select a range
2c13eb2
static compilation is not quite working yet
henderkes Apr 30, 2025
b3dacf9
lowercase
henderkes May 6, 2025
f5fffaf
format setEnv§
henderkes May 15, 2025
2897fdd
fix icu for relocatable objects (required by libphp.so building)
henderkes May 15, 2025
03b634b
fix libsodium with -fPIC too
henderkes May 15, 2025
23ae3f6
remove unused option
henderkes May 15, 2025
6fe8b59
ld library path for shared extension building
henderkes May 15, 2025
9557c9e
remove static target for zip
henderkes May 15, 2025
2200179
remove static target for swoole
henderkes May 15, 2025
b402b73
fix copy command with BUILD_MODULES_CONSTANT
henderkes May 15, 2025
1ae27c7
oopsie
henderkes May 15, 2025
8726736
oopsie in opcache
henderkes May 15, 2025
76a9be2
fix shared bz2 build
henderkes May 17, 2025
05e9129
refactor dom out to its own extension, fails shared build
henderkes May 17, 2025
c1e91e1
sockets doesn't install header?!
henderkes May 17, 2025
eab8c27
shared dom ext requires xml
henderkes May 17, 2025
f88c10d
restore buildphp command
henderkes May 18, 2025
2ff3009
-fPIC for unixodbc
henderkes May 18, 2025
1fbd2c1
-fPIC for postgresql CFLAGS, but it's still erroring out
henderkes May 18, 2025
bdd7642
install headers and modules from shared extensions
henderkes May 18, 2025
ea7c145
libxml2 pic...
henderkes May 18, 2025
1179237
Update test-extensions.php
henderkes May 18, 2025
f708907
zstd pic
henderkes May 18, 2025
6b50700
remove dom extra cake
henderkes May 18, 2025
8147433
Update dom.php
henderkes May 18, 2025
54ff717
patch intl standard to c++17
henderkes May 18, 2025
bff99fa
fix imagick shared build
henderkes May 19, 2025
5bd53ed
skip php rebuild if we're only building shared libphp.so
henderkes May 19, 2025
7ba1948
fix pdo_sqlsrv
henderkes May 19, 2025
683371a
fix phar
henderkes May 20, 2025
38dfcda
fix rdkafka
henderkes May 20, 2025
14a0e1a
fix macos
henderkes May 20, 2025
20b6870
rewrite extension_dir
henderkes May 20, 2025
545a653
better phar handling
henderkes May 20, 2025
1e50dac
Update BuildPHPCommand.php
henderkes May 20, 2025
93c6928
fix readline
henderkes May 20, 2025
a9f81dd
remove -fpic and -fpie (-fPIC and -fPIE are still there)
henderkes May 20, 2025
03ca3f4
why do we have prefix= calls instead of prefix=BUILD_ROOT_DIR?
henderkes May 20, 2025
f47daac
cs fix, xml building fails now, unsure why, doesn't seem to import ex…
henderkes May 20, 2025
fa285ec
more patching, xml still not working though
henderkes May 20, 2025
c43423a
replace root cause of the automatic enable
henderkes May 21, 2025
95a2f46
rework building of shared extensions so that builtin extensions are b…
henderkes May 21, 2025
495e868
rework configure args
henderkes May 21, 2025
7698ceb
fixes for more configure args
henderkes May 21, 2025
3f8d297
linter
henderkes May 21, 2025
d349627
linter
henderkes May 21, 2025
9538016
Merge branch 'fix/icurel' into feat/spx
henderkes May 21, 2025
fd5bc54
Merge pull request #721 from crazywhalecc/feat/spx
henderkes May 21, 2025
11c1164
fix spx
henderkes May 21, 2025
3ff31d2
fix undefined references to brotlicommon functions in gd.so
henderkes May 21, 2025
fc7df58
msgpack requires session
henderkes May 21, 2025
af51469
session, not sockets...
henderkes May 21, 2025
b376d16
remove runSharedExtensionCheckUnix
henderkes May 21, 2025
b68d71b
testPHP in windowsbuilder
henderkes May 21, 2025
e3d7969
select all quick button
henderkes May 21, 2025
4a44282
shoehorn the lot in, I don't know how to fix this otherwise
henderkes May 21, 2025
64b6f98
the flag doesn't fix it, the problem is something else
henderkes May 21, 2025
c29ca97
add -lbrotlienc to curl
henderkes May 22, 2025
310be95
new build-with-php key for extensions
henderkes May 22, 2025
3713ae8
extra dependencies for extensions
henderkes May 22, 2025
4b8412d
shared for imagick
henderkes May 22, 2025
b91c83b
linter
henderkes May 22, 2025
6a86b28
fix case of nonexistent pc
henderkes May 22, 2025
bc002d5
linter again
henderkes May 22, 2025
396d4b3
broli, hahahaha
henderkes May 22, 2025
0afe0e5
last problems (?)
henderkes May 22, 2025
5eecd14
linter
henderkes May 22, 2025
2a70b99
change to count of Static Extensions
henderkes May 22, 2025
835fc1e
oops
henderkes May 22, 2025
c2d5afc
mysqli and mysqlnd can also be built shared
henderkes May 22, 2025
5189147
shared ssh2 wants openssl if mysqli or mysqlnd aren't built in
henderkes May 22, 2025
15dc672
remove shared-ext-depends
henderkes May 23, 2025
ed35b65
build all static exts no matter if we're also building shared versions
henderkes May 23, 2025
4ce7374
move zend extension check into config
henderkes May 25, 2025
e568041
\$SPC_CMD_PREFIX_PHP_MAKE -> $SPC_CMD_PREFIX_PHP_MAKE
henderkes May 25, 2025
a9d5dcf
fixer
henderkes May 25, 2025
f83715c
add function description
henderkes May 25, 2025
a8987d4
the what now?
henderkes May 25, 2025
9665473
revert env
henderkes May 25, 2025
14ca782
rename method
henderkes May 25, 2025
234df8d
update spx, works static and shared
henderkes May 25, 2025
c972a94
another way where static extensions would be excluded if also compile…
henderkes May 25, 2025
3662e07
fix spc doctor command, gettext is installed by default, but doesn't …
henderkes May 25, 2025
d833d89
fixes on arch64
henderkes May 25, 2025
e2ea10d
set extension dir before
henderkes May 25, 2025
92acb95
linter
henderkes May 25, 2025
b68701f
updated the static-php spx
henderkes May 27, 2025
4299abf
Update vitepress version, fix selecting all options
crazywhalecc May 30, 2025
3867b99
update doc for spx extension
henderkes May 30, 2025
5382362
only disable openmp for rh devtoolset-10
henderkes May 30, 2025
2a5915f
patched this in ext-spx before, do it here instead
henderkes May 30, 2025
6147721
dont disable openmp macro
henderkes May 30, 2025
78b2a89
--with-pic for libpng
henderkes May 31, 2025
4c12477
--with-pic for libffi
henderkes May 31, 2025
764fdd4
--enable-pic for gettext
henderkes May 31, 2025
4c64707
-ldl and --with-pic for imagemagick
henderkes May 31, 2025
8767181
--with-pic for ldap
henderkes May 31, 2025
2dbcbc6
--with-pic and --enable-pic for other libraries that support them
henderkes May 31, 2025
ad38609
-DPOSITION_INDEPENDENT_CODE=ON
henderkes May 31, 2025
3052b1c
change extension_dir, the env variable only has an effect during comp…
henderkes May 31, 2025
8312ce4
add ext-xz and ext-brotli
henderkes May 31, 2025
c44b8b1
test xz and brotli as well
henderkes May 31, 2025
61837f0
more os tests
henderkes May 31, 2025
93eb637
Merge branch 'main' into fix/icurel
henderkes May 31, 2025
3bc5ac2
space
henderkes May 31, 2025
55b4ba5
fix file_exists check in printing shared extension folder
henderkes Jun 1, 2025
febf9b1
full test suite for shared extensions
henderkes Jun 1, 2025
da7a125
librdkafka needs "which" to be installed
henderkes Jun 1, 2025
396ddd3
cs fix
henderkes Jun 1, 2025
5ae5a3d
cs fix
henderkes Jun 1, 2025
7c009b6
add rdkafka
henderkes Jun 1, 2025
8b98792
zts of course
henderkes Jun 1, 2025
108bf34
craft needs to download shared extensions too
henderkes Jun 2, 2025
ed87a7c
don't force invalidate php-src if the download option is explicitly p…
henderkes Jun 2, 2025
c53b06c
shared-extensions instead of build-shared
henderkes Jun 2, 2025
4b0fa94
stan
henderkes Jun 2, 2025
6b689f1
explicitly pass env to process handler, fails in docker otherwise (??…
henderkes Jun 2, 2025
a9d37bb
add source patch for ffi on centos 7
henderkes Jun 4, 2025
161a553
-release (soname) compilation support for linux shared embed
henderkes Jun 5, 2025
e219111
tests for brotli and xz
henderkes Jun 5, 2025
ad8581d
Merge remote-tracking branch 'origin/main' into fix/icurel
henderkes Jun 5, 2025
94e31f1
doms
henderkes Jun 5, 2025
e022a45
only apply ffi patch at version >= 8.3.16
henderkes Jun 5, 2025
86541b1
only apply ffi patch at version >= 8.3.16
henderkes Jun 5, 2025
17b4c18
accidental space
henderkes Jun 5, 2025
01a79fc
unify tests for all compression extensions
henderkes Jun 5, 2025
8b94a71
cs fix
henderkes Jun 5, 2025
31652e8
I HATE WINDOWS
henderkes Jun 5, 2025
57b527c
gzencode, of course
henderkes Jun 5, 2025
861010a
trim envs
henderkes Jun 6, 2025
3b9670c
fpic for liblzma
henderkes Jun 6, 2025
7c4c8c6
cache libc version
henderkes Jun 6, 2025
3761a9c
brotli was matching /dev/null, which should not be used
henderkes Jun 6, 2025
1479bef
brotli was matching /dev/null, which should not be used
henderkes Jun 6, 2025
dbc7ff5
Merge pull request #746 from crazywhalecc/fix/embed-soname
henderkes Jun 6, 2025
3007234
Merge remote-tracking branch 'origin/main' into fix/icurel
henderkes Jun 6, 2025
621e396
Merge branch 'fix/icurel' of https://github.com/crazywhalecc/static-p…
henderkes Jun 6, 2025
4582e1f
cs fix
henderkes Jun 6, 2025
b6a1182
patch la files
henderkes Jun 6, 2025
a682126
apply suggestions
henderkes Jun 6, 2025
715650c
add "which" to spc doctor
henderkes Jun 6, 2025
0d91ad7
remove buildUnixShared method from sqlsrv
henderkes Jun 6, 2025
f29ee95
remove buildUnixShared method from xhprof
henderkes Jun 6, 2025
635fbae
Merge remote-tracking branch 'origin/main' into fix/icurel
henderkes Jun 6, 2025
111de20
fix cs
henderkes Jun 6, 2025
e31942b
uncommented buildphp, haha
henderkes Jun 7, 2025
2dde537
makeCmakeArgs
henderkes Jun 7, 2025
2a39fb0
Merge remote-tracking branch 'origin/main' into fix/icurel
henderkes Jun 7, 2025
a6ea499
ngtcp2 patch la files
henderkes Jun 7, 2025
a302547
fix libyaml install dir
henderkes Jun 7, 2025
0b8543e
thread safety for pgsql?
henderkes Jun 7, 2025
23be548
thread safety for pgsql (in version 17, remove this entirely)
henderkes Jun 7, 2025
e5f483d
libtidy uses strange cmake options
henderkes Jun 7, 2025
2093b4e
cs fix
henderkes Jun 7, 2025
f4771b4
test macos too
henderkes Jun 7, 2025
bb1f086
pq forgets to link against -llber, only links against -lldap
henderkes Jun 7, 2025
08d3849
cs fix
henderkes Jun 7, 2025
2f53915
fix ldap for postgresql
henderkes Jun 7, 2025
0ebd44b
bring back zstd cmake flags
henderkes Jun 7, 2025
a99c4a3
remove getLibFilesString from Extension buildUnixShared
henderkes Jun 8, 2025
6ed440d
refactor out method to get static and shared libraries
henderkes Jun 8, 2025
53eb6dc
cs fix hook isn't working on windows
henderkes Jun 8, 2025
fa744bb
merge cmake changes from master into icurel
henderkes Jun 9, 2025
187d51e
-DPOSITION_INDEPENDENT_CODE=ON for cmake
henderkes Jun 9, 2025
20f222d
post merge fixes
henderkes Jun 9, 2025
c9e9119
remove gd from static extension test
henderkes Jun 9, 2025
978975d
import class
henderkes Jun 9, 2025
aedcc86
fix cmake minimum version for libtidy
henderkes Jun 9, 2025
684b5d4
remove alpine tests for now https://github.com/php/php-src/pull/18779
henderkes Jun 9, 2025
7202514
Add autoconf executor
crazywhalecc Jun 9, 2025
8b09e1a
Fix zlib autoconf builder
crazywhalecc Jun 9, 2025
1b08a25
Add --enable-pic for default autoconf args
crazywhalecc Jun 9, 2025
8896d47
Add tests for autoconf libs
crazywhalecc Jun 9, 2025
0ed6f29
Add tests for autoconf libs
crazywhalecc Jun 9, 2025
4c8f9e1
Remove attr and libacl tests
crazywhalecc Jun 9, 2025
ae56bed
Fix ncurses build
crazywhalecc Jun 9, 2025
25c2baf
Fix brotlienc pkgconfig patching
crazywhalecc Jun 9, 2025
9e8119e
Fix ldap build
crazywhalecc Jun 10, 2025
6cb2cdd
Add ignoreConfigureArgs for UnixAutoconfExecutor
crazywhalecc Jun 10, 2025
11f2130
Fix libxslt lib compile bug
crazywhalecc Jun 10, 2025
da45aa7
Fix ngtcp2 and libheif build missing lib bug
crazywhalecc Jun 10, 2025
474fe63
Add optional lib log
crazywhalecc Jun 10, 2025
b320eb8
Rename ignoreConfigureArgs to removeConfigureArgs
crazywhalecc Jun 10, 2025
145fe7c
Remove curl libbrotli patches
crazywhalecc Jun 10, 2025
9ed62b0
make patchLaDependencyPrefix argument optional, remove cleanLaFiles
henderkes Jun 10, 2025
dcdd167
Merge remote-tracking branch 'origin/fix/icurel' into fix/icurel
henderkes Jun 10, 2025
6d3e2d9
revert extension tests
henderkes Jun 10, 2025
63656cf
cs fixer, of course
henderkes Jun 10, 2025
c3aa735
update tests to all static
henderkes Jun 11, 2025
311de93
fix gomp error
henderkes Jun 11, 2025
a7771e9
enable musl too
henderkes Jun 11, 2025
a503aaa
-lomp on macos
henderkes Jun 11, 2025
d322be1
err, add it back in
henderkes Jun 11, 2025
518ed3a
don't add -lomp on macos (not required)
henderkes Jun 11, 2025
a1ccddb
Test macOS 15 for all php version
crazywhalecc Jun 11, 2025
70b9186
Lets' fuzz it
crazywhalecc Jun 11, 2025
80f2912
Fix rdkafka with zstd build failed bug, reset test-extensions
crazywhalecc Jun 11, 2025
cec5274
Re-test
crazywhalecc Jun 11, 2025
62a5813
compatibility with RHEL 10?
henderkes Jun 11, 2025
4be1e75
dirty as fuck, I don't understand why AMQP_SHARED_LIBADD is not avail…
henderkes Jun 11, 2025
0e09228
err
henderkes Jun 11, 2025
78b3778
err
henderkes Jun 11, 2025
9f35c95
cs fix
henderkes Jun 11, 2025
84fb354
this is not needed anymore
henderkes Jun 11, 2025
c0ea47c
I really got redundant test error
crazywhalecc Jun 11, 2025
2ea8a7e
Fix macOS embed re-archive bug
crazywhalecc Jun 11, 2025
e0734fe
Add frameworks for extension
crazywhalecc Jun 11, 2025
28e5e58
Revert ext-matrix-tests and test-extensions
crazywhalecc Jun 11, 2025
e2efaab
fix attempted ar deletions when building shared libphp
henderkes Jun 12, 2025
bfba598
Fix glfw source path
crazywhalecc Jun 12, 2025
089b94d
add fastlz, libmemcached for linux
henderkes Jun 12, 2025
fcfbb59
fix phpstan
henderkes Jun 12, 2025
01ab0d3
update default flags
henderkes Jun 12, 2025
d9f7aa7
update default env (shouldn't we pass -fpic to default c flags on mac…
henderkes Jun 12, 2025
0ee9a0c
oops, don't pass -fpic to CPPflags, I misread it as CXXflags
henderkes Jun 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ docker/source/
# default source extract directory
/source/

# built by shared embed tests
/locale/

# default source download directory
/downloads/

Expand Down
19 changes: 9 additions & 10 deletions config/ext.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,6 @@
"Linux": "partial",
"BSD": "wip"
},
"target": [
"static",
"shared"
],
"notes": true,
"arg-type": "custom",
"type": "builtin",
Expand Down Expand Up @@ -414,13 +410,19 @@
},
"mysqli": {
"type": "builtin",
"target": [
"static"
],
"arg-type": "with",
"ext-depends": [
"mysqlnd"
]
},
"mysqlnd": {
"type": "builtin",
"target": [
"static"
],
"arg-type-windows": "with",
"lib-depends": [
"zlib"
Expand Down Expand Up @@ -454,6 +456,9 @@
"openssl": {
"notes": true,
"type": "builtin",
"target": [
"static"
],
"arg-type": "custom",
"arg-type-windows": "with",
"lib-depends": [
Expand Down Expand Up @@ -781,9 +786,6 @@
"Windows": "no",
"BSD": "wip"
},
"target": [
"static"
],
"notes": true,
"type": "external",
"source": "swoole",
Expand Down Expand Up @@ -1055,9 +1057,6 @@
"support": {
"BSD": "wip"
},
"target": [
"static"
],
"type": "builtin",
"arg-type": "with-prefix",
"arg-type-windows": "enable",
Expand Down
10 changes: 10 additions & 0 deletions src/SPC/builder/BuilderBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,25 @@ public function proveExts(array $static_extensions, array $shared_extensions = [
*/
abstract public function buildPHP(int $build_target = BUILD_TARGET_NONE);

/**
* @throws WrongUsageException
* @throws RuntimeException
* @throws FileSystemException
*/
public function buildSharedExts(): void
{
FileSystem::replaceFileLineContainsString(BUILD_BIN_PATH . '/php-config', 'extension_dir="', 'extension_dir="' . BUILD_MODULES_PATH . '"');
FileSystem::createDir(BUILD_MODULES_PATH);
foreach ($this->getExts() as $ext) {
if (!$ext->isBuildShared()) {
continue;
}
logger()->info('Building extension [' . $ext->getName() . '] as shared extension (' . $ext->getName() . '.so)');
$ext->buildShared();
}
if (getenv('EXTENSION_DIR')) {
FileSystem::replaceFileLineContainsString(BUILD_BIN_PATH . '/php-config', 'extension_dir="', 'extension_dir="' . getenv('EXTENSION_DIR') . '"');
}
}

/**
Expand Down
30 changes: 27 additions & 3 deletions src/SPC/builder/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,23 @@ public function patchBeforeMake(): bool
return false;
}

/**
* Patch code before shared extension ./configure
* If you need to patch some code, overwrite this
* return true if you patched something, false if not
*/
public function patchBeforeSharedBuild(): bool
{
return false;
}

/**
* Run shared extension check when cli is enabled
* @throws RuntimeException
*/
public function runSharedExtensionCheckUnix(): void
{
[$ret] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n -d "extension=' . BUILD_LIB_PATH . '/' . $this->getName() . '.so" --ri ' . $this->getName());
[$ret] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n -d "extension=' . BUILD_MODULES_PATH . '/' . $this->getName() . '.so" --ri ' . $this->getName());
if ($ret !== 0) {
throw new RuntimeException($this->getName() . '.so failed to load');
}
Expand Down Expand Up @@ -275,6 +285,10 @@ public function validate(): void
*/
public function buildShared(): void
{
if (file_exists(BUILD_MODULES_PATH . '/' . $this->getName() . '.so')) {
logger()->info('extension ' . $this->getName() . ' already built, skipping');
return;
}
match (PHP_OS_FAMILY) {
'Darwin', 'Linux' => $this->buildUnixShared(),
default => throw new WrongUsageException(PHP_OS_FAMILY . ' build shared extensions is not supported yet'),
Expand All @@ -297,17 +311,27 @@ public function buildUnixShared(): void
'CFLAGS' => $config['cflags'],
'LDFLAGS' => $config['ldflags'],
'LIBS' => $config['libs'],
'LD_LIBRARY_PATH' => BUILD_LIB_PATH,
];
// prepare configure args
shell()->cd($this->source_dir)
->setEnv($env)
->execWithEnv(BUILD_BIN_PATH . '/phpize')
->execWithEnv('./configure ' . $this->getUnixConfigureArg(true) . ' --with-php-config=' . BUILD_BIN_PATH . '/php-config --enable-shared --disable-static')
->execWithEnv('make clean')
->execWithEnv('make -j' . $this->builder->concurrency);
->execWithEnv('make -j' . $this->builder->concurrency)
->execWithEnv('make install');

// copy shared library
copy($this->source_dir . '/modules/' . $this->getDistName() . '.so', BUILD_LIB_PATH . '/' . $this->getDistName() . '.so');
$extensionDirFile = (getenv('EXTENSION_DIR') ?: $this->source_dir . '/modules') . '/' . $this->getName() . '.so';
$sourceDirFile = $this->source_dir . '/modules/' . $this->getName() . '.so';
if (file_exists($extensionDirFile)) {
copy($extensionDirFile, BUILD_MODULES_PATH . '/' . $this->getName() . '.so');
} elseif (file_exists($sourceDirFile)) {
copy($sourceDirFile, BUILD_MODULES_PATH . '/' . $this->getName() . '.so');
} else {
throw new RuntimeException('extension ' . $this->getName() . ' built successfully, but into an unexpected location.');
}
// check shared extension with php-cli
if (file_exists(BUILD_BIN_PATH . '/php')) {
$this->runSharedExtensionCheckUnix();
Expand Down
5 changes: 5 additions & 0 deletions src/SPC/builder/extension/bz2.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,9 @@ public function patchBeforeConfigure(): bool
FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/-lbz2/', $this->getLibFilesString() . $frameworks);
return true;
}

public function getUnixConfigureArg(bool $shared = false): string
{
return $shared ? '--with-bz2=' . BUILD_ROOT_PATH : '';
}
}
72 changes: 72 additions & 0 deletions src/SPC/builder/extension/dom.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

declare(strict_types=1);

namespace SPC\builder\extension;

use SPC\builder\Extension;
use SPC\exception\RuntimeException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
use SPC\util\SPCConfigUtil;

#[CustomExt('dom')]
class dom extends Extension
{
/**
* @throws RuntimeException
*/
public function getUnixConfigureArg(bool $shared = false): string
{
$arg = '--enable-dom';
if (!$shared) {
$arg .= ' --with-libxml="' . BUILD_ROOT_PATH . '"';
}
return $arg;
}

public function patchBeforeBuildconf(): bool
{
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/win32/build/config.w32', 'dllmain.c ', '');
return true;
}

public function getWindowsConfigureArg(): string
{
return '--with-dom --with-libxml';
}

public function buildUnixShared(): void
{
$config = (new SPCConfigUtil($this->builder))->config([$this->getName()]);
$env = [
'CFLAGS' => $config['cflags'] . ' -I' . SOURCE_PATH . '/php-src',
'LDFLAGS' => $config['ldflags'],
'LIBS' => $config['libs'],
'LD_LIBRARY_PATH' => BUILD_LIB_PATH,
];
// prepare configure args
shell()->cd($this->source_dir)
->setEnv($env)
->execWithEnv(BUILD_BIN_PATH . '/phpize')
->execWithEnv('./configure ' . $this->getUnixConfigureArg(true) . ' --with-php-config=' . BUILD_BIN_PATH . '/php-config --enable-shared --disable-static')
->execWithEnv('make clean')
->execWithEnv('make -j' . $this->builder->concurrency);

// copy shared library
FileSystem::createDir(BUILD_MODULES_PATH);
$extensionDirFile = (getenv('EXTENSION_DIR') ?: $this->source_dir . '/modules') . '/' . $this->getName() . '.so';
$sourceDirFile = $this->source_dir . '/modules/' . $this->getName() . '.so';
if (file_exists($extensionDirFile)) {
copy($extensionDirFile, BUILD_MODULES_PATH . '/' . $this->getName() . '.so');
} elseif (file_exists($sourceDirFile)) {
copy($sourceDirFile, BUILD_MODULES_PATH . '/' . $this->getName() . '.so');
} else {
throw new RuntimeException('extension ' . $this->getName() . ' built successfully, but into an unexpected location.');
}
// check shared extension with php-cli
if (file_exists(BUILD_BIN_PATH . '/php')) {
$this->runSharedExtensionCheckUnix();
}
}
}
11 changes: 11 additions & 0 deletions src/SPC/builder/extension/opcache.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ public function validate(): void
}
}

public function runSharedExtensionCheckUnix(): void
{
[$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n -d "zend_extension=' . BUILD_MODULES_PATH . '/opcache.so" -v');
if ($ret !== 0) {
throw new RuntimeException('opcache.so failed to load.');
}
if (!str_contains(join($out), 'with Zend OPcache')) {
throw new RuntimeException('opcache.so failed to load.');
}
}

public function patchBeforeBuildconf(): bool
{
if (file_exists(SOURCE_PATH . '/php-src/.opcache_patched')) {
Expand Down
21 changes: 21 additions & 0 deletions src/SPC/builder/extension/sockets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace SPC\builder\extension;

use SPC\builder\Extension;
use SPC\util\CustomExt;

#[CustomExt('sockets')]
class sockets extends Extension
{
public function patchBeforeConfigure(): bool
{
if (file_exists(BUILD_INCLUDE_PATH . 'php/ext/sockets/php_sockets.h')) {
return false;
}
copy(SOURCE_PATH . '/php-src/ext/sockets/php_sockets.h', BUILD_INCLUDE_PATH . 'php/ext/sockets/php_sockets.h');
return true;
}
}
5 changes: 4 additions & 1 deletion src/SPC/builder/extension/xdebug.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ class xdebug extends Extension
{
public function runSharedExtensionCheckUnix(): void
{
[$ret] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n -d "zend_extension=' . BUILD_LIB_PATH . '/xdebug.so" --ri xdebug');
[$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n -d "zend_extension=' . BUILD_MODULES_PATH . '/xdebug.so" -v');
if ($ret !== 0) {
throw new RuntimeException('xdebug.so failed to load.');
}
if (!str_contains(join($out), 'with Xdebug')) {
throw new RuntimeException('xdebug.so failed to load.');
}
}
}
1 change: 0 additions & 1 deletion src/SPC/builder/extension/xml.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#[CustomExt('soap')]
#[CustomExt('xmlreader')]
#[CustomExt('xmlwriter')]
#[CustomExt('dom')]
#[CustomExt('simplexml')]
class xml extends Extension
{
Expand Down
17 changes: 11 additions & 6 deletions src/SPC/builder/linux/library/icu.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@ class icu extends LinuxLibraryBase

protected function build(): void
{
$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"';
$cppflags = 'CPPFLAGS="-DU_CHARSET_IS_UTF8=1 -DU_USING_ICU_NAMESPACE=1 -DU_STATIC_IMPLEMENTATION=1 -DPIC -fPIC"';
$cxxflags = 'CXXFLAGS="-std=c++17 -fPIC -fno-ident"';
$ldflags = getenv('SPC_LIBC') !== 'glibc' ? 'LDFLAGS="-static"' : '';
shell()->cd($this->source_dir . '/source')
->exec(
->setEnv([
'CFLAGS' => $this->getLibExtraCFlags(),
'LDFLAGS' => $this->getLibExtraLdFlags(),
'LIBS' => $this->getLibExtraLibs(),
])
->execWithEnv(
"{$cppflags} {$cxxflags} {$ldflags} " .
'./runConfigureICU Linux ' .
'--enable-static ' .
Expand All @@ -33,9 +38,9 @@ protected function build(): void
'--enable-samples=no ' .
'--prefix=' . BUILD_ROOT_PATH
)
->exec('make clean')
->exec("make -j{$this->builder->concurrency}")
->exec('make install');
->execWithEnv('make clean')
->execWithEnv("make -j{$this->builder->concurrency}")
->execWithEnv('make install');

$this->patchPkgconfPrefix(['icu-i18n.pc', 'icu-io.pc', 'icu-uc.pc'], PKGCONF_PATCH_PREFIX);
FileSystem::removeDir(BUILD_LIB_PATH . '/icu');
Expand Down
6 changes: 5 additions & 1 deletion src/SPC/builder/linux/library/libffi.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ public function build(): void
$arch = getenv('SPC_ARCH');

shell()->cd($this->source_dir)
->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()])
->setEnv([
'CFLAGS' => $this->getLibExtraCFlags(),
'LDFLAGS' => $this->getLibExtraLdFlags(),
'LIBS' => $this->getLibExtraLibs(),
])
->execWithEnv(
'./configure ' .
'--enable-static ' .
Expand Down
6 changes: 5 additions & 1 deletion src/SPC/builder/linux/library/openssl.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ public function build(): void
$clang_postfix = SystemUtil::getCCType(getenv('CC')) === 'clang' ? '-clang' : '';

shell()->cd($this->source_dir)
->setEnv(['CFLAGS' => $this->getLibExtraCFlags() ?: $this->builder->arch_c_flags, 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()])
->setEnv([
'CFLAGS' => $this->getLibExtraCFlags(),
'LDFLAGS' => $this->getLibExtraLdFlags(),
'LIBS' => $this->getLibExtraLibs(),
])
->execWithEnv(
"{$env} ./Configure no-shared {$extra} " .
'--prefix=/ ' .
Expand Down
6 changes: 5 additions & 1 deletion src/SPC/builder/macos/library/openssl.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ protected function build(): void
$arch = getenv('SPC_ARCH');

shell()->cd($this->source_dir)
->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()])
->setEnv([
'CFLAGS' => $this->getLibExtraCFlags(),
'LDFLAGS' => $this->getLibExtraLdFlags(),
'LIBS' => $this->getLibExtraLibs(),
])
->exec(
"./Configure no-shared {$extra} " .
'--prefix=/ ' . // use prefix=/
Expand Down
4 changes: 2 additions & 2 deletions src/SPC/builder/unix/UnixBuilderBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ protected function deployBinary(int $type): bool
default => throw new RuntimeException('Deployment does not accept type ' . $type),
};
logger()->info('Deploying ' . $this->getBuildTypeName($type) . ' file');
FileSystem::createDir(BUILD_ROOT_PATH . '/bin');
shell()->exec('cp ' . escapeshellarg($src) . ' ' . escapeshellarg(BUILD_ROOT_PATH . '/bin/'));
FileSystem::createDir(BUILD_BIN_PATH);
shell()->exec('cp ' . escapeshellarg($src) . ' ' . escapeshellarg(BUILD_BIN_PATH));
return true;
}

Expand Down
Loading