Skip to content

Commit 8e4dc6d

Browse files
committed
Expand PHP build to be more featureful
1 parent 76343cc commit 8e4dc6d

File tree

2 files changed

+89
-23
lines changed

2 files changed

+89
-23
lines changed

.github/workflows/CI.yml

Lines changed: 63 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ jobs:
4242
# build: pnpm build --target aarch64-apple-darwin
4343
build: pnpm build
4444
setup: |
45-
brew install autoconf automake libtool re2c bison libiconv
45+
brew install autoconf automake libtool re2c bison libiconv \
46+
argon2 libzip
4647
4748
# TODO: Do we need to care about x86_64 macOS?
4849
# NOTE: Unable to force link bison on macOS 13, which php-src requires.
@@ -51,7 +52,8 @@ jobs:
5152
# build: pnpm build --target x86_64-apple-darwin
5253
build: pnpm build
5354
setup: |
54-
brew install autoconf automake libtool re2c bison libiconv
55+
brew install autoconf automake libtool re2c bison libiconv \
56+
argon2 libzip
5557
5658
#
5759
# Linux
@@ -64,10 +66,12 @@ jobs:
6466
# build: pnpm build --target x86_64-unknown-linux-gnu
6567
build: pnpm build
6668
setup: |
67-
sudo apt-get update
68-
sudo apt-get install -y libssl-dev pkg-config build-essential \
69+
apt-get update
70+
apt-get install -y curl libssl-dev pkg-config build-essential \
6971
libcurl4-openssl-dev autoconf libxml2-dev libsqlite3-dev \
70-
bison re2c libonig-dev patchelf
72+
bison re2c libonig-dev patchelf zlib1g-dev openssh-client git \
73+
libclang-dev libreadline-dev libpng-dev libjpeg-dev libzip-dev \
74+
libsodium-dev libargon2-dev
7175
7276
# TODO: Can't use the musl container, need to build with ssh-agent access.
7377
# TODO: Fails because missing x86_64-linux-musl-gcc
@@ -152,17 +156,42 @@ jobs:
152156
if: ${{ !matrix.settings.docker }}
153157
shell: bash
154158
run: |
159+
set -x
155160
${{ matrix.settings.setup }}
156161
157162
# Use brew bison and libiconv manually. Force linking does not work on macOS 13
158163
if [[ "$(uname)" == "Darwin" ]]; then
159-
export PATH="$(brew --prefix bison)/bin:$(brew --prefix libiconv)/bin:$PATH"
160-
export LDFLAGS="$LDFLAGS -L$(brew --prefix bison)/lib -L$(brew --prefix libiconv)/lib"
164+
# Expose bison to compiler
165+
export PATH="$(brew --prefix bison)/bin:$PATH"
166+
export LDFLAGS="$LDFLAGS -L$(brew --prefix bison)/lib"
167+
export CPPFLAGS="$CPPFLAGS -I$(brew --prefix bison)/include"
161168
fi
162169
163170
cd php-src
164171
./buildconf
165-
./configure --enable-shared --enable-embed=shared --enable-zts --without-iconv --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-openssl --with-curl --enable-mbstring
172+
173+
# TODO: Figure out why macOS can't find libiconv
174+
./configure \
175+
--enable-shared --enable-embed=shared \
176+
--with-config-file-path=/usr/local/etc/php \
177+
--with-config-file-scan-dir=/usr/local/etc/php/conf.d \
178+
--enable-option-checking=fatal \
179+
--with-pic \
180+
--enable-zts \
181+
--enable-mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd \
182+
--with-pdo-sqlite=/usr --with-sqlite3=/usr \
183+
--with-openssl --with-password-argon2 --with-sodium=shared \
184+
--with-curl \
185+
--enable-mbstring --with-mhash \
186+
--enable-exif `#--enable-gd` \
187+
--with-zip --with-zlib \
188+
--without-iconv \
189+
--without-readline \
190+
--disable-phpdbg \
191+
--with-pear \
192+
--enable-fileinfo \
193+
--disable-cgi
194+
166195
make -j$([[ "$(uname)" == "Darwin" ]] && sysctl -n hw.physicalcpu || nproc)
167196
sudo make install
168197
cd ..
@@ -178,12 +207,8 @@ jobs:
178207
options: '--user 0:0 -v ${{ github.workspace }}/.cargo-cache/git/db:/usr/local/cargo/git/db -v ${{ github.workspace }}/.cargo/registry/cache:/usr/local/cargo/registry/cache -v ${{ github.workspace }}/.cargo/registry/index:/usr/local/cargo/registry/index -v ${{ github.workspace }}:/build -w /build'
179208
shell: bash
180209
run: |
181-
# Can't use the setup script because docker lacks sudo
182-
apt-get update
183-
apt-get install -y curl libssl-dev pkg-config build-essential \
184-
libcurl4-openssl-dev autoconf libxml2-dev libsqlite3-dev \
185-
bison re2c libonig-dev patchelf zlib1g-dev openssh-client git \
186-
libclang-dev
210+
set -x
211+
${{ matrix.settings.setup }}
187212
188213
# Install rust toolchain
189214
curl https://sh.rustup.rs -sSf | bash -s -- -y -t ${{ matrix.settings.target }}
@@ -206,8 +231,30 @@ jobs:
206231
207232
# Build PHP
208233
cd php-src
209-
./buildconf
210-
./configure --enable-shared --enable-embed=shared --enable-zts --without-iconv --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-openssl --with-curl --enable-mbstring
234+
./buildconf --force
235+
236+
./configure \
237+
--prefix=/usr \
238+
--enable-shared --enable-embed=shared \
239+
--with-config-file-path=/usr/local/etc/php \
240+
--with-config-file-scan-dir=/usr/local/etc/php/conf.d \
241+
--enable-option-checking=fatal \
242+
--with-pic \
243+
--enable-zts \
244+
--enable-mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd \
245+
--with-pdo-sqlite=/usr --with-sqlite3=/usr \
246+
--with-openssl --with-password-argon2 --with-sodium=shared \
247+
--with-curl \
248+
--enable-mbstring --with-mhash \
249+
--enable-exif --enable-gd \
250+
--with-zip --with-zlib \
251+
--without-iconv \
252+
--with-readline \
253+
--disable-phpdbg \
254+
--with-pear \
255+
--enable-fileinfo \
256+
--disable-cgi
257+
211258
make -j$([[ "$(uname)" == "Darwin" ]] && sysctl -n hw.physicalcpu || nproc)
212259
make install
213260
cd ..

INTERNALS.md

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,34 @@ Building PHP itself is straightforward. Here's the basic configuration:
77
```sh
88
git clone https://github.com/php/php-src.git
99
cd php-src
10-
./buildconf
11-
./configure --enable-shared --enable-embed=shared --enable-zts --without-iconv --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-openssl --with-curl --enable-mbstring
12-
make -j$([[ "$(uname)" == "Darwin" ]] && sysctl -n hw.physicalcpu || nproc)
13-
sudo make install
14-
```
1510

16-
```sh
11+
if [[ "$(uname)" == "Darwin" ]]; then
12+
export PATH="$(brew --prefix bison)/bin:$(brew --prefix libiconv)/bin:$PATH"
13+
export LDFLAGS="$LDFLAGS -L$(brew --prefix bison)/lib -L$(brew --prefix libiconv)/lib -L$(brew --prefix readline)/lib"
14+
fi
15+
1716
./buildconf
18-
./configure --enable-shared --enable-embed=shared --enable-zts --with-config-file-path=/usr/local/etc/php --with-config-file-scan-dir=/usr/local/etc/php/conf.d --enable-option-checking=fatal --with-mhash --with-pic --enable-mbstring --enable-mysqlnd --with-password-argon2 --with-sodium=shared --with-pdo-sqlite=/usr --with-sqlite3=/usr --with-curl --with-iconv --with-openssl --with-readline --with-zlib --disable-phpdbg --with-pear --disable-cgi
17+
./configure \
18+
--enable-shared --enable-embed=shared \
19+
--with-config-file-path=/usr/local/etc/php \
20+
--with-config-file-scan-dir=/usr/local/etc/php/conf.d \
21+
--enable-option-checking=fatal \
22+
--with-pic \
23+
--enable-zts \
24+
--enable-mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd \
25+
--with-pdo-sqlite=/usr --with-sqlite3=/usr \
26+
--with-openssl --with-password-argon2 --with-sodium=shared \
27+
--with-curl \
28+
--enable-mbstring --with-mhash \
29+
--enable-exif --enable-gd \
30+
--with-zip --with-zlib \
31+
--without-iconv \
32+
--with-readline \
33+
--disable-phpdbg \
34+
--with-pear \
35+
--enable-fileinfo \
36+
--disable-cgi
37+
1938
make -j$([[ "$(uname)" == "Darwin" ]] && sysctl -n hw.physicalcpu || nproc)
2039
sudo make install
2140
```

0 commit comments

Comments
 (0)