php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65106 PHP fails to compile
Submitted: 2013-06-23 16:45 UTC Modified: 2023-01-23 12:55 UTC
Votes:15
Avg. Score:3.9 ± 1.1
Reproduced:14 of 14 (100.0%)
Same Version:2 (14.3%)
Same OS:4 (28.6%)
From: mark at kreine dot ru Assigned:
Status: Closed Package: Compile Failure
PHP Version: 5.5.0 OS: Ubuntu 12.04
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mark at kreine dot ru
New email:
PHP Version: OS:

 

 [2013-06-23 16:45 UTC] mark at kreine dot ru
Description:
------------
Hello,

I'm trying to compile PHP with the following configure command script:

./configure --prefix=/soft/php --with-apxs2=/soft/httpd/bin/apxs --with-libxml-dir=/soft/libxml --with-zlib-dir=/soft/zlib --with-zlib=shared,/soft/zlib --enable-bcmath --enable-exif --with-pcre-dir=/soft/pcre --with-jpeg-dir=/soft/libjpeg --with-png-dir=/soft/libpng --with-gd=shared --with-mysql=shared,/soft/mysql --with-mysqli=shared,/soft/mysql/bin/mysql_config --with-pdo-mysql=shared,/soft/mysql --enable-mbstring --enable-ftp --enable-calendar --enable-sockets --enable-soap --enable-zip

While configure ends successfully, make returns the following error:

/bin/bash /tmp/php-5.5.0/libtool --silent --preserve-dup-deps --mode=compile cc -I/tmp/php-5.5.0/ext/fileinfo/libmagic -Iext/fileinfo/ -I/tmp/php-5.5.0/ext/fileinfo/ -DPHP_ATOM_INC -I/tmp/php-5.5.0/include -I/tmp/php-5.5.0/main -I/tmp/php-5.5.0 -I/tmp/php-5.5.0/ext/date/lib -I/tmp/php-5.5.0/ext/ereg/regex -I/soft/libxml/include/libxml2 -I/soft/zlib/include -I/soft/libjpeg/include -I/soft/libpng/include -I/tmp/php-5.5.0/ext/mbstring/oniguruma -I/tmp/php-5.5.0/ext/mbstring/libmbfl -I/tmp/php-5.5.0/ext/mbstring/libmbfl/mbfl -I/soft/mysql/include/mysql -I/tmp/php-5.5.0/ext/sqlite3/libsqlite -I/tmp/php-5.5.0/TSRM -I/tmp/php-5.5.0/Zend    -I/usr/include -g -O2 -fvisibility=hidden  -c /tmp/php-5.5.0/ext/fileinfo/libmagic/apprentice.c -o ext/fileinfo/libmagic/apprentice.lo 
cc: internal compiler error: Killed (program cc1)


Then it says:
make: *** [ext/fileinfo/libmagic/apprentice.lo] Error 1

Test script:
---------------
./configure --prefix=/soft/php --with-apxs2=/soft/httpd/bin/apxs --with-libxml-dir=/soft/libxml --with-zlib-dir=/soft/zlib --with-zlib=shared,/soft/zlib --enable-bcmath --enable-exif --with-pcre-dir=/soft/pcre --with-jpeg-dir=/soft/libjpeg --with-png-dir=/soft/libpng --with-gd=shared --with-mysql=shared,/soft/mysql --with-mysqli=shared,/soft/mysql/bin/mysql_config --with-pdo-mysql=shared,/soft/mysql --enable-mbstring --enable-ftp --enable-calendar --enable-sockets --enable-soap --enable-zip

Expected result:
----------------
Successful configuration and compilation

