|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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 PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 14:00:01 2025 UTC |
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'