Skip to content

Commit 58eafe5

Browse files
authored
Merge pull request #622 from DubbleClick/libacl
bring back pr for libacl
2 parents 89e8c15 + 74edcb7 commit 58eafe5

File tree

20 files changed

+260
-33
lines changed

20 files changed

+260
-33
lines changed

.github/workflows/build-unix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ on:
1515
php-version:
1616
required: true
1717
description: PHP version to compile
18-
default: '8.3'
18+
default: '8.4'
1919
type: choice
2020
options:
2121
- '8.4'

bin/spc-gnu-docker

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,4 @@ echo 'SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS="-ldl -lpthread -lm -lresolv -lutil -lrt"'
137137
# shellcheck disable=SC2086
138138
# shellcheck disable=SC2090
139139

140-
$DOCKER_EXECUTABLE run --rm $INTERACT -e SPC_FIX_DEPLOY_ROOT="$(pwd)" --env-file /tmp/spc-gnu-docker.env $MOUNT_LIST cwcc-spc-gnu-$SPC_USE_ARCH # bin/spc $@
140+
$DOCKER_EXECUTABLE run --rm $INTERACT -e SPC_FIX_DEPLOY_ROOT="$(pwd)" --env-file /tmp/spc-gnu-docker.env $MOUNT_LIST cwcc-spc-gnu-$SPC_USE_ARCH bin/spc $@

config/env.ini

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
; SPC_LINUX_DEFAULT_CC: the default compiler for linux. (For alpine linux: `gcc`, default: `$GNU_ARCH-linux-musl-gcc`)
3636
; SPC_LINUX_DEFAULT_CXX: the default c++ compiler for linux. (For alpine linux: `g++`, default: `$GNU_ARCH-linux-musl-g++`)
3737
; SPC_LINUX_DEFAULT_AR: the default archiver for linux. (For alpine linux: `ar`, default: `$GNU_ARCH-linux-musl-ar`)
38-
; SPC_PHP_DEFAULT_LD_LIBRARY_PATH_CMD: the default LD_LIBRARY_PATH for php. (linux: `LD_LIBRARY_PATH=/usr/local/musl/$GNU_ARCH-linux-musl/lib`, default: empty)
3938

4039

4140
[global]
@@ -45,6 +44,14 @@ SPC_CONCURRENCY=${CPU_COUNT}
4544
SPC_SKIP_PHP_VERSION_CHECK="no"
4645
; Ignore some check item for bin/spc doctor command, comma separated (e.g. SPC_SKIP_DOCTOR_CHECK_ITEMS="if homebrew has installed")
4746
SPC_SKIP_DOCTOR_CHECK_ITEMS=""
47+
; EXTENSION_DIR where the built php will look for extension when a .ini instructs to load them
48+
; only useful for builds targeting glibc --libc=glibc
49+
; default paths
50+
; Ubuntu/Debian: /usr/lib/php/{PHP_VERSION}/
51+
; RHEL: /usr/lib64/php/modules
52+
; Alpine: /usr/lib/php{PHP_VERSION}/modules
53+
; where {PHP_VERSION} is 84 for php 8.4
54+
EXTENSION_DIR=
4855

4956
[windows]
5057
; php-sdk-binary-tools path
@@ -63,7 +70,7 @@ CXX=${SPC_LINUX_DEFAULT_CXX}
6370
AR=${SPC_LINUX_DEFAULT_AR}
6471
LD=ld.gold
6572
; default compiler flags, used in CMake toolchain file, openssl and pkg-config build
66-
SPC_DEFAULT_C_FLAGS=
73+
SPC_DEFAULT_C_FLAGS="-fPIC"
6774
SPC_DEFAULT_CXX_FLAGS=
6875
; extra libs for building php executable, used in `make` command for building php (this value may changed by extension build process, space separated)
6976
SPC_EXTRA_LIBS=
@@ -76,7 +83,7 @@ SPC_MICRO_PATCHES=static_extensions_win32,cli_checks,disable_huge_page,vcruntime
7683
; buildconf command
7784
SPC_CMD_PREFIX_PHP_BUILDCONF="./buildconf --force"
7885
; configure command
79-
SPC_CMD_PREFIX_PHP_CONFIGURE="${SPC_PHP_DEFAULT_LD_LIBRARY_PATH_CMD} ./configure --prefix= --with-valgrind=no --enable-shared=no --enable-static=yes --disable-all --disable-cgi --disable-phpdbg --with-pic"
86+
SPC_CMD_PREFIX_PHP_CONFIGURE="./configure --prefix= --with-valgrind=no --enable-shared=no --enable-static=yes --disable-all --disable-cgi --disable-phpdbg --with-pic"
8087
; make command
8188
SPC_CMD_PREFIX_PHP_MAKE="make -j${CPU_COUNT}"
8289
; embed type for php, static (libphp.a) or shared (libphp.so)
@@ -117,8 +124,6 @@ SPC_CMD_PREFIX_PHP_BUILDCONF="./buildconf --force"
117124
SPC_CMD_PREFIX_PHP_CONFIGURE="./configure --prefix= --with-valgrind=no --enable-shared=no --enable-static=yes --disable-all --disable-cgi --disable-phpdbg"
118125
; make command
119126
SPC_CMD_PREFIX_PHP_MAKE="make -j${CPU_COUNT}"
120-
; embed type for php, static or shared
121-
SPC_CMD_VAR_PHP_EMBED_TYPE="static"
122127

