Как отследить причину ошибок компиляции в операции установки pecl zip (с устаревшей версией PHP)? - PullRequest
1 голос
/ 23 октября 2019

У меня неизбежная потребность в разработке систем на основе PHP 5.4. Я знаю, что это хорошо из-за обновлений безопасности, но это то, что у меня есть сейчас. Я хочу создать образ PHP 5.4 Docker для целей разработки. Исторически сложилось так, что моя команда и я использовали образ PHP 5.6 на основе Centos, поскольку нет доступных изображений 5.4 Centos.

Таким образом, я пытаюсь скомпилировать PHP 5.4. С большим количеством проб и ошибок я получил его для компиляции PHP с минимальными скомпилированными расширениями, а затем с кучей динамически загружаемых расширений сверху. Это означает, что мои различные последующие проекты могут выбирать, какие расширения им нужны, просто добавляя правильные php.ini команды расширения.

Вот мои Dockerfile:

# A custom Docker/PHP build for 5.4
#
# PHP 5.4 is no longer available as a standard image as it is
# well out of support. Centos has been chosen to mirror live
# servers.

FROM centos:7 AS build

# Do OS updates using fastest mirrors
RUN yum update -y

# Here is the raw OS (give up if repo is down)
RUN timeout 3m yum install -y wget curl gcc make
# Here are some dependencies (give up if repo is down)
RUN timeout 3m yum install -y \
        libxml2-devel libssh-devel \
        openssl-devel curl-devel postgresql-devel \
        autoconf

WORKDIR /root

RUN wget https://www.php.net/distributions/php-5.4.45.tar.gz && \
    tar -xf php-5.4.45.tar.gz

WORKDIR /root/php-5.4.45

# Compile here
# OpenSSL/curl are used nearly everywhere, e.g. Compose
# zlib is useful but not required for Composer
RUN ./configure \
    --with-config-file-path=/usr/local/etc/php \
    --with-config-file-scan-dir=/usr/local/etc/php/conf.d \
    --with-openssl \
    --with-openssl-dir \
    --with-curl=/usr/local/bin \
    --with-zlib \
    --with-pdo-mysql
RUN make && make install

# Create a store for the modules
RUN mkdir /root/exts

# Compile some PHP extensions (keep in alpha order please)
RUN cd ext/bcmath    && phpize && ./configure && make && cp modules/bcmath.so    /root/exts/
RUN yum install -y bzip2-devel
RUN cd ext/bz2       && phpize && ./configure && make && cp modules/bz2.so       /root/exts/
RUN cd ext/calendar  && phpize && ./configure && make && cp modules/calendar.so  /root/exts/
RUN yum install -y enchant-devel
RUN cd ext/enchant   && phpize && ./configure && make && cp modules/enchant.so   /root/exts/
RUN cd ext/exif      && phpize && ./configure && make && cp modules/exif.so      /root/exts/
RUN cd ext/ftp       && phpize && ./configure && make && cp modules/ftp.so       /root/exts/
RUN yum install -y libpng-devel
RUN cd ext/gd        && phpize && ./configure && make && cp modules/gd.so        /root/exts/
RUN cd ext/gettext   && phpize && ./configure && make && cp modules/gettext.so   /root/exts/
RUN yum install -y gmp-devel
RUN cd ext/gmp       && phpize && ./configure && make && cp modules/gmp.so       /root/exts/

# Investigate this one
# igbinary

RUN yum install -y libicu-devel gcc-c++
RUN cd ext/intl      && phpize && ./configure && make && cp modules/intl.so      /root/exts/
RUN cd ext/mbstring  && phpize && ./configure && make && cp modules/mbstring.so  /root/exts/

# See comments under https://www.mojowill.com/geek/php-mcrypt-on-centos-6/ to
# install "Centos Extras"
RUN yum install epel-release -y && yum update -y
RUN yum install -y libmcrypt-devel
RUN cd ext/mcrypt    && phpize && ./configure && make && cp modules/mcrypt.so    /root/exts/

# This is not included in the source bundle, so we need to fetch and compile
RUN yum install -y libmemcached-devel zlib-devel autoconf gcc make
RUN pecl install memcached-2.2.0
RUN cp /usr/local/lib/php/extensions/no-debug-non-zts-20100525/memcached.so /root/exts/

RUN cd ext/mysql     && phpize && ./configure && make && cp modules/mysql.so     /root/exts/
RUN cd ext/mysqli    && phpize && ./configure && make && cp modules/mysqli.so    /root/exts/
RUN cd ext/pcntl     && phpize && ./configure && make && cp modules/pcntl.so     /root/exts/
RUN cd ext/pdo       && phpize && ./configure && make && cp modules/pdo.so       /root/exts/

RUN cd ext/pdo_pgsql && phpize && ./configure && make && cp modules/pdo_pgsql.so /root/exts/
RUN yum install -y libedit-devel readline-devel
RUN cd ext/readline  && phpize && ./configure && make && cp modules/readline.so  /root/exts/

# Investigate this one
#RUN cd ext/redis     && phpize && ./configure && make && cp modules/redis.so     /root/exts/

RUN cd ext/shmop     && phpize && ./configure && make && cp modules/shmop.so     /root/exts/
RUN cd ext/soap      && phpize && ./configure && make && cp modules/soap.so      /root/exts/
RUN cd ext/sockets   && phpize && ./configure && make && cp modules/sockets.so   /root/exts/
RUN cd ext/sysvmsg   && phpize && ./configure && make && cp modules/sysvmsg.so   /root/exts/
RUN cd ext/sysvsem   && phpize && ./configure && make && cp modules/sysvsem.so   /root/exts/
RUN cd ext/sysvshm   && phpize && ./configure && make && cp modules/sysvshm.so   /root/exts/
RUN cd ext/wddx      && phpize && ./configure && make && cp modules/wddx.so      /root/exts/
RUN cd ext/xml       && phpize && ./configure && make && cp modules/xml.so       /root/exts/
RUN cd ext/xmlrpc    && phpize && ./configure && make && cp modules/xmlrpc.so    /root/exts/
RUN yum install -y libxslt-devel
RUN cd ext/xsl       && phpize && ./configure && make && cp modules/xsl.so       /root/exts/

# The PECL compile fails, but the version of libzip (0.10.1) looks exactly right
RUN yum install -y libzip-devel gcc
RUN pecl install zip-1.11.0
# Does not compile either on Centos 6 or 7

Это работает полностью, кромедля последней части, которая является pecl установкой расширения zip. Вот мой вывод на консоль (из шага Docker):

Step 52/70 : RUN pecl install zip-1.11.0
 ---> Running in 06d2ef53ba56
downloading zip-1.11.0.tgz ...
Starting to download zip-1.11.0.tgz (263,909 bytes)
......................................................done: 263,909 bytes
93 source files, building
running: phpize
Configuring for:
PHP Api Version:         20100412
Zend Module Api No:      20100525
Zend Extension Api No:   220100525
building in /tmp/pear/temp/pear-build-defaultuserhYPzzK/zip-1.11.0
running: /tmp/pear/temp/zip/configure
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for PHP prefix... /usr/local
checking for PHP includes... -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib
checking for PHP extension directory... /usr/local/lib/php/extensions/no-debug-non-zts-20100525
checking for PHP installed headers prefix... /usr/local/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... gawk
checking for zip archive read/writesupport... yes, shared
checking for the location of libz... no
checking pcre install prefix... no
checking for the location of zlib... /usr
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for int8_t... yes
checking for int16_t... yes
checking for int32_t... yes
checking for int64_t... yes
checking for uint8_t... yes
checking for uint16_t... yes
checking for uint32_t... yes
checking for uint64_t... yes
checking for ssize_t... yes
checking size of short... 2
checking size of int... 4
checking size of long... 8
checking size of long long... 8
checking size of off_t... 8
checking size of size_t... 8
checking for touch... /usr/bin/touch
checking for unzip... no
checking whether struct tm is in sys/time.h or time.h... time.h
checking for struct tm.tm_zone... yes
checking for ld used by cc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for /usr/bin/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm -B
checking whether ln -s works... yes
checking how to recognize dependent libraries... pass_all
/tmp/pear/temp/zip/configure: line 6197: /usr/bin/file: No such file or directory
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking the maximum length of command line arguments... 1572864
checking command to parse /usr/bin/nm -B output from cc object... ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC
checking if cc PIC flag -fPIC works... yes
checking if cc static flag -static works... no
checking if cc supports -c -o file.o... yes
checking whether the cc linker (/usr/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no

creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h
running: make
/bin/sh /tmp/pear/temp/pear-build-defaultuserhYPzzK/zip-1.11.0/libtool --mode=compile cc  -I. -I/tmp/pear/temp/zip -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-defaultuserhYPzzK/zip-1.11.0/include -I/tmp/pear/temp/pear-build-defaultuserhYPzzK/zip-1.11.0/main -I/tmp/pear/temp/zip -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /tmp/pear/temp/zip/php_zip.c -o php_zip.lo
mkdir .libs
 cc -I. -I/tmp/pear/temp/zip -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-defaultuserhYPzzK/zip-1.11.0/include -I/tmp/pear/temp/pear-build-defaultuserhYPzzK/zip-1.11.0/main -I/tmp/pear/temp/zip -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/zip/php_zip.c  -fPIC -DPIC -o .libs/php_zip.o
/tmp/pear/temp/zip/php_zip.c: In function 'php_zip_get_property_ptr_ptr':
/tmp/pear/temp/zip/php_zip.c:882:3: warning: passing argument 3 of 'std_hnd->get_property_ptr_ptr' makes pointer from integer without a cast [enabled by default]
   retval = std_hnd->get_property_ptr_ptr(object, member, type, key TSRMLS_CC);
   ^
/tmp/pear/temp/zip/php_zip.c:882:3: note: expected 'const struct _zend_literal *' but argument is of type 'int'
/tmp/pear/temp/zip/php_zip.c:882:3: error: too many arguments to function 'std_hnd->get_property_ptr_ptr'
/tmp/pear/temp/zip/php_zip.c: In function 'zm_startup_zip':
/tmp/pear/temp/zip/php_zip.c:2759:43: warning: assignment from incompatible pointer type [enabled by default]
  zip_object_handlers.get_property_ptr_ptr = php_zip_get_property_ptr_ptr;
                                           ^
make: *** [php_zip.lo] Error 1
ERROR: `make' failed

Это довольно неожиданная ошибка компиляции - «слишком много аргументов» кажется, что имеется несоответствие библиотеки или что-то в этом роде, но я специально выбрал 1.11, которая является версией расширения на производственных серверах. Может ли быть так, что моя версия libzip-devel слишком новая, и если да, могу ли я получить более раннюю версию и заставить ее работать в поддерживаемой версии Centos?

Я не сталкивался с этой проблемой ни на одномдругое расширение, так что, возможно, это просто неудача. У меня проблема с обманщиком на последнем!

Обновление

Собственная версия libzip-devel в используемой мной версии Centos равна 0.10.1, которая соответствует версии libzip, о которой сообщают производственные серверы (через php -i). Вот информация из образа Docker:

[root@0b093624d012 /]# yum info libzip-devel
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
 * base: mirror.freethought-internet.co.uk
 * epel: mirror.freethought-internet.co.uk
 * extras: mirror.freethought-internet.co.uk
 * updates: mirror.freethought-internet.co.uk
Available Packages
Name        : libzip-devel
Arch        : i686
Version     : 0.10.1
Release     : 8.el7
Size        : 77 k
Repo        : base/7/x86_64
Summary     : Development files for libzip
URL         : http://www.nih.at/libzip/index.html
License     : BSD
Description : The libzip-devel package contains libraries and header files for
            : developing applications that use libzip.

Name        : libzip-devel
Arch        : x86_64
Version     : 0.10.1
Release     : 8.el7
Size        : 77 k
Repo        : base/7/x86_64
Summary     : Development files for libzip
URL         : http://www.nih.at/libzip/index.html
License     : BSD
Description : The libzip-devel package contains libraries and header files for
            : developing applications that use libzip.

Я сомневаюсь, что изменение моего компилятора C могло бы помочь, но я, безусловно, открыт для идей в этом направлении.

1 Ответ

1 голос
/ 25 октября 2019

Я наконец исправил это.

Сначала я заметил, что у меня было несоответствие версии PHP уровня патча. Мой рабочий сервер работает на 5.4.16, а я собирался на 5.4.45. Я настроил это, уверенный, что он загрузит правильный код для связи с другими библиотеками, но обнаружил, что это не имеет значения.

Затем я проанализировал, сколько номеров версий мне пришлось увеличить в расширении pecl zip. чтобы получить следующую доступную стабильную версию, которая перенесла меня с zip-1.11.0 на zip-1.12.3. Это скомпилировано нормально. Это не идеально, потому что мой рабочий сервер действительно смешивает zip 1.11.0 с PHP 5.4.16, но неважно - мы разрабатываем с использованием 5.6 около года, хотя мы нацелены на производство 5.4. Таким образом, новый имидж по-прежнему является существенной победой, учитывая, что он значительно приближает нас к нашей живой среде.

...