Skip to content
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

8.3.0 build fails on centos 8 with mbstring related error #12774

Closed
Xerkus opened this issue Nov 24, 2023 · 13 comments
Closed

8.3.0 build fails on centos 8 with mbstring related error #12774

Xerkus opened this issue Nov 24, 2023 · 13 comments

Comments

@Xerkus
Copy link

Xerkus commented Nov 24, 2023

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
php-build/php-build#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 #11603

PHP Version

8.3.0

Operating System

Centos 8

@nielsdos
Copy link
Member

nielsdos commented Nov 24, 2023

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.

@Girgias
Copy link
Member

Girgias commented Nov 27, 2023

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

@Girgias Girgias closed this as not planned Won't fix, can't repro, duplicate, stale Nov 27, 2023
@wheakerd
Copy link

wheakerd commented Jan 8, 2024

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.

@remicollet
Copy link
Member

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/

@nstiac
Copy link

nstiac commented Feb 3, 2024

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 ?

@nielsdos
Copy link
Member

nielsdos commented Feb 3, 2024

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.

@Xerkus
Copy link
Author

Xerkus commented Feb 4, 2024

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.

@jirikmik
Copy link

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.

@stevenhfotofix
Copy link

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

@nstiac
Copy link

nstiac commented Mar 28, 2024 via email

@stevenhfotofix
Copy link

stevenhfotofix commented Mar 28, 2024

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

@gdegoulet
Copy link
Contributor

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

@nstiac
Copy link

nstiac commented Aug 17, 2024

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.

craigcomstock added a commit to cfengine/buildscripts that referenced this issue Sep 5, 2024
- Modified php building for buggy old toolchains
php/php-src#12774
https://sourceware.org/bugzilla/show_bug.cgi?id=23169

- Patched php configure script for ubuntu-16 old gcc version 5
The check in php/build/php.m4 is not sufficient to guard for gcc 5 on ubuntu 16

Ticket: ENT-12140
Changelog: none.
craigcomstock added a commit to cfengine/buildscripts that referenced this issue Sep 5, 2024
- Modified php building for buggy old toolchains
php/php-src#12774
https://sourceware.org/bugzilla/show_bug.cgi?id=23169

- Patched php configure script for ubuntu-16 old gcc version 5
The check in php/build/php.m4 is not sufficient to guard for gcc 5 on ubuntu 16

Ticket: ENT-12140
Changelog: none.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants