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

Building ext/intl fails with GCC 8.5.0 #17107

Open
adeshmrane opened this issue Dec 10, 2024 · 8 comments · May be fixed by #17179
Open

Building ext/intl fails with GCC 8.5.0 #17107

adeshmrane opened this issue Dec 10, 2024 · 8 comments · May be fixed by #17179

Comments

@adeshmrane
Copy link

adeshmrane commented Dec 10, 2024

Description

I am trying to compile PHP 8.4.1 on AlmaLinux release 8.10

When I enable the IMAPintl extension with the --enable-intl=shared option i ran into below errors.

/usr/lib/gcc/x86_64-redhat-linux/8/include/stddef.h:437:2: error: expected ‘;’ after struct definition
 } max_align_t;
  ^
  ;
/usr/lib/gcc/x86_64-redhat-linux/8/include/stddef.h:437:1: error: missing type-name in typedef-declaration
 } max_align_t;
 ^
/usr/lib/gcc/x86_64-redhat-linux/8/include/stddef.h:437:14: error: expected unqualified-id before ‘;’ token
 } max_align_t;
              ^
<command-line>: error: expected unqualified-id before ‘void’
In file included from /setups/php-8.4.1/Zend/zend_portability.h:798,
                 from /setups/php-8.4.1/Zend/zend_types.h:25,
                 from /setups/php-8.4.1/ext/intl/intl_convertcpp.h:23,
                 from /setups/php-8.4.1/ext/intl/intl_convertcpp.cpp:17:
/usr/include/c++/8/cstddef:56:11: error: expected ‘;’ before ‘void’
   using ::max_align_t;
           ^
           ;
/usr/include/c++/8/cstddef:56:22: error: expected unqualified-id before ‘;’ token
   using ::max_align_t;
                      ^
<command-line>: error: expected unqualified-id before ‘void’
/setups/php-8.4.1/Zend/zend_portability.h:800:14: note: in expansion of macro ‘max_align_t’
 typedef std::max_align_t zend_max_align_t;
              ^~~~~~~~~~~
In file included from /setups/php-8.4.1/main/php.h:31,
                 from /setups/php-8.4.1/ext/intl/intl_convertcpp.cpp:20:
/setups/php-8.4.1/Zend/zend.h:240:2: error: ‘zend_max_align_t’ does not name a type; did you mean ‘max_align_t’?
  zend_max_align_t align;
  ^~~~~~~~~~~~~~~~
  max_align_t

I am using gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-22)

PHP Version

php 8.4.1

Operating System

AlmaLinux release 8.10

@iluuu1994
Copy link
Member

Getting error for installing IMAP extension

To clarify: You mean intl, not imap? The imap extension now lives at https://github.com/php/pecl-mail-imap.

@cmb69
Copy link
Member

cmb69 commented Dec 10, 2024

#include <stddef.h>

vs

# include <cstddef>

I guess.

@cmb69 cmb69 changed the title Getting error for installing IMAP extension Getting error for installing intl extension Dec 10, 2024
@cmb69
Copy link
Member

cmb69 commented Dec 13, 2024

This is caused by #15096. Need to double check whether including <cstddef> is really necessary (would better be avoided if possible).

@cmb69 cmb69 self-assigned this Dec 13, 2024
@cmb69
Copy link
Member

cmb69 commented Dec 14, 2024

I've checked that more thoroughly, and the problem is that stddef.h does not define max_align_t at all on Windows (regardless of the language standard specified). So prior to ab449a7 C builds would take the fallback definition (while C++ builds would fail). The fix was based on the assumption that additionally including cstdef as extern C++ would not interfere with the already included stddef.h, but that was apparently presumptuous; while GCC 8.5 is a bit old, it is not ancient.

An alternative fix would have been to just not relying on max_align_t being defined on Windows, instead of including cstddef for C++ builds. The fallback definition likely would have been okay in all circumstances for Windows (at least MSVC), since its size is 8, what matches the max_align_t definition in cstddef (where it is defined as double; note that long double is identical to double on Windows).

But dropping the cstddef include now might introduce an ABI break (what would be very bad). So I don't know what to do. Any suggestions welcome!

@adeshmrane
Copy link
Author

adeshmrane commented Dec 16, 2024

what is the minimum Linux operating system required to compile and build PHP 8.4.1?

@cmb69
Copy link
Member

cmb69 commented Dec 16, 2024

See https://www.php.net/manual/en/install.unix.source.php. Wrt to Linux distributions, we used to keep an eye on still supported CentOS versions (which were rather conservative), but this distribution is gone now. It seems that AlmaLinux 8 is supposed to get security updates till 2029 (PHP-8.4 on until end of 2028), so it might be a good idea to support that. And apparently, AlmaLinux 8.10 ships with GCC 8.5.0 by default.

@adeshmrane
Copy link
Author

However, I am getting issues with the same configuration.

is there any way I can solve that?

@cmb69 cmb69 changed the title Getting error for installing intl extension Building ext/intl fails with GCC 8.5.0 Dec 16, 2024
cmb69 added a commit to cmb69/php-src that referenced this issue Dec 16, 2024
A previous fix to be able to build C++ extensions with MSVC[1], was
based on two assumptions:

* `max_align_t` would be defined in stddef.h on Windows
* additionally including cstddef as extern C++ would not interfere with
  the already included stddef.h

The former was plain wrong; there is no such typedef (or macro); the
latter was presumptuous, as can be seen in the bug tracker ticket.

Thus we revert that fix, and instead make an exception for Windows,
where we always use the fallback definition, which should work fine on
Windows.

[1] <php@ab449a7>
@cmb69 cmb69 linked a pull request Dec 16, 2024 that will close this issue
@cmb69
Copy link
Member

cmb69 commented Dec 16, 2024

is there any way I can solve that?

You can try the patch from the linked PR, or upgrade GCC, I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants