Topic: php 8 compiler define error

Hi Remi,

I'm running into an issue with PHP 8 and v8js.  I'm not sure if it is related to your packages, but I was hoping you could help narrow it down:

I'm running CentOS 8 and PHP 8, and trying to compile v8js which is not officially ready for PHP 8 (https://github.com/phpv8/v8js/issues/458), but when I was trying the PR posted in that issue, I'm getting an odd compile error:

In file included from /usr/local/src/v8js-php8/php_v8js_macros.h:35,
                 from /usr/local/src/v8js-php8/v8js_v8.cc:19:
/opt/remi/php80/root/usr/include/php/main/php_config.h:26:18: error: expected identifier before string constant
 #define COMPILER "gcc (GCC) 8.3.1 20191121 (Red Hat 8.3.1-5)"
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/remi/php80/root/usr/include/php/main/php_config.h:26:18: note: in definition of macro ‘COMPILER’
 #define COMPILER "gcc (GCC) 8.3.1 20191121 (Red Hat 8.3.1-5)"
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/remi/php80/root/usr/include/php/main/php_config.h:26:18: error: expected ‘}’ before string constant
 #define COMPILER "gcc (GCC) 8.3.1 20191121 (Red Hat 8.3.1-5)"
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/remi/php80/root/usr/include/php/main/php_config.h:26:18: note: in definition of macro ‘COMPILER’
 #define COMPILER "gcc (GCC) 8.3.1 20191121 (Red Hat 8.3.1-5)"
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I don't know C/C++ well-enough, but if I remove the "#define COMPILER" line in php_config.h, it compiles cleanly.  If I change COMPILER to be something else like COMPILER123, then it compiles cleanly too.  I don't see COMPILER defined in php_config.h in PHP 7.4.

From looking at other included files, v8/include/v8.h defines an enum called StateTag with a value of COMPILER - see https://github.com/v8/v8/blob/master/include/v8.h#L2359.  If I comment out that line, then it compiles cleanly too.

I tried compiling PHP 8 manually, and v8js compiled cleanly since my php_config.h had "/* #undef COMPILER */" for that line.

Could the 2 constants be conflicting in some form?  Do you have any recommendations on how to best resolve it?

Thank you for your help.

Ryan

Re: php 8 compiler define error

Hmm... interesting

COMPILER is an optional constant define at build time and used to be displayed in phpinfo

phpinfo()
PHP Version => 8.0.1RC1

System => Linux builder.remirepo.net 5.9.15-200.fc33.x86_64 #1 SMP Wed Dec 16 19:14:35 UTC 2020 x86_64
Build Date => Dec 15 2020 12:57:35
Build System => Fedora release 33 (Thirty Three)
Build Provider => Remi's RPM repository <https://rpms.remirepo.net/>
Compiler => gcc (GCC) 10.2.1 20201125 (Red Hat 10.2.1-9)
Architecture => x86_64
...

This constant exists for year and was mostly used only in windows build.
Provided in my build since PHP 8 to improve information, especially for support

Need to think on how to properly fix it

Seems too late to change its name now
Will be sad to remove it
...

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

Re: php 8 compiler define error

After thinking about this, seems better to rename the macros which are too generic

PR open for discussion
https://github.com/php/php-src/pull/6546

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

Re: php 8 compiler define error

Great, thanks for looking it and your quick response to resolve it.

Re: php 8 compiler define error

Fixed upstream in 8.1

Patch backported in my repo for 8.0.1 packages.

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi