Repository navigation
Unable to build PHP 8.3.0 alpha 1 / fileinfo extension #11408
Copy link
Copy link
Closed
Description
Description
Hello,
I'm trying to provide PHP 8.3.0 in the Nix ecosystem and I'm unable to compile PHP 8.3.0 alpha1. The issue seems to come from the fileinfo extension, see the attached log.
Here's the output of the test 57547:
$ cat ./php-8.3.0alpha1/ext/fileinfo/tests/bug57547.out
───────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ File: ./php-8.3.0alpha1/ext/fileinfo/tests/bug57547.out
───────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 │ Warning: PHP Startup: Invalid library (maybe not a PHP library) '/build/php-8.3.0alpha1/ext/fileinfo/modules//fileinfo.so' in Unknown on line 0
2 │
3 │ Warning: PHP Startup: Invalid library (maybe not a PHP library) 'fileinfo.so' in Unknown on line 0
4 │
5 │ Fatal error: Uncaught Error: Class "finfo" not found in /build/php-8.3.0alpha1/ext/fileinfo/tests/bug57547.php:6
6 │ Stack trace:
7 │ #0 {main}
8 │ thrown in /build/php-8.3.0alpha1/ext/fileinfo/tests/bug57547.php on line 6
───────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
$
$ file ./php-8.3.0alpha1/ext/fileinfo/modules/fileinfo.so
./php-8.3.0alpha1/ext/fileinfo/modules/fileinfo.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, with debug_info, not stripped
$ ldd ./php-8.3.0alpha1/ext/fileinfo/modules/fileinfo.so
linux-vdso.so.1 (0x00007ffe6c1d0000)
libc.so.6 => /nix/store/flf14c3ibr83jsa070j25hg5gjapydhl-glibc-2.37-8/lib/libc.so.6 (0x00007f22d50fc000)
/nix/store/flf14c3ibr83jsa070j25hg5gjapydhl-glibc-2.37-8/lib64/ld-linux-x86-64.so.2 (0x00007f22d5a9f000)
$
$ readelf -a ./php-8.3.0alpha1/ext/fileinfo/modules/fileinfo.so
(See gist)
PHP Version
PHP 8.3.0
Operating System
NixOS
Activity
ramsey commentedon Jun 9, 2023
While no external libraries should be required to build the fileinfo extension, I do find this line from your logs interesting:
This command (and the accompanying libmagic library) is normally available on all Unix-like distributions. I'm not sure why it's missing. Install it, and see if that fixes the issue.
https://www.darwinsys.com/file/
jtojnar commentedon Jun 9, 2023
That error occurs because
configurescripts generated with old versions of Autotools look specifically for/usr/bin/file(which Nix does not have) rather than looking it up onPATH. But that can be safely ignored most of the time.Either way, I suspect this is something Nix specific and OP should check out what the “invalid” library is:
ramsey commentedon Jun 9, 2023
The "invalid library" is
fileinfo.so. It's invalid because it wasn't built properly, presumably because the system is missing something that PHP's build system expects.ramsey commentedon Jun 9, 2023
Never mind about my "missing libmagic/file" assumption. PHP ships with libmagic, so it doesn't need any anything from the system. https://github.com/php/php-src/tree/master/ext/fileinfo
I was hoping it was a missing system dependency, since that'd be easier to fix. 😄
ndossche commentedon Jun 9, 2023
Note: I don't use Nix, but I can't reproduce this on my distro (built as shared object).
I agree something must've gone wrong with your fileinfo.so build. Does it always happen or was this a one-time?
You can try to execute
file <location to fileinfo.so>to see if the file is corrupted (similarly check ifreadelfcomplains).drupol commentedon Jun 9, 2023
I updated the OP with the information requested, I will come back on the computer a bit later to dig a bit deeper. In the meantime, if you have a clue, let me know.
ndossche commentedon Jun 9, 2023
I see your .dynsym section doesn't contain an export for
get_modulewhich is the reason the extension loading fails. I just checked and my fileinfo.so build on my machine does. Not sure yet what could cause this tbh.LeSuisse commentedon Jun 21, 2023
I took a bit of time to bisect the issue using the Nix derivation, it seems to be present since these commits:
6219d7f
a24727a
a3dd514
The exact cause of the build issue is not yet clear to me.
ndossche commentedon Jun 22, 2023
Thanks for sticking through!
Could you please try this patch for me? This tries two things: force load the config; and also force the output of the get_module part.
If this works, does the following then also work (after you reverted the above patch)?
drupol commentedon Jun 22, 2023
Dear @nielsdos, I just tested with the first and the issue is still there.
I also tested with 8.3.0-alpha2 with no difference.
ndossche commentedon Jun 22, 2023
Thanks for testing. Are you able to share your config.h and the configure command line you used? This would help us reproduce the issue on our systems.
I will only be able to continue looking at this in the evening though.
drupol commentedon Jun 22, 2023
Here's the
config.h/tmp/nix-build-php-fileinfo-8.3.0.drv-1/php-8.3.0alpha2/ext/fileinfo/config.h
drupol commentedon Jun 22, 2023
I succeeded to build the extension, I was applying not applying the patch correctly the first time.
I confirm that both patches are working.
Fix phpGH-11408: Unable to build PHP 8.3.0 alpha 1 / fileinfo extension
ndossche commentedon Jun 22, 2023
Thanks @drupol I've submitted a PR to fix this, the fix will be in the next alpha.
Fix phpGH-11408: Unable to build PHP 8.3.0 alpha 1 / fileinfo extension