Linux

How to Fix: dynamic STT_GNU_IFUNC symbol mb_utf16be_to_wchar Error When Compiling PHP

Step 1: Enable gcc-toolset-13

On AlmaLinux, Rocky Linux, CentOS Stream 8/9:

dnf install -y gcc-toolset-13

On RHEL (with subscription enabled):

subscription-manager repos --enable codeready-builder-for-rhel-9-$(arch)-rpms
dnf install -y gcc-toolset-13

Step 2: Activate the New Toolchain

You can either enable it for the current shell session:

scl enable gcc-toolset-13 bash

or (on newer distros):

source /opt/rh/gcc-toolset-13/enable

Check version:

gcc --version

You should now see something like:

gcc (GCC) 13.x.x

Step 3: Rebuild PHP

If you are compiling PHP manually:
cd /usr/local/src/php-8.x.x
make clean
./configure --enable-fpm --with-openssl ...   # your usual options
make -j$(nproc)
make install

If you are using DirectAdmin CustomBuild:

cd /usr/local/directadmin/custombuild
./build clean
./build php n

Step 4: Make gcc-toolset-13 Permanent (Optional)

echo "source /opt/rh/gcc-toolset-13/enable" >> /etc/profile.d/gcc-toolset-13.sh

Now every new login shell will automatically use gcc-13.