|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80197 implicit declaration of function 'magic_stream' is invalid
Submitted: 2020-10-07 11:45 UTC Modified: 2020-10-16 08:53 UTC
From: Assigned:
Status: Open Package: PHP options/info functions
PHP Version: 8.0.0rc1 OS: macOS Catalina 10.15.7
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
New email:
PHP Version: OS:


 [2020-10-07 11:45 UTC]
I previously compiled 8.0.0beta3 and worked fine. Today I run the same configuration on 8.0.0rc1 and configure went through fine and then when I ran make  command it died with the message:

/Users/mIREK/compile/php8/php-8.0.0rc1/ext/fileinfo/fileinfo.c:429:24: error: implicit declaration of function 'magic_stream' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                                ret_val = (char *) magic_stream(magic, stream);
/Users/mIREK/compile/php8/php-8.0.0rc1/ext/fileinfo/fileinfo.c:429:24: note: did you mean 'magic_setparam'?
/opt/local/include/magic.h:153:5: note: 'magic_setparam' declared here
int magic_setparam(magic_t, int, const void *);
/Users/mIREK/compile/php8/php-8.0.0rc1/ext/fileinfo/fileinfo.c:429:15: warning: cast to 'char *' from smaller integer type 'int' [-Wint-to-pointer-cast]
                                ret_val = (char *) magic_stream(magic, stream);
/Users/mIREK/compile/php8/php-8.0.0rc1/ext/fileinfo/fileinfo.c:477:25: error: implicit declaration of function 'magic_stream' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
                                                ret_val = (char *)magic_stream(magic, stream);
/Users/mIREK/compile/php8/php-8.0.0rc1/ext/fileinfo/fileinfo.c:477:17: warning: cast to 'char *' from smaller integer type 'int' [-Wint-to-pointer-cast]
                                                ret_val = (char *)magic_stream(magic, stream);
2 warnings and 2 errors generated.
make: *** [ext/fileinfo/fileinfo.lo] Error 1

As a configure I used this, which for beta worked fine:

./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-exif \
--enable-ftp \
--enable-fpm \
--enable-gd \
--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-freetype \
--with-iconv=/opt/local \
--with-libxml \
--with-jpeg \
--with-layout=GNU \
--with-mysql-sock=/tmp/mysql.sock \
--with-openssl \
--with-pdo-mysql=mysqlnd \
--with-pdo-pgsql=/opt/local/lib/postgresql12 \
--with-pdo-sqlite \
--with-pgsql=/opt/local/lib/postgresql12 \
--with-pic \
--with-sqlite3 \
--with-webp \
--with-xsl \
--with-zip \


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-10-07 11:54 UTC]
I did a diff of this file between beta and rc and the result is:

❯ diff /Users/mIREK/compile/php8/php-8.0.0rc1/ext/fileinfo/fileinfo.c /Users/mIREK/compile/php8/php-8.0.0beta3/ext/fileinfo/fileinfo.c
< 		zend_throw_error(NULL, "Invalid finfo object"); \
>         	php_error_docref(NULL, E_WARNING, "The invalid fileinfo object."); \
< 		php_error_docref(NULL, E_WARNING, "Failed to load magic database at \"%s\"", file);
> 		php_error_docref(NULL, E_WARNING, "Failed to load magic database at '%s'.", file);
< 			php_error_docref(NULL, E_WARNING, "Failed to load magic database");
> 			php_error_docref(NULL, E_WARNING, "Failed to load magic database.");
< 				zend_argument_type_error(1, "must not contain any null bytes");
> 				zend_argument_type_error(1, "must not contain null bytes");

So before it was Just warning and now it throws error, but I am not any C developer, I just can see that this was changed...
 [2020-10-07 12:20 UTC]
> /opt/local/include/magic.h

Apparently, the build includes the system header, although
that is undesired.  I think we want

 ext/fileinfo/fileinfo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ext/fileinfo/fileinfo.c b/ext/fileinfo/fileinfo.c
index 0a4ee3c34e..39343f06fc 100644
--- a/ext/fileinfo/fileinfo.c
+++ b/ext/fileinfo/fileinfo.c
@@ -19,7 +19,7 @@
 #include "php.h"
-#include <magic.h>
+#include "magic.h"
  * HOWMANY specifies the maximum offset libmagic will look at
  * this is currently hardcoded in the libmagic source but not exported

Also for PHP 7.3+.
 [2020-10-07 13:49 UTC]
I applied the diff change in ext/fileinfo/fileinfo.c, rerun configure and compile, but it still uses the /opt/local/include/magic.h

Is there any way of setup/configuration to force it use this the internal libmagic and this file?
 [2020-10-09 14:28 UTC]
Maybe #include "libmagic/magic.h"?
 [2020-10-15 10:29 UTC]
-Status: Open +Status: Feedback
 [2020-10-15 13:07 UTC]
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...
 [2020-10-16 08:53 UTC]
-Status: Feedback +Status: Open
 [2020-10-16 08:53 UTC]
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] <>
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Nov 29 09:01:24 2020 UTC