php-src icon indicating copy to clipboard operation
php-src copied to clipboard

8.3.0 build fails on centos 8 with mbstring related error

Open Xerkus opened this issue 3 years ago • 14 comments

Description

PHP 8.3.0 build fails on centos 8 with the error:

/usr/bin/ld: dynamic STT_GNU_IFUNC symbol `mb_utf16be_to_wchar' with pointer equality in `ext/mbstring/libmbfl/filters/mbfilter_utf16.o' can not be used when making an executable; recompile with -fPIE and relink with -pie
collect2: error: ld returned 1 exit status

Original failure discovered during 8.3.0 build at https://github.com/php-build/php-build/pull/759

Recreated locally in centos:8 docker image running configure and make directly. Full build log output available here https://gist.github.com/Xerkus/185b0a566abe8acee620b9a0ae84468d

Used configure as follows, no env variables used:

./configure --with-config-file-path=/tmp/php-build-test-20231124174343/8.3.0/etc \
  --with-config-file-scan-dir=/tmp/php-build-test-20231124174343/8.3.0/etc/conf.d \
  --prefix=/tmp/php-build-test-20231124174343/8.3.0 \
  --libexecdir=/tmp/php-build-test-20231124174343/8.3.0/libexec \
  --datadir=/tmp/php-build-test-20231124174343/8.3.0/share/php \
  --mandir=/tmp/php-build-test-20231124174343/8.3.0/share/man \
  --enable-sockets \
  --enable-exif \
  --with-zlib \
  --with-zlib-dir=/usr \
  --with-bz2 \
  --enable-intl \
  --with-openssl \
  --enable-soap \
  --enable-xmlreader \
  --with-xsl --enable-ftp \
  --enable-cgi \
  --with-curl=/usr \
  --with-tidy \
  --enable-sysvsem \
  --enable-sysvshm \
  --enable-shmop \
  --with-mysqli=mysqlnd \
  --with-pdo-mysql=mysqlnd \
  --with-pdo-sqlite \
  --enable-pcntl \
  --with-readline \
  --enable-mbstring \
  --disable-debug \
  --enable-fpm \
  --enable-bcmath \
  --enable-phpdbg \
  --enable-gd \
  --with-jpeg \
  --with-zip \
  --with-mhash \
  --with-libdir=lib64  

This issue looks similar to me https://github.com/php/php-src/issues/11603

PHP Version

8.3.0

Operating System

Centos 8

Xerkus avatar Nov 24 '23 18:11 Xerkus

This is actually this issue: https://sourceware.org/bugzilla/show_bug.cgi?id=23169 That was fixed in binutils 2.31, but CentOS8 uses version 2.30 which is old (almost 6 years: Jan 2018). I don't know how to work around this, it's not like we can check via a macro the binutils version but we could in principle test during configure if this is broken (although I prefer not to)... In any case I really recommend you to use a modern toolchain.

ndossche avatar Nov 24 '23 23:11 ndossche

I am going to close this as this is not a bug in PHP.

Girgias avatar Nov 27 '23 03:11 Girgias

Remove binutils from Centos 8 stream and remove them from https://ftp.gnu.org/gnu/binutils/ Compile and install the latest source code from Zhongla. This will solve this problem.

wheakerd avatar Jan 08 '24 11:01 wheakerd

Notice: I'm used to build all PHP versions (up to 8.3) on EL-7, EL-8 and EL-9, and never encounter this issue.

If you need recent versions, simply use https://rpms.remirepo.net/wizard/

remicollet avatar Jan 09 '24 07:01 remicollet

So all users of Centos8 / Almalinux 8 / Rockylinux 8 should just resign to not using PHP 8.3 and newer because of a compiler bug that you are very well capable of bypassing so far much easier than an entire family of users removing an integral part of the original OS with a plethora of unexpected consequences ?

nstiac avatar Feb 03 '24 22:02 nstiac

Why should I spend my free time in the weekend providing a workaround for an oerating system that the company is dropping support for, and shipping the operating system with a known compiler bug? Makes no sense to me.

