Bug #80197 [Opn]: implicit declaration of function 'magic_stream' is invalid
| From: | nikic@php.net | Date: | Thu, 03 Dec 2020 09:21:35 +0000 |
| Subject: | Bug #80197 [Opn]: implicit declaration of function 'magic_stream' is invalid | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-230817@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80197&edit=1
ID: 80197
Updated by: nikic@php.net
Reported by: mkoula@php.net
Summary: implicit declaration of function 'magic_stream' is
invalid
Status: Open
Type: Bug
Package: PHP options/info functions
Operating System: macOS Catalina 10.15.7
PHP Version: 8.0.0
Block user comment: N
Private report: N
New Comment:
Well, I guess we now found out why it was adding the extension CFLAGS to the start rather than the
end...
It sounds like it will be necessary to filter the flags and place some of them before (-I) and some
after (-W).
Always great when there's a random mix of earlier options and later options taking priority...
Previous Comments:
------------------------------------------------------------------------
[2020-12-03 05:35:59] php-bugs-2020 at ryandesign dot com
As I said, putting -isystem/opt/local/include in CPPFLAGS when you call ./configure works around the
issues. php80 will be in MacPorts shortly and I'm including that workaround there.
------------------------------------------------------------------------
[2020-12-02 23:53:01] mkoula@php.net
@ryandesign - I am waiting for the MacPorts version :D
Anyway, I compiled the released 8.0.0 version on the latest macOS BigSur and it died on the GD
Library on exactly the same issue.
Then I compiled PHP without GD Library and image support and it went fine. It works, later I even
compiled some pecl extensions like igbinary, redis, APCu and this also worked.
I didn't have time to investigate further, but with this 'configure' I used:
'./configure' '--prefix=/opt/local' '--sysconfdir=/opt/local/php80'
'--program-suffix=80' '--with-config-file-path=/opt/local/etc/php80'
'--with-config-file-scan-dir=/opt/local/etc/php80/conf.d' '--enable-bcmath'
'--enable-calendar' '--enable-ftp' '--enable-fpm'
'--enable-intl' '--enable-mbregex' '--enable-mbstring'
'--enable-mysqlnd' '--enable-pcntl' '--enable-soap'
'--enable-sockets' '--enable-sysvmsg' '--enable-sysvsem'
'--enable-sysvshm' '--enable-opcache' '--with-curl'
'--with-fpm-user=_www' '--with-fpm-group=_www'
'--with-iconv=/opt/local' '--with-libxml' '--with-layout=GNU'
'--with-mysql-sock=/tmp/mysql.sock' '--with-openssl'
'--with-pdo-mysql=mysqlnd' '--with-pdo-pgsql=/opt/local/lib/postgresql13'
'--with-pdo-sqlite' '--with-pgsql=/opt/local/lib/postgresql13'
'--with-sqlite3' '--with-xsl' '--with-zip' '--with-zlib'
------------------------------------------------------------------------
[2020-12-02 23:39:22] php-bugs-2020 at ryandesign dot com
I am encountering this as well as I try to add php 8.0.0 to MacPorts. libmagic (part of file 5.39)
is also installed with MacPorts, providing /opt/local/include/magic.h. You appear to bundle a
modified libmagic with php and want to include its headers.
The problem may be specific to the versions of clang shipped with Xcode 12 and later, which have
turned implicit declaration of function into an error. It used to be just a warning.
The problem appears to be that the -I flags are in the wrong order. Here is the compile line:
/bin/sh /path/to/php-8.0.0/libtool --silent --preserve-dup-deps --mode=compile ccache /usr/bin/clang
-Iext/fileinfo/ -I/path/to/php-8.0.0/ext/fileinfo/ -I/path/to/php-8.0.0/include
-I/path/to/php-8.0.0/main -I/path/to/php-8.0.0 -I/path/to/php-8.0.0/ext/date/lib
-I/opt/local/include/libxml2 -I/opt/local/include -I/opt/local/include/editline
-I/path/to/php-8.0.0/TSRM -I/path/to/php-8.0.0/Zend -I/opt/local/include -no-cpp-precomp -Wall
-Wextra -Wno-strict-aliasing -Wno-implicit-fallthrough -Wno-unused-parameter -Wno-sign-compare -pipe
-Os -Werror=implicit-function-declaration -arch x86_64 -fvisibility=hidden -DZEND_SIGNALS
-I/path/to/php-8.0.0/ext/fileinfo/libmagic -c /path/to/php-8.0.0/ext/fileinfo/fileinfo.c -o
ext/fileinfo/fileinfo.lo
Note that -I/opt/local/include (which comes from user-specified (or in my case MacPorts-specified)
CPPFLAGS) precedes project-local paths like -I/path/to/php-8.0.0/ext/fileinfo/libmagic. All
project-local -I flags should precede global -I flags so that you don't accidentally include
system headers instead of your local files.
This problem does not happen with php 7.4.13 or earlier. There the compile line is:
/bin/sh /path/to/php-7.4.13/libtool --silent --preserve-dup-deps --mode=compile ccache
/usr/bin/clang -I/path/to/php-7.4.13/ext/fileinfo/libmagic -Iext/fileinfo/
-I/path/to/php-7.4.13/ext/fileinfo/ -DPHP_ATOM_INC -I/path/to/php-7.4.13/include
-I/path/to/php-7.4.13/main -I/path/to/php-7.4.13 -I/path/to/php-7.4.13/ext/date/lib
-I/opt/local/include/libxml2 -I/opt/local/include -I/opt/local/include/editline
-I/path/to/php-7.4.13/TSRM -I/path/to/php-7.4.13/Zend -I/opt/local/include -no-cpp-precomp -pipe
-Os -Werror=implicit-function-declaration -arch x86_64 -fvisibility=hidden -Wall
-Wno-strict-aliasing -DZEND_SIGNALS -c /path/to/php-7.4.13/ext/fileinfo/fileinfo.c -o
ext/fileinfo/fileinfo.lo
Note how -I/path/to/php-7.4.13/ext/fileinfo/libmagic appears earlier in the compile line, before
-I/opt/local/include, thus ensuring that your modified copy of magic.h gets used instead of a
standard one that might be installed in a system directory.
I'm not sure what changed in php 8 to cause the order of -I flags to change.
Until the order of -I flags is fixed in the php build system, a workaround for the user could be to
deactivate or uninstall libmagic before installing php 8. Another workaround for the user could be
to add -isystem/opt/local/include to CPPFLAGS, which will override any existing -I/opt/local/include
to ensure /opt/local/include gets placed at the end of the search path regardless of where it
appears on the compile line.
------------------------------------------------------------------------
[2020-10-16 08:53:32] cmb@php.net
Not sure what exactly might be wrong with GD, but that libmagic
include line looks wrong to me. Isn't that a bug that should be
fixed for PHP-7.3[1] upwards?
[1] <https://github.com/php/php-src/blob/php-7.3.23/ext/fileinfo/fileinfo.c#L24>
------------------------------------------------------------------------
[2020-10-15 13:07:46] mkoula@php.net
I tried this
#include "libmagic/magic.h",
and seemed to be working but then I had similar issues in GD library in multiple files. I also used
the local links and I was able to finally compiled it, but just calling PHP in cli produces
segmentation faut.
Strage is that beta worked fine for me without issues an RC not. So I wait for another release...
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=80197
--
Edit this bug report at https://bugs.php.net/bug.php?id=80197&edit=1