无法在 FreeBSD 上编译 PHP 5.6.17 --with-mcrypt

Cannot compile PHP 5.6.17 --with-mcrypt on FreeBSD

我正在尝试根据 http://php.net/manual/en/mcrypt.requirements.php 在启用了 libmcrypt-2.5.8 的 FreeBSD 10 上从源代码构建 PHP 5.6.17。 libmcrypt 构建似乎可以使用 make EXTRACFLAGS=-fPIC :

root@dev% dir /usr/local/lib/*mcry*
-rw-r--r--  1 root  wheel  1033370 Jan 14 11:30 /usr/local/lib/libmcrypt.a
-rwxr-xr-x  1 root  wheel      746 Jan 14 11:30 /usr/local/lib/libmcrypt.la

之后:

./configure --with-apxs2=/usr/local/apache/bin/apxs \
--with-config-file-path=/usr/local/etc  \
--enable-bcmath --without-cdb \
--with-gd --with-mysql=/usr/local/mysql \
--without-iodbc --enable-inline-optimization \
--without-gdbm --with-ndbm --without-db2 \
--without-dbm --without-readline --without-recode \
--with-openssl --without-db3 --enable-dba \
--with-curl --with-jpeg-dir=/usr/local/lib --enable-calendar \
--with-mhash --enable-mbstring=all --with-png-dir=/usr/local/libpng \
--with-zlib --with-freetype-dir=/usr/local/lib \
--with-pdo-mysql=mysqlnd --enable-exif --with-libxml-dir=/usr/local/lib \
 --enable-zip \
--with-imap=/usr/local/imap-2007f \
--with-mcrypt

配置与 mcrypt 相关的输出:

checking for mcrypt support... yes
checking for libmcrypt version... >= 2.5.6
checking for mcrypt_module_open in -lmcrypt... no
checking for mcrypt_module_open in -lmcrypt... yes

我在 'make'

时收到此错误
    /usr/bin/ld: /usr/local/lib/libmcrypt.a(mcrypt_extra.o): relocation R_X86_64_32 against `mps' can not be used when making a shared object; recompile with -fPIC
    /usr/local/lib/libmcrypt.a: could not read symbols: Bad value
    cc: error: linker command failed with exit code 1 (use -v to see invocation)
    *** Error code 1

    Stop.

make: stopped in /usr/local/dev_build_sources/php-5.6.17

我以前能够使用 PHP 5.6.6

中的这些步骤进行构建

这个问题https://serverfault.com/questions/357020/how-can-i-install-enable-mcrypt-without-re-installing-php建议将 mcrypt(为什么不是 libmcrypt?)作为扩展,但 mcrypt make 一直失败

EDIT - 添加尝试在 php-5.6.17/ext/mcrypt 中进行扩展的结果似乎无法说明它需要-fPI 旗帜,但它们已经提供了..

root@dev% make EXTRACFLAGS=-fPIC
/bin/sh /usr/local/dev_build_sources/TEMP_PHP/php-5.6.17/ext/mcrypt/libtool --mode=compile cc  -I. -I/usr/local/dev_build_sources/TEMP_PHP/php-5.6.17/ext/mcrypt -DPHP_ATOM_INC -I/usr/local/dev_build_sources/TEMP_PHP/php-5.6.17/ext/mcrypt/include -I/usr/local/dev_build_sources/TEMP_PHP/php-5.6.17/ext/mcrypt/main -I/usr/local/dev_build_sources/TEMP_PHP/php-5.6.17/ext/mcrypt -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 -I/usr/local/include  -DHAVE_CONFIG_H  -g -O2   -c /usr/local/dev_build_sources/TEMP_PHP/php-5.6.17/ext/mcrypt/mcrypt.c -o mcrypt.lo
mkdir .libs
 cc -I. -I/usr/local/dev_build_sources/TEMP_PHP/php-5.6.17/ext/mcrypt -DPHP_ATOM_INC -I/usr/local/dev_build_sources/TEMP_PHP/php-5.6.17/ext/mcrypt/include -I/usr/local/dev_build_sources/TEMP_PHP/php-5.6.17/ext/mcrypt/main -I/usr/local/dev_build_sources/TEMP_PHP/php-5.6.17/ext/mcrypt -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 -I/usr/local/include -DHAVE_CONFIG_H -g -O2 -c /usr/local/dev_build_sources/TEMP_PHP/php-5.6.17/ext/mcrypt/mcrypt.c  -fPIC -DPIC -o .libs/mcrypt.o
/bin/sh /usr/local/dev_build_sources/TEMP_PHP/php-5.6.17/ext/mcrypt/libtool --mode=compile cc  -I. -I/usr/local/dev_build_sources/TEMP_PHP/php-5.6.17/ext/mcrypt -DPHP_ATOM_INC -I/usr/local/dev_build_sources/TEMP_PHP/php-5.6.17/ext/mcrypt/include -I/usr/local/dev_build_sources/TEMP_PHP/php-5.6.17/ext/mcrypt/main -I/usr/local/dev_build_sources/TEMP_PHP/php-5.6.17/ext/mcrypt -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 -I/usr/local/include  -DHAVE_CONFIG_H  -g -O2   -c /usr/local/dev_build_sources/TEMP_PHP/php-5.6.17/ext/mcrypt/mcrypt_filter.c -o mcrypt_filter.lo
 cc -I. -I/usr/local/dev_build_sources/TEMP_PHP/php-5.6.17/ext/mcrypt -DPHP_ATOM_INC -I/usr/local/dev_build_sources/TEMP_PHP/php-5.6.17/ext/mcrypt/include -I/usr/local/dev_build_sources/TEMP_PHP/php-5.6.17/ext/mcrypt/main -I/usr/local/dev_build_sources/TEMP_PHP/php-5.6.17/ext/mcrypt -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 -I/usr/local/include -DHAVE_CONFIG_H -g -O2 -c /usr/local/dev_build_sources/TEMP_PHP/php-5.6.17/ext/mcrypt/mcrypt_filter.c  -fPIC -DPIC -o .libs/mcrypt_filter.o
/usr/local/dev_build_sources/TEMP_PHP/php-5.6.17/ext/mcrypt/mcrypt_filter.c:210:37: warning: passing 'const char *' to
      parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
        mcrypt_module = mcrypt_module_open(cipher, algo_dir, mode, mode_dir);
                                           ^~~~~~
/usr/local/include/mutils/mcrypt.h:38:34: note: passing argument to parameter 'algorithm' here
        MCRYPT mcrypt_module_open(char *algorithm,
                                        ^
1 warning generated.
/bin/sh /usr/local/dev_build_sources/TEMP_PHP/php-5.6.17/ext/mcrypt/libtool --mode=link cc -DPHP_ATOM_INC -I/usr/local/dev_build_sources/TEMP_PHP/php-5.6.17/ext/mcrypt/include -I/usr/local/dev_build_sources/TEMP_PHP/php-5.6.17/ext/mcrypt/main -I/usr/local/dev_build_sources/TEMP_PHP/php-5.6.17/ext/mcrypt -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 -I/usr/local/include  -DHAVE_CONFIG_H  -g -O2   -o ./mcrypt.la -export-dynamic -avoid-version -prefer-pic -module -rpath /usr/local/dev_build_sources/TEMP_PHP/php-5.6.17/ext/mcrypt/modules  mcrypt.lo mcrypt_filter.lo -Wl,-rpath,/usr/local/lib -L/usr/local/lib -lmcrypt
cc -shared  .libs/mcrypt.o .libs/mcrypt_filter.o  -L/usr/local/lib /usr/local/lib/libmcrypt.a  -Wl,-rpath -Wl,/usr/local/lib -Wl,-soname -Wl,mcrypt.so -o ./.libs/mcrypt.so
/usr/bin/ld: /usr/local/lib/libmcrypt.a(mcrypt_extra.o): relocation R_X86_64_32 against `mps' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libmcrypt.a: could not read symbols: Bad value
cc: error: linker command failed with exit code 1 (use -v to see invocation)
*** Error code 1

成功了:

在libmcrypt-2.5.8源目录下

./configure --disable-posix-threads --with-pic

然后make没有任何标志

PHP 使用上面的配置命令和普通 make

构建正常