123128
; *** default build vars for building php ***
124129
; CFLAGS for configuring php
@@ -131,6 +136,8 @@ SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS="-L${BUILD_LIB_PATH}"
131136
SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="${SPC_PHP_DEFAULT_OPTIMIZE_CFLAGS}"
132137
; EXTRA_LIBS for `make` php
133138
SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS="-lresolv"
139+
; embed type for php, static (libphp.a) or shared (libphp.dylib)
140+
SPC_CMD_VAR_PHP_EMBED_TYPE="static"
134141

135142
[freebsd]
136143
; compiler environments

config/lib.json

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@
99
"type": "root",
1010
"source": "php-src",
1111
"lib-depends": [
12-
"micro",
13-
"lib-base"
12+
"lib-base",
13+
"micro"
14+
],
15+
"lib-depends-linux": [
16+
"lib-base",
17+
"libacl",
18+
"micro"
1419
]
1520
},
1621
"micro": {
@@ -24,6 +29,12 @@
2429
"pkg-config"
2530
]
2631
},
32+
"attr": {
33+
"source": "attr",
34+
"static-libs-unix": [
35+
"libattr.a"
36+
]
37+
},
2738
"brotli": {
2839
"source": "brotli",
2940
"static-libs-unix": [
@@ -234,6 +245,15 @@
234245
"libsodium"
235246
]
236247
},
248+
"libacl": {
249+
"source": "libacl",
250+
"static-libs-unix": [
251+
"libacl.a"
252+
],
253+
"lib-depends": [
254+
"attr"
255+
]
256+
},
237257
"libaom": {
238258
"source": "libaom",
239259
"static-libs-unix": [

config/source.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@
3636
"path": "LICENSE"
3737
}
3838
},
39+
"attr": {
40+
"type": "git",
41+
"rev": "v2.5.2",
42+
"url": "https://git.savannah.nongnu.org/git/attr.git",
43+
"provide-pre-built": true,
44+
"license": {
45+
"type": "file",
46+
"path": "doc/COPYING"
47+
}
48+
},
3949
"brotli": {
4050
"type": "ghtar",
4151
"repo": "google/brotli",
@@ -323,6 +333,16 @@
323333
"path": "LICENSE"
324334
}
325335
},
336+
"libacl": {
337+
"type": "git",
338+
"rev": "v2.3.2",
339+
"url": "https://git.savannah.nongnu.org/git/acl.git",
340+
"provide-pre-built": true,
341+
"license": {
342+
"type": "file",
343+
"path": "doc/COPYING"
344+
}
345+
},
326346
"libaom": {
327347
"type": "git",
328348
"rev": "main",

src/SPC/builder/Extension.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ public function getUnixConfigureArg(): string
139139

140140
/**
141141
* Patch code before ./buildconf
142-
* If you need to patch some code, overwrite this and return true
142+
* If you need to patch some code, overwrite this
143+
* return true if you patched something, false if not
143144
*/
144145
public function patchBeforeBuildconf(): bool
145146
{
@@ -148,7 +149,8 @@ public function patchBeforeBuildconf(): bool
148149

149150
/**
150151
* Patch code before ./configure
151-
* If you need to patch some code, overwrite this and return true
152+
* If you need to patch some code, overwrite this
153+
* return true if you patched something, false if not
152154
*/
153155
public function patchBeforeConfigure(): bool
154156
{
@@ -157,7 +159,8 @@ public function patchBeforeConfigure(): bool
157159

158160
/**
159161
* Patch code before make
160-
* If you need to patch some code, overwrite this and return true
162+
* If you need to patch some code, overwrite this
163+
* return true if you patched something, false if not
161164
*/
162165
public function patchBeforeMake(): bool
163166
{

src/SPC/builder/LibraryBase.php

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function calcDependency(): void
113113
/*
114114
Rules:
115115
If it is a Windows system, try the following dependencies in order: lib-depends-windows, lib-depends-win, lib-depends.
116-
If it is a macOS system, try the following dependencies in order: lib-depends-darwin, lib-depends-unix, lib-depends.
116+
If it is a macOS system, try the following dependencies in order: lib-depends-macos, lib-depends-unix, lib-depends.
117117
If it is a Linux system, try the following dependencies in order: lib-depends-linux, lib-depends-unix, lib-depends.
118118
*/
119119
foreach (Config::getLib(static::NAME, 'lib-depends', []) as $dep_name) {
@@ -261,14 +261,6 @@ public function tryBuild(bool $force_build = false): int
261261
return LIB_STATUS_ALREADY;
262262
}
263263

264-
/**
265-
* Patch before build, overwrite this and return true to patch libs.
266-
*/
267-
public function patchBeforeBuild(): bool
268-
{
269-
return false;
270-
}
271-
272264
public function validate(): void
273265
{
274266
// do nothing, just throw wrong usage exception if not valid
@@ -294,6 +286,46 @@ public function beforePack(): void
294286
// do something before pack, default do nothing. overwrite this method to do something (e.g. modify pkg-config file)
295287
}
296288

289+
/**
290+
* Patch code before build
291+
* If you need to patch some code, overwrite this
292+
* return true if you patched something, false if not
293+
*/
294+
public function patchBeforeBuild(): bool
295+
{
296+
return false;
297+
}
298+
299+
/**
300+
* Patch code before ./buildconf
301+
* If you need to patch some code, overwrite this
302+
* return true if you patched something, false if not
303+
*/
304+
public function patchBeforeBuildconf(): bool
305+
{
306+
return false;
307+
}
308+
309+
/**
310+
* Patch code before ./configure
311+
* If you need to patch some code, overwrite this
312+
* return true if you patched something, false if not
313+
*/
314+
public function patchBeforeConfigure(): bool
315+
{
316+
return false;
317+
}
318+
319+
/**
320+
* Patch code before make
321+
* If you need to patch some code, overwrite this
322+
* return true if you patched something, false if not
323+
*/
324+
public function patchBeforeMake(): bool
325+
{
326+
return false;
327+
}
328+
297329
/**
298330
* Build this library.
299331
*

src/SPC/builder/linux/LinuxBuilder.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,13 @@ public function __construct(array $options = [])
3737
GlobalEnvManager::init($this);
3838

3939
// set library path, some libraries need it. (We cannot use `putenv` here, because cmake will be confused)
40-
if (!filter_var(getenv('SPC_NO_MUSL_PATH'), FILTER_VALIDATE_BOOLEAN)) {
40+
if (!filter_var(getenv('SPC_NO_MUSL_PATH'), FILTER_VALIDATE_BOOLEAN) && $this->libc !== LIBC_GLIBC) {
4141
$this->setOptionIfNotExist('library_path', "LIBRARY_PATH=\"/usr/local/musl/{$arch}-linux-musl/lib\"");
4242
$this->setOptionIfNotExist('ld_library_path', "LD_LIBRARY_PATH=\"/usr/local/musl/{$arch}-linux-musl/lib\"");
43+
GlobalEnvManager::putenv("PATH=/usr/local/musl/bin:/usr/local/musl/{$arch}-linux-musl/bin:" . getenv('PATH'));
44+
$configure = getenv('SPC_CMD_PREFIX_PHP_CONFIGURE');
45+
$configure = "LD_LIBRARY_PATH=\"/usr/local/musl/{$arch}-linux-musl/lib\" " . $configure;
46+
GlobalEnvManager::putenv("SPC_CMD_PREFIX_PHP_CONFIGURE={$configure}");
4347
}
4448

4549
if (str_ends_with(getenv('CC'), 'linux-musl-gcc') && !file_exists("/usr/local/musl/bin/{$arch}-linux-musl-gcc") && (getenv('SPC_NO_MUSL_PATH') !== 'yes')) {
@@ -174,7 +178,7 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
174178
->exec(
175179
getenv('SPC_CMD_PREFIX_PHP_CONFIGURE') . ' ' .
176180
($enable_cli ? '--enable-cli ' : '--disable-cli ') .
177-
($enable_fpm ? '--enable-fpm ' : '--disable-fpm ') .
181+
($enable_fpm ? '--enable-fpm ' . ($this->getLib('libacl') !== null ? '--with-fpm-acl ' : '') : '--disable-fpm ') .
178182
($enable_embed ? "--enable-embed={$embed_type} " : '--disable-embed ') .
179183
($enable_micro ? '--enable-micro=all-static ' : '--disable-micro ') .
180184
$config_file_path .
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SPC\builder\linux\library;
6+
7+
class attr extends LinuxLibraryBase
8+
{
9+
use \SPC\builder\unix\library\attr;
10+
11+
public const NAME = 'attr';
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SPC\builder\linux\library;
6+
7+
class libacl extends LinuxLibraryBase
8+
{
9+
use \SPC\builder\unix\library\libacl;
10+
11+
public const NAME = 'libacl';
12+
}

0 commit comments

Comments
 (0)