Actual result:
--------------
Firstly:
/bin/bash /tmp/php-5.5.0/libtool --silent --preserve-dup-deps --mode=compile cc -I/tmp/php-5.5.0/ext/fileinfo/libmagic -Iext/fileinfo/ -I/tmp/php-5.5.0/ext/fileinfo/ -DPHP_ATOM_INC -I/tmp/php-5.5.0/include -I/tmp/php-5.5.0/main -I/tmp/php-5.5.0 -I/tmp/php-5.5.0/ext/date/lib -I/tmp/php-5.5.0/ext/ereg/regex -I/soft/libxml/include/libxml2 -I/soft/zlib/include -I/soft/libjpeg/include -I/soft/libpng/include -I/tmp/php-5.5.0/ext/mbstring/oniguruma -I/tmp/php-5.5.0/ext/mbstring/libmbfl -I/tmp/php-5.5.0/ext/mbstring/libmbfl/mbfl -I/soft/mysql/include/mysql -I/tmp/php-5.5.0/ext/sqlite3/libsqlite -I/tmp/php-5.5.0/TSRM -I/tmp/php-5.5.0/Zend    -I/usr/include -g -O2 -fvisibility=hidden  -c /tmp/php-5.5.0/ext/fileinfo/libmagic/apprentice.c -o ext/fileinfo/libmagic/apprentice.lo 
cc: internal compiler error: Killed (program cc1)

Then:
make: *** [ext/fileinfo/libmagic/apprentice.lo] Error 1

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-06-23 16:47 UTC] mark at kreine dot ru
-Operating System: CentOS 6.4 +Operating System: Ubuntu 12.04
 [2013-06-23 16:47 UTC] mark at kreine dot ru
Just edited operating system, first time erroneously was stated as CentOS 6.4
 [2013-06-23 17:07 UTC] rasmus@php.net
-Status: Open +Status: Feedback
 [2013-06-23 17:07 UTC] rasmus@php.net
Not much to go on there with just "internal compiler error". Thousands of people 
have compiled 5.5.0 successfully on Ubuntu 12.04 so I think you need to look at 
what specifically is different about this box of yours from everyone elses' 
Ubuntu setups. Low on ram? Bad ram perhaps? Try it on another machine?
 [2013-10-02 23:40 UTC] nhawks at gmail dot com
I just ran into this on a freshly-provisioned VPS. 
------------------------------------------------------------------------
Configure flags:
------------------------------------------------------------------------
'--with-readline=/usr/lib64' '--with-libedit=/usr/lib64' '--with-recode=/usr/lib64' '--includedir=/usr' '--libdir=/usr/lib64' '--with-libdir=lib64' '--with-gnu-ld' '--with-apxs2=/usr/local/apache2/bin/apxs' '--enable-phar' '--enable-bcmath' '--with-bz2' '--enable-calendar' '--enable-opcache=no' '--with-pic' '--with-curl=/usr' '--with-freetype-dir=/usr' '--with-png-dir=/usr' '--with-xpm-dir=/usr' '--enable-gd-native-ttf' '--with-gettext' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr' '--with-openssl' '--with-pspell' '--with-zlib' '--with-layout=GNU' '--enable-exif' '--enable-ftp' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-wddx' '--with-kerberos' '--enable-shmop' '--with-libxml-dir=/usr' '--enable-xml' '--enable-static' '--enable-mbstring' '--enable-mbregex' '--with-mcrypt=/usr' '--with-mhash=/usr' '--with-tidy=/usr' '--with-gd' '--with-xmlrpc' '--with-mysql=/usr' '--with-mysqli=/usr/bin/mysql_config' '--enable-dom' '--enable-soap' '--with-xsl=/usr' '--enable-xmlreader' '--enable-xmlwriter' '--enable-json' '--enable-zip' '--enable-fileinfo' '--enable-intl' '--with-icu-dir=/usr' '--with-enchant=/usr' '--disable-inifile' '--disable-flatfile' '--disable-posix' '--disable-debug' '--disable-rpath' '--without-pear' '--enable-pcntl' '--enable-dba' '--enable-maintainer-zts' '--without-sqlite3' '--without-pdo-sqlite'

