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

`PHP_CHECK_PDO_INCLUDES` generates mangled output on PHP 8.0 and 8.1

Open NattyNarwhal opened this issue 4 years ago • 2 comments

Description

I've been trying to modernize the build system of an extension (specifically PDO_IBM, so we can do better CI), including replacing an old and crufty PDO check (that was having issues with how setup-php in an action set up the PHP prefix) with the new hotness, PHP_CHECK_PDO_INCLUDES that the built-in extensions have been using for a long while now.

However, not all is rosy. While the build works after changing to use the PHP macro instead of the old logic in 7.3, 7.4, and 8.1, it does not work in 8.0, and I can reproduce that with Fedora's build of 8.0.

I have some quick notes and comparisons in a gist, comparing CI matrix results + testing on my local system with 8.0 and reverting my change to use the old style of PDO include check. The outputs are from libtool normalizing the outputs plus what the generated Makefile looks like. Notably, the spot where there should the path to the extension is empty when using the PHP_CHECK_PDO_INCLUDES. I suspect what then happens is gcc looks for the next arg for the include path, and eats that. In the 8.1 case, it seems it eats -c, which obviously is Not Good for an object being built, giving you output like this:

/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/11/../../../../lib64/crt1.o: in function `_start':
(.text+0x1b): undefined reference to `main'
/usr/bin/ld: /tmp/ccBcJS2Z.o: in function `zm_startup_pdo_ibm':
/home/calvin/src/pecl-database-pdo_ibm/pdo_ibm.c:131: undefined reference to `php_pdo_get_dbh_ce'
/usr/bin/ld: /home/calvin/src/pecl-database-pdo_ibm/pdo_ibm.c:131: undefined reference to `zend_declare_class_constant_long'
/usr/bin/ld: /home/calvin/src/pecl-database-pdo_ibm/pdo_ibm.c:132: undefined reference to `php_pdo_get_dbh_ce'
[...]

8.1 is also suffering from this issue, but it seems it's eating a -D, which is not ideal but papers over the issue. 7.x seems fine. I'm wondering if this might be an issue in PHP or if there's an issue in the extension's build script I'm missing

PHP Version

PHP 8.0.15

Operating System

Fedora 35

NattyNarwhal avatar Feb 11 '22 17:02 NattyNarwhal

You also need to change the variable name for the PHP_NEW_EXTENSION invocation: https://github.com/php/pecl-database-pdo_ibm/blob/6510dd4e9a4de052763693bcce8ddc78945eeafc/config.m4#L101-L105. I think that should solve the issue.

cmb69 avatar Feb 17 '22 13:02 cmb69

Ah, you're right! Mea culpa, but it's quite a subtle one...

NattyNarwhal avatar Feb 17 '22 19:02 NattyNarwhal