Skip to content

Expand PHP build to be more featureful #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
87 changes: 68 additions & 19 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ jobs:
# build: pnpm build --target aarch64-apple-darwin
build: pnpm build
setup: |
brew install autoconf automake libtool re2c bison libiconv
brew install autoconf automake libtool re2c bison libiconv \
argon2 libzip

# TODO: Do we need to care about x86_64 macOS?
# NOTE: Unable to force link bison on macOS 13, which php-src requires.
Expand All @@ -51,7 +52,8 @@ jobs:
# build: pnpm build --target x86_64-apple-darwin
build: pnpm build
setup: |
brew install autoconf automake libtool re2c bison libiconv
brew install autoconf automake libtool re2c bison libiconv \
argon2 libzip

#
# Linux
Expand All @@ -64,10 +66,12 @@ jobs:
# build: pnpm build --target x86_64-unknown-linux-gnu
build: pnpm build
setup: |
sudo apt-get update
sudo apt-get install -y libssl-dev pkg-config build-essential \
apt-get update
apt-get install -y curl libssl-dev pkg-config build-essential \
libcurl4-openssl-dev autoconf libxml2-dev libsqlite3-dev \
bison re2c libonig-dev patchelf
bison re2c libonig-dev patchelf zlib1g-dev openssh-client git \
libclang-dev libreadline-dev libpng-dev libjpeg-dev libzip-dev \
libsodium-dev libargon2-dev

# TODO: Can't use the musl container, need to build with ssh-agent access.
# TODO: Fails because missing x86_64-linux-musl-gcc
Expand Down Expand Up @@ -152,17 +156,42 @@ jobs:
if: ${{ !matrix.settings.docker }}
shell: bash
run: |
set -x
${{ matrix.settings.setup }}

# Use brew bison and libiconv manually. Force linking does not work on macOS 13
if [[ "$(uname)" == "Darwin" ]]; then
export PATH="$(brew --prefix bison)/bin:$(brew --prefix libiconv)/bin:$PATH"
export LDFLAGS="$LDFLAGS -L$(brew --prefix bison)/lib -L$(brew --prefix libiconv)/lib"
# Expose bison to compiler
export PATH="$(brew --prefix bison)/bin:$PATH"
export LDFLAGS="$LDFLAGS -L$(brew --prefix bison)/lib"
export CPPFLAGS="$CPPFLAGS -I$(brew --prefix bison)/include"
fi

cd php-src
./buildconf
./configure --enable-shared --enable-embed=shared --enable-zts --without-iconv --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-openssl --with-curl --enable-mbstring

# TODO: Figure out why macOS can't find libiconv and libpng (for gd)
./configure \
--enable-shared --enable-embed=shared \
--with-config-file-path=/usr/local/etc/php \
--with-config-file-scan-dir=/usr/local/etc/php/conf.d \
--enable-option-checking=fatal \
--with-pic \
--enable-zts \
--enable-mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd \
--with-pdo-sqlite=/usr --with-sqlite3=/usr \
--with-openssl --with-password-argon2 --with-sodium=shared \
--with-curl \
--enable-mbstring --with-mhash \
--enable-exif `#--enable-gd` \
--with-zip --with-zlib \
--without-iconv \
--without-readline \
--disable-phpdbg \
--with-pear \
--enable-fileinfo \
--disable-cgi

make -j$([[ "$(uname)" == "Darwin" ]] && sysctl -n hw.physicalcpu || nproc)
sudo make install
cd ..
Expand All @@ -178,12 +207,8 @@ jobs:
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'
shell: bash
run: |
# Can't use the setup script because docker lacks sudo
apt-get update
apt-get install -y curl libssl-dev pkg-config build-essential \
libcurl4-openssl-dev autoconf libxml2-dev libsqlite3-dev \
bison re2c libonig-dev patchelf zlib1g-dev openssh-client git \
libclang-dev
set -x
${{ matrix.settings.setup }}

# Install rust toolchain
curl https://sh.rustup.rs -sSf | bash -s -- -y -t ${{ matrix.settings.target }}
Expand All @@ -206,8 +231,30 @@ jobs:

# Build PHP
cd php-src
./buildconf
./configure --enable-shared --enable-embed=shared --enable-zts --without-iconv --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-openssl --with-curl --enable-mbstring
./buildconf --force

./configure \
--prefix=/usr \
--enable-shared --enable-embed=shared \
--with-config-file-path=/usr/local/etc/php \
--with-config-file-scan-dir=/usr/local/etc/php/conf.d \
--enable-option-checking=fatal \
--with-pic \
--enable-zts \
--enable-mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd \
--with-pdo-sqlite=/usr --with-sqlite3=/usr \
--with-openssl --with-password-argon2 --with-sodium=shared \
--with-curl \
--enable-mbstring --with-mhash \
--enable-exif --enable-gd \
--with-zip --with-zlib \
--without-iconv \
--with-readline \
--disable-phpdbg \
--with-pear \
--enable-fileinfo \
--disable-cgi

make -j$([[ "$(uname)" == "Darwin" ]] && sysctl -n hw.physicalcpu || nproc)
make install
cd ..
Expand Down Expand Up @@ -267,12 +314,12 @@ jobs:
target: x86_64-apple-darwin
architecture: x64
setup: |
brew install openssl@3
brew install openssl@3 argon2
- host: macos-15
target: aarch64-apple-darwin
architecture: arm64
setup: |
brew install openssl@3
brew install openssl@3 argon2 libzip
# - host: windows-latest
# target: x86_64-pc-windows-msvc
# architecture: x64
Expand Down Expand Up @@ -390,7 +437,9 @@ jobs:
apt-get update
apt-get install -y libssl-dev pkg-config build-essential \
libcurl4-openssl-dev autoconf libxml2-dev libsqlite3-dev \
bison re2c libonig-dev
bison re2c libonig-dev libargon2-dev libzip-dev zlib1g-dev \
openssh-client libclang-dev libreadline-dev libpng-dev \
libjpeg-dev libsodium-dev

npm run test

Expand Down
33 changes: 26 additions & 7 deletions INTERNALS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,34 @@ Building PHP itself is straightforward. Here's the basic configuration:
```sh
git clone https://github.com/php/php-src.git
cd php-src
./buildconf
./configure --enable-shared --enable-embed=shared --enable-zts --without-iconv --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-openssl --with-curl --enable-mbstring
make -j$([[ "$(uname)" == "Darwin" ]] && sysctl -n hw.physicalcpu || nproc)
sudo make install
```

```sh
if [[ "$(uname)" == "Darwin" ]]; then
export PATH="$(brew --prefix bison)/bin:$(brew --prefix libiconv)/bin:$PATH"
export LDFLAGS="$LDFLAGS -L$(brew --prefix bison)/lib -L$(brew --prefix libiconv)/lib -L$(brew --prefix readline)/lib"
fi

./buildconf
./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
./configure \
--enable-shared --enable-embed=shared \
--with-config-file-path=/usr/local/etc/php \
--with-config-file-scan-dir=/usr/local/etc/php/conf.d \
--enable-option-checking=fatal \
--with-pic \
--enable-zts \
--enable-mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd \
--with-pdo-sqlite=/usr --with-sqlite3=/usr \
--with-openssl --with-password-argon2 --with-sodium=shared \
--with-curl \
--enable-mbstring --with-mhash \
--enable-exif --enable-gd \
--with-zip --with-zlib \
--without-iconv \
--with-readline \
--disable-phpdbg \
--with-pear \
--enable-fileinfo \
--disable-cgi

make -j$([[ "$(uname)" == "Darwin" ]] && sysctl -n hw.physicalcpu || nproc)
sudo make install
```
Expand Down
Loading