In any case, feel free to provide a PR.

ndossche avatar Feb 03 '24 22:02 ndossche

So all users of Centos8 / Almalinux 8 / Rockylinux 8 should just resign to not using PHP 8.3 and newer because of a compiler bug that you are very well capable of bypassing so far much easier than an entire family of users removing an integral part of the original OS with a plethora of unexpected consequences ?

Or, hear me out, they discover here default binutils is too old in their EOL os, so they install and enable newer devtoolset with recent binutils and happily build php 8.3 using that.

Xerkus avatar Feb 04 '24 02:02 Xerkus

In Almalinux 8 it is possible to add newer gcc for example by dnf install gcc-toolset-13 and build PHP 8.3 with mbstring against it.

jirikmik avatar Feb 23 '24 16:02 jirikmik

In Almalinux 8 it is possible to add newer gcc for example by dnf install gcc-toolset-13 and build PHP 8.3 with mbstring against it.

Thank you jirikmik, you saved me a lot of headaches.

To follow up with that, so you don't have to look it up - after installing the toolset you can use this command to run make:

scl enable gcc-toolset-13 make

stevenhfotofix avatar Mar 28 '24 20:03 stevenhfotofix

I wouldn't recommend installing a newer gcc just like that. I did and it turned up braking other things that were dynamically linked to the older library but were being given the new one even when installed purposefully with this in mind and even when reinstalled/recompiled with the newer gcc .. it became hell. But hey.. maybe it was just me and some setting I mishandled or the fact that not all of the software is on the latests available versions (because we need it to be like that due to some old code still working on older versions and because Centos itself does not work well with the latest versions)

Yahoo Mail: Search, Organize, Conquer

On Thu, Mar 28, 2024 at 3:11 PM, Steven @.***> wrote:

In Almalinux 8 it is possible to add newer gcc for example by dnf install gcc-toolset-13 and build PHP 8.3 with mbstring against it.

Thank you jirikmik, you saved me a lot of headaches.

To follow up with that, so you don't have to look it up - after installing the toolset you can use this command to run make:

scl enable gcc-toolset-13 make

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

nstiac avatar Mar 28 '24 21:03 nstiac

Using the toolset doesn't replace the GCC already installed, it sets up its own environment. While I am still testing things, the compile went through without problems (PHP 8.3.4 on AlmaLinux 8.9) and I am not getting any issues so far after compiling without specifying the GCC directly from the compiled php binary.

For others doing research on getting past this issue and wishing to do some research, here are a few links:

More details about Software Collections

https://access.redhat.com/documentation/en-us/red_hat_software_collections/3/html/packaging_guide/sect-enabling_the_software_collection

The toolset jirikmik referred to:

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/developing_c_and_cpp_applications_in_rhel_8/additional-toolsets-for-development_developing-applications

stevenhfotofix avatar Mar 28 '24 21:03 stevenhfotofix

Workaround if you don't want to install gcc-toolset-* : configure with --enable-mbstring=shared this issue occured only if mbstring is not compiled as a shared extension (you also need to add extension=mbstring.so to your php.ini) @remicollet : that's why you never encounter this issue since you provide a shared extension

gdegoulet avatar Jun 06 '24 11:06 gdegoulet

Workaround if you don't want to install gcc-toolset-* : configure with --enable-mbstring=shared this issue occured only if mbstring is not compiled as a shared extension (you also need to add extension=mbstring.so to your php.ini) @remicollet : that's why you never encounter this issue since you provide a shared extension

Thank you @gdegoulet .. this was by far the best and easiest option to make it work.

nstiac avatar Aug 17 '24 19:08 nstiac

I tried compiling php 8.4.2, and had this error using gcc 12, gcc 8 and probably the same with gcc 4 if not more errors:- dynamic STT_GNU_IFUNC symbol mb_utf16be_to_wchar' with pointer equality in ext/mbstring/libmbfl/filters/mbfilter_utf16.o'

Using --enable-mbstring=shared fixed this, many thanks for @gdegoulet.

InputOutputZ avatar Jan 13 '25 12:01 InputOutputZ