Same issue on Rocky Linux 8.
However i managed to fix it.
Two ways you can do it:
Installing gcc-toolset-12 or gcc-toolset-13 is not enough, you need to Activate the newer gcc-toolset-12 for the compilation.
edit the php.sh file and look for the Install_Configure() function:
at the end of the function you will see the block where php8.4 is being evaluated from:
if [ "${version}" == "8.3" ];then
./configure --prefix=${php_setup_path} --with-config-file-path=${php_setup_path}/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype --with-jpeg --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-intl --enable-pcntl --enable-ftp --enable-gd --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --with-gettext --disable-fileinfo --enable-opcache --with-sodium=/usr/local/libsodium --with-webp ${i_make_args} 2>&1|tee /tmp/php_config.pl
else
./configure --prefix=${php_setup_path} --with-config-file-path=${php_setup_path}/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype --with-jpeg --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-intl --enable-pcntl --enable-ftp --enable-gd --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --with-gettext --disable-fileinfo --enable-opcache --with-sodium=/usr/local/libsodium --with-webp ${i_make_args} 2>&1|tee /tmp/php_config.pl
fi
As you can see there is ifstatement for 8.3 but not for 8.4, the 8.4 version is being installed based on the else condition. (I also think this need to be fixed), anyway add this before the ifstatement.
source /opt/rh/gcc-toolset-13/enable
This will tell the function to use gcc-toolset for that specific compilation.
another solution which is easier is to add these variables before the if statement;
# Add the required security flags for the linker
export CFLAGS="$CFLAGS -fPIE"
export CXXFLAGS="$CXXFLAGS -fPIE"
export LDFLAGS="-pie"
This will compile mbstring with these required security flags.
Another solution is to change the php8.3 ifstatement block to include php 8.4. Because on the php 8.3 ifstatement mbstring is not specified.
With newer PHP version such as php 8.4 you really do not need to specify mbstring at the compilation as long you have intl compiled. Just replace with this:
elif [ "${php_version}" == "74" ] || [ "${php_version}" -ge "80" ]; then