(Using maintainer-zts for Event MTM... wasn't a problem on a previous build.)
------------------------------------------------------------------------
I apt-get install'd the following packages to satisfy various dependencies:
------------------------------------------------------------------------
 bison libpcre3 libpcre3-dev libssl-dev zlib1g zlib1g-devel libcurl4-openssl-dev libfreetype6-dev libpng12-dev libxpm-dev libjpeg62-dev libpspell-dev libxml2-dev libmcrypt-dev libmhash-dev libtidy-dev libzip-dev libicu-dev libenchant-dev libbz2-dev libedit-dev librecode-dev  libxslt1-dev libmagic-dev libgmp3-dev gpp g++ 
------------------------------------------------------------------------
Interestingly, PHP's configure script did NOT notify me, but I was missing libmagic at first. Installing libmagic-dev changed nothing (even after ldconfig/reboot). Yes, /usr/lib64 and /lib64 are in /etc/ld.so.conf.d/lib64. (Perhaps it's a different folder I'm missing...?) 

So far, nothing's built by hand except Apache - but it's confirmed working. The exact same thing happens when I try to compile PHP 5.4.20. I had no such issues when I last built PHP 5.5, on CentOS.
------------------------------------------------------------------------
Actual copy-paste of my final retry, before I go looking for libmagic source to compile...
------------------------------------------------------------------------
/bin/sh /home/u/src/php-5.5.4/libtool --silent --preserve-dup-deps --mode=compile cc -I/home/u/src/php-5.5.4/ext/fileinfo/libmagic -Iext/fileinfo/ -I/home/u/src/php-5.5.4/ext/fileinfo/ -DPHP_ATOM_INC -I/home/u/src/php-5.5.4/include -I/home/u/src/php-5.5.4/main -I/home/u/src/php-5.5.4 -I/home/u/src/php-5.5.4/ext/date/lib -I/home/u/src/php-5.5.4/ext/ereg/regex -I/usr/include/libxml2 -I/home/u/src/php-5.5.4/ext/sqlite3/libsqlite -I/home/u/src/php-5.5.4/TSRM -I/home/u/src/php-5.5.4/Zend    -I/usr/include -g -O2 -fvisibility=hidden  -c /home/u/src/php-5.5.4/ext/fileinfo/libmagic/apprentice.c -o ext/fileinfo/libmagic/apprentice.lo 
cc: Internal error: Killed (program cc1)
Please submit a full bug report.
See <file:///usr/share/doc/gcc-4.4/README.Bugs> for instructions.
make: *** [ext/fileinfo/libmagic/apprentice.lo] Error 1
------------------------------------------------------------------------
Version of libmagic on the machine:
------------------------------------------------------------------------
$ aptitude show libmagic-dev
Package: libmagic-dev             
State: installed
Automatically installed: no
Version: 5.04-5+squeeze2
Priority: optional
Section: libdevel
Maintainer: Daniel Baumann <daniel@lists.debian-maintainers.org>
Uncompressed Size: 279 k
Depends: libmagic1 (= 5.04-5+squeeze2)
Suggests: file
Description: File type determination library using "magic" numbers (development)
 This library can be used to classify files according to magic number tests. It implements the core functionality of the file command. 
 
 This package contains the development files.
Homepage: http://www.darwinsys.com/file/
------------------------------------------------------------------------
-30-
 [2013-10-15 11:54 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 [2014-01-16 20:12 UTC] brandon at brandonsavage dot net
I ran into this bug when compiling PHP on a box with only 512 mb of RAM total. It appears the compiler ran out of memory. Recommend adding some kind of "minimum system requirements" for PHP.
 [2015-12-22 14:46 UTC] noreplythanks at example dot fake dot com
I had this issue too, on Raspbian (Linux) on a Raspberry Pi.
 [2016-03-25 11:19 UTC] slier81 at gmail dot com
Run to this same issue when try to compile php7.0.4

After some research, i figure this error occurred when im compiling on machine with only 512mb of memory..

Should have stated system requirement clearly
 [2020-11-13 09:49 UTC] remy dot issard at cnrs dot fr
Same problem, Ubuntu 20.04 on VirtualBox VM with Vagrant, PHP7.3.
VM with 1024MB of memory -> not enought !
Solved by setting, in VagrantFile, 2048MB of memory for VM and... It works !
 [2023-01-23 05:15 UTC] guillaume-php at outters dot eu
The problem arises on a Raspberry Pi 3 Model B (1 Go of RAM) trying to compile PHP 8.1.14.
The 42 MB data_file.c triggers an (exponential?) memory consumption, with gcc at least,
while compiling a 7 MB array (with bytes expressed as "0x00, " thus the total file size).
I wonder if those 7 MB get embedded into every php binary, and are duplicated in every process (unless fileinfo gets compiled as a shared lib) :-\

PHP 7.4.33's 34 MB data_file.c manages to compile,
using 600 to 700 MB of vsize (tested by decrementing ulimit -v from 1 GB down until crash)

Now, I "seem" (1) to have a solution:
-----------------------------------------------------------
Replace list initialization with string initialization (2).
-----------------------------------------------------------
That is:
    0x1C, 0x04, 0x1E, 0xF1, 0x0E, 0x00, 0x00, 0x00, 0x4F, 0x33, 0x00, 0x00, 0x78, 0x0C, 0x00, 0x00,
become:
    "\x1C\x04\x1E\xF1\x0E\x00\x00\x00\x4F\x33\x00\x00\x78\x0C\x00\x00"

Although a modest gain on the .c size (33 %), gcc requires 75 % less memory to compile. This would allow us years of fileinfo growing.
Of course a non-regression needs to be done to avoid breaking under compilers who, on the contrary, worked better with lists; but (1) makes me optimistic.

Notes
-----

(1) "seem" because after crashing my RPi (3), I continued my tests on a totally unrelated machine (FreeBSD in an amd64 VBox), using PHP 7.4.33 source to test gcc behaviour.
So it lacks a test in real conditions, but I hope the transposition could reveal successful.
Here I needed (ulimit -v dichotomy to determine the necessary vsize for a successful compilation):
* 655 MB (gcc 11.2 with list initialization)
* 179 MB (gcc 11.2 with string initialization)
* 898 MB (clang 13.0.0 with list initialization)
* 210 MB (clang 13.0.0 with string initialization)

(2) Converting the .c:
sed -e 's#^0x#"\\x#' -e 's#, 0x#\\x#g' -e 's#, *$#"#' -e 's#{ *$##' -e 's#}##'
Maybe I could provide a patch for create_data_file.php.

(3) My attempt at fine-graining mem consumption:
# procpath from https: //unix.stackexchange.com/a/414770/452410
rm -f /tmp/procpath.sqlite3 ; ~/.local/bin/procpath record -i 0.3 -d /tmp/procpath.sqlite3 -r 600 '$..children[?("apprentice" in @.cmdline)]' &
(
    ulimit -v 524288 # Letting 1048576 was a mistake… The RPi crashed.
    cd ~/tmp/php-8.1.14/
    time _here the crashing "/bin/bash …/libtool … …/apprentice.lo" command line from a ps auxww_
)
killall procpath
sqlite3 /tmp/procpath.sqlite3 "select max(stat_vsize) / 1048576, cmdline from record group by stat_pid order by max(record_id)" | sed -e 's# -[IW].[^ ]*##g'
 [2023-01-23 06:17 UTC] guillaume-php at outters dot eu
P.R. at https://github.com/php/php-src/pull/10422
 [2023-01-23 12:55 UTC] cmb@php.net
-Status: No Feedback +Status: Re-Opened
 [2023-01-24 13:11 UTC] guillaume-php at outters dot eu
The following pull request has been associated:

Patch Name: Fix bug #65106: PHP fails to compile ext/fileinfo
On GitHub:  https://github.com/php/php-src/pull/10422
Patch:      https://github.com/php/php-src/pull/10422.patch
 [2024-03-22 14:00 UTC] git@php.net
Automatic comment on behalf of outtersg (author) and nielsdos (committer)
Revision: https://github.com/php/php-src/commit/bcd3eec44aa4e4eeb7deb4ee6b6cfb596dcc7baa
Log: Fix bug #65106: PHP fails to compile ext/fileinfo
 [2024-03-22 14:00 UTC] git@php.net
-Status: Re-Opened +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 11:01:29 2024 UTC