Skip to content

Commit 289f4b3

Browse files
authored
Merge pull request #726 from crazywhalecc/fix/icurel
Fix PIC errors when building libphp.so | extensive extension building rework
2 parents a48680c + 0ee9a0c commit 289f4b3

File tree

125 files changed

+2424
-1532
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+2424
-1532
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ docker/source/
1010
# default source extract directory
1111
/source/**
1212

13+
# built by shared embed tests
14+
/locale/
15+
1316
# default source download directory
1417
/downloads/**
1518

bin/spc-gnu-docker

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ RUN yum update -y && \
7272
yum install -y devtoolset-10-gcc-*
7373
RUN echo "source scl_source enable devtoolset-10" >> /etc/bashrc
7474
RUN source /etc/bashrc
75+
RUN yum install -y which
7576
7677
RUN curl -o cmake.tgz -fsSL https://github.com/Kitware/CMake/releases/download/v3.31.4/cmake-3.31.4-linux-$BASE_ARCH.tar.gz && \
7778
mkdir /cmake && \

config/env.ini

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ CXX=${SPC_LINUX_DEFAULT_CXX}
6868
AR=${SPC_LINUX_DEFAULT_AR}
6969
LD=ld.gold
7070
; default compiler flags, used in CMake toolchain file, openssl and pkg-config build
71-
SPC_DEFAULT_C_FLAGS="-fPIC"
72-
SPC_DEFAULT_CXX_FLAGS=
71+
SPC_DEFAULT_C_FLAGS="-fpic -Os"
72+
SPC_DEFAULT_CXX_FLAGS="-fpic -Os"
7373
; extra libs for building php executable, used in `make` command for building php (this value may changed by extension build process, space separated)
7474
SPC_EXTRA_LIBS=
7575
; upx executable path
@@ -81,25 +81,27 @@ SPC_MICRO_PATCHES=static_extensions_win32,cli_checks,disable_huge_page,vcruntime
8181
; buildconf command
8282
SPC_CMD_PREFIX_PHP_BUILDCONF="./buildconf --force"
8383
; configure command
84-
SPC_CMD_PREFIX_PHP_CONFIGURE="./configure --prefix= --with-valgrind=no --enable-shared=no --enable-static=yes --disable-all --disable-cgi --disable-phpdbg --with-pic"
84+
SPC_CMD_PREFIX_PHP_CONFIGURE="./configure --prefix= --with-valgrind=no --disable-shared --enable-static --disable-all --disable-cgi --disable-phpdbg --with-pic"
8585
; make command
8686
SPC_CMD_PREFIX_PHP_MAKE="make -j${CPU_COUNT}"
8787
; embed type for php, static (libphp.a) or shared (libphp.so)
8888
SPC_CMD_VAR_PHP_EMBED_TYPE="static"
8989

9090
; *** default build vars for building php ***
9191
; CFLAGS for configuring php
92-
SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS="${SPC_DEFAULT_C_FLAGS} -fPIE"
92+
SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS="${SPC_DEFAULT_C_FLAGS} -fpie"
9393
; CPPFLAGS for configuring php
9494
SPC_CMD_VAR_PHP_CONFIGURE_CPPFLAGS="-I${BUILD_INCLUDE_PATH}"
9595
; LDFLAGS for configuring php
9696
SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS="-L${BUILD_LIB_PATH}"
9797
; LIBS for configuring php
9898
SPC_CMD_VAR_PHP_CONFIGURE_LIBS="-ldl -lpthread -lm"
9999
; EXTRA_CFLAGS for `make` php
100-
SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -fpic -fpie -Os -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fno-ident -fPIE -fPIC"
100+
SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -fno-ident -fpie ${SPC_DEFAULT_C_FLAGS}"
101101
; EXTRA_LIBS for `make` php
102102
SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS="-ldl -lpthread -lm"
103+
; EXTRA_LDFLAGS for `make` php, can use -release to set a soname for libphp.so
104+
SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS=""
103105
; EXTRA_LDFLAGS_PROGRAM for `make` php
104106
SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM="-all-static -Wl,-O1 -pie"
105107

@@ -108,8 +110,8 @@ SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM="-all-static -Wl,-O1 -pie"
108110
CC=clang
109111
CXX=clang++
110112
; default compiler flags, used in CMake toolchain file, openssl and pkg-config build
111-
SPC_DEFAULT_C_FLAGS="--target=${MAC_ARCH}-apple-darwin"
112-
SPC_DEFAULT_CXX_FLAGS="--target=${MAC_ARCH}-apple-darwin"
113+
SPC_DEFAULT_C_FLAGS="--target=${MAC_ARCH}-apple-darwin -Os"
114+
SPC_DEFAULT_CXX_FLAGS="--target=${MAC_ARCH}-apple-darwin -Os"
113115
; extra libs for building php executable, used in `make` command for building php (this value may changed by extension build process, space separated)
114116
SPC_EXTRA_LIBS=
115117
; phpmicro patches, for more info, see: https://github.com/easysoft/phpmicro/tree/master/patches
@@ -131,7 +133,7 @@ SPC_CMD_VAR_PHP_CONFIGURE_CPPFLAGS="-I${BUILD_INCLUDE_PATH}"
131133
; LDFLAGS for configuring php
132134
SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS="-L${BUILD_LIB_PATH}"
133135
; EXTRA_CFLAGS for `make` php
134-
SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -fpic -fpie -Os -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
136+
SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -fpic -fpie ${SPC_DEFAULT_C_FLAGS}"
135137
; EXTRA_LIBS for `make` php
136138
SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS="-lresolv"
137139
; embed type for php, static (libphp.a) or shared (libphp.dylib)

config/ext.json

Lines changed: 78 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@
2424
"bcmath": {
2525
"type": "builtin"
2626
},
27+
"brotli": {
28+
"type": "external",
29+
"source": "ext-brotli",
30+
"arg-type": "enable",
31+
"lib-depends": [
32+
"brotli"
33+
]
34+
},
2735
"bz2": {
2836
"type": "builtin",
2937
"arg-type-unix": "with-prefix",
@@ -95,7 +103,10 @@
95103
"ev": {
96104
"type": "external",
97105
"source": "ev",
98-
"arg-type-windows": "with"
106+
"arg-type-windows": "with",
107+
"ext-depends": [
108+
"sockets"
109+
]
99110
},
100111
"event": {
101112
"support": {
@@ -124,10 +135,6 @@
124135
"Linux": "partial",
125136
"BSD": "wip"
126137
},
127-
"target": [
128-
"static",
129-
"shared"
130-
],
131138
"notes": true,
132139
"arg-type": "custom",
133140
"type": "builtin",
@@ -323,6 +330,16 @@
323330
"openssl"
324331
]
325332
},
333+
"libxml": {
334+
"support": {
335+
"BSD": "wip"
336+
},
337+
"type": "builtin",
338+
"arg-type": "none",
339+
"target": [
340+
"static"
341+
]
342+
},
326343
"lz4": {
327344
"support": {
328345
"Windows": "wip",
@@ -335,19 +352,12 @@
335352
"liblz4"
336353
]
337354
},
338-
"libxml": {
339-
"support": {
340-
"BSD": "wip"
341-
},
342-
"type": "builtin",
343-
"arg-type": "none",
344-
"ext-depends": [
345-
"xml"
346-
]
347-
},
348355
"mbregex": {
349356
"type": "builtin",
350357
"arg-type": "custom",
358+
"target": [
359+
"static"
360+
],
351361
"ext-depends": [
352362
"mbstring"
353363
],
@@ -380,13 +390,13 @@
380390
"ext-depends": [
381391
"zlib",
382392
"session"
383-
]
393+
],
394+
"build-with-php": true
384395
},
385396
"memcached": {
386397
"support": {
387398
"Windows": "wip",
388-
"BSD": "wip",
389-
"Linux": "no"
399+
"BSD": "wip"
390400
},
391401
"type": "external",
392402
"source": "memcached",
@@ -395,6 +405,10 @@
395405
"lib-depends": [
396406
"libmemcached"
397407
],
408+
"lib-depends-unix": [
409+
"libmemcached",
410+
"fastlz"
411+
],
398412
"ext-depends": [
399413
"session",
400414
"zlib"
@@ -413,6 +427,10 @@
413427
"openssl",
414428
"zstd",
415429
"zlib"
430+
],
431+
"frameworks": [
432+
"CoreFoundation",
433+
"Security"
416434
]
417435
},
418436
"msgpack": {
@@ -422,7 +440,10 @@
422440
"type": "external",
423441
"source": "msgpack",
424442
"arg-type-unix": "with",
425-
"arg-type-win": "enable"
443+
"arg-type-win": "enable",
444+
"ext-depends": [
445+
"session"
446+
]
426447
},
427448
"mysqli": {
428449
"type": "builtin",
@@ -461,7 +482,8 @@
461482
},
462483
"opcache": {
463484
"type": "builtin",
464-
"arg-type-unix": "custom"
485+
"arg-type-unix": "custom",
486+
"zend-extension": true
465487
},
466488
"openssl": {
467489
"notes": true,
@@ -650,6 +672,9 @@
650672
"arg-type": "with-prefix",
651673
"lib-depends": [
652674
"readline"
675+
],
676+
"target": [
677+
"static"
653678
]
654679
},
655680
"redis": {
@@ -669,10 +694,12 @@
669694
]
670695
},
671696
"session": {
672-
"type": "builtin"
697+
"type": "builtin",
698+
"build-with-php": true
673699
},
674700
"shmop": {
675-
"type": "builtin"
701+
"type": "builtin",
702+
"build-with-php": true
676703
},
677704
"simdjson": {
678705
"type": "external",
@@ -690,7 +717,8 @@
690717
],
691718
"ext-depends-windows": [
692719
"xml"
693-
]
720+
],
721+
"build-with-php": true
694722
},
695723
"snappy": {
696724
"support": {
@@ -783,7 +811,7 @@
783811
"lib-depends": [
784812
"libssh2"
785813
],
786-
"ext-depends-windows": [
814+
"ext-depends": [
787815
"openssl",
788816
"zlib"
789817
]
@@ -793,9 +821,6 @@
793821
"Windows": "no",
794822
"BSD": "wip"
795823
},
796-
"target": [
797-
"static"
798-
],
799824
"notes": true,
800825
"type": "external",
801826
"source": "swoole",
@@ -913,7 +938,8 @@
913938
]
914939
},
915940
"tokenizer": {
916-
"type": "builtin"
941+
"type": "builtin",
942+
"build-with-php": true
917943
},
918944
"uuid": {
919945
"support": {
@@ -954,7 +980,8 @@
954980
"Darwin": "partial",
955981
"Linux": "partial"
956982
},
957-
"notes": true
983+
"notes": true,
984+
"zend-extension": true
958985
},
959986
"xhprof": {
960987
"support": {
@@ -966,7 +993,8 @@
966993
"source": "xhprof",
967994
"ext-depends": [
968995
"ctype"
969-
]
996+
],
997+
"build-with-php": true
970998
},
971999
"xlswriter": {
9721000
"support": {
@@ -996,7 +1024,8 @@
9961024
],
9971025
"ext-depends-windows": [
9981026
"iconv"
999-
]
1027+
],
1028+
"build-with-php": true
10001029
},
10011030
"xmlreader": {
10021031
"support": {
@@ -1010,7 +1039,8 @@
10101039
"ext-depends-windows": [
10111040
"xml",
10121041
"dom"
1013-
]
1042+
],
1043+
"build-with-php": true
10141044
},
10151045
"xmlwriter": {
10161046
"support": {
@@ -1023,7 +1053,8 @@
10231053
],
10241054
"ext-depends-windows": [
10251055
"xml"
1026-
]
1056+
],
1057+
"build-with-php": true
10271058
},
10281059
"xsl": {
10291060
"support": {
@@ -1040,13 +1071,24 @@
10401071
"dom"
10411072
]
10421073
},
1074+
"xz": {
1075+
"type": "external",
1076+
"source": "ext-xz",
1077+
"arg-type": "with",
1078+
"lib-depends": [
1079+
"xz"
1080+
]
1081+
},
10431082
"yac": {
10441083
"support": {
10451084
"BSD": "wip"
10461085
},
10471086
"type": "external",
10481087
"source": "yac",
10491088
"arg-type-unix": "custom",
1089+
"lib-depends-unix": [
1090+
"fastlz"
1091+
],
10501092
"ext-depends-unix": [
10511093
"igbinary"
10521094
]
@@ -1067,9 +1109,6 @@
10671109
"support": {
10681110
"BSD": "wip"
10691111
},
1070-
"target": [
1071-
"static"
1072-
],
10731112
"type": "builtin",
10741113
"arg-type": "with-prefix",
10751114
"arg-type-windows": "enable",
@@ -1093,6 +1132,9 @@
10931132
"arg-type-windows": "enable",
10941133
"lib-depends": [
10951134
"zlib"
1135+
],
1136+
"target": [
1137+
"static"
10961138
]
10971139
},
10981140
"zstd": {

0 commit comments

Comments
 (0)