php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66103 Cross-compiling not supported
Submitted: 2013-11-15 20:13 UTC Modified: 2020-10-28 11:42 UTC
Votes:31
Avg. Score:4.5 ± 0.8
Reproduced:28 of 29 (96.6%)
Same Version:6 (21.4%)
Same OS:21 (75.0%)
From: rmarku at gmail dot com Assigned: nikic (profile)
Status: Closed Package: opcache
PHP Version: 5.5.6 OS: Linux
Private report: No CVE-ID: None
 [2013-11-15 20:13 UTC] rmarku at gmail dot com
Description:
------------
Cross-compiling not supported

I'm trying to cross-compile PHP 5.5.6 with OpenWRT buildroot. If I disable OPcache, everything goes well.
with OPcache enabled, configure hangs with this error.

...
checking for mcrypt_module_open in -lmcrypt... yes
checking for MSSQL support via FreeTDS... no
checking for MySQL support... yes, shared
checking for specified location of the MySQL UNIX socket... no
checking for mysql_close in -lmysqlclient... yes
checking for MySQL UNIX socket location... no
checking for MySQLi support... yes, shared
checking whether to enable embedded MySQLi support... no
checking for mysql_set_server_option in -lmysqlclient... yes
checking for mysql_set_character_set in -lmysqlclient... yes
checking for mysql_stmt_next_result in -lmysqlclient... no
checking for Oracle Database OCI8 support... no
checking whether to enable Zend OPcache support... yes
checking for mprotect... yes
checking for sysvipc shared memory support... no
checking for mmap() using MAP_ANON shared memory support... no
checking for mmap() using /dev/zero shared memory support... no
checking for mmap() using shm_open() shared memory support... no
checking for mmap() using regular file shared memory support... no
checking "whether flock struct is linux ordered"... configure: error: in `/openwrt/trunk/build_dir/target-mips_34kc_uClibc-0.9.33.2/php-5.5.6':
configure: error: cannot run test program while cross compiling
See `config.log' for more details



Patches

flock-type-crosscompile.patch (last revision 2014-08-21 09:41 UTC by zboszor at pr dot hu)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-12-09 15:38 UTC] hdboeve at boevewebdevelopment dot nl
Same error, on OS X Mavericks:

checking for sysvipc shared memory support... no
checking for mmap() using MAP_ANON shared memory support... no
checking for mmap() using /dev/zero shared memory support... no
checking for mmap() using shm_open() shared memory support... no
checking for mmap() using regular file shared memory support... no
checking "whether flock struct is linux ordered"... "no"
checking "whether flock struct is BSD ordered"... "no"
configure: error: Don't know how to define struct flock on this system, set --enable-opcache=no
 [2014-08-09 23:09 UTC] bos at je-eigen-domein dot nl
Same problem.

In ZendAccelerator.h it looks for the presence of other defines such as __linux__ first to determine flock order, in favor of the results of the test (HAVE_FLOCK_LINUX)
So why is not being able to run the test fatal?


==
# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || (defined(__APPLE__) && defined(__MACH__)/* Darwin */) || defined(__OpenBSD__) || defined(__NetBSD__)
#  define FLOCK_STRUCTURE(name, type, whence, start, len) \
		struct flock name = {start, len, -1, type, whence}
# elif defined(__svr4__)
#  define FLOCK_STRUCTURE(name, type, whence, start, len) \
		struct flock name = {type, whence, start, len}
# elif defined(__linux__) || defined(__hpux) || defined(__GNU__)
#  define FLOCK_STRUCTURE(name, type, whence, start, len) \
		struct flock name = {type, whence, start, len, 0}
# elif defined(_AIX)
#  if defined(_LARGE_FILES) || defined(__64BIT__)
#   define FLOCK_STRUCTURE(name, type, whence, start, len) \
		struct flock name = {type, whence, 0, 0, 0, start, len }
#  else
#   define FLOCK_STRUCTURE(name, type, whence, start, len) \
		struct flock name = {type, whence, start, len}
#  endif
# elif defined(HAVE_FLOCK_BSD)
#  define FLOCK_STRUCTURE(name, type, whence, start, len) \
		struct flock name = {start, len, -1, type, whence}
# elif defined(HAVE_FLOCK_LINUX)
#  define FLOCK_STRUCTURE(name, type, whence, start, len) \
		struct flock name = {type, whence, start, len}
# else
#  error "Don't know how to define struct flock"
# endif
#endif
==
 [2014-12-21 18:22 UTC] avarsanov at yahoo dot com
"checking "whether flock struct is linux ordered"... "no"
checking "whether flock struct is BSD ordered"... "no"
configure: error: Don't know how to define struct flock on this system, set --enable-opcache=no"

I had the same error, while compiling PHP (5.6.4, but that does not matter, because I tried als PHP 5.6.3 and was reproducable) on Debian GNU/Linux. I saw that problem when I forgot to set LD_LIBRARY_PATH environment variable.

So doing it like that solved my problem:

$ export LD_LIBRARY_PATH=/usr/local/mysql/lib
$ ./configure --enable-fpm --with-mcrypt --with-zlib --with-curl --disable-debug --disable-rpath --enable-inline-optimization --with-bz2 --enable-sockets --enable-zip --with-fpm-user=www-data --with-fpm-group=www-data --with-mysql=/usr/local/mysql/
$ make
$ make test
# export LD_LIBRARY_PATH=/usr/local/mysql/lib
# make install
 [2016-02-05 16:11 UTC] ttilley at sonusnet dot com
Fails with PHP 7.0.2/OpenWRT as well, and disabling opcache isn't an acceptable option as the enhanced opcache performance is a major reason to want PHP 7.

Obviously the test program can't be run in a cross-compile - the configure script should be modified to take flock_type as an input variable to support cross-compiling. If the input variable is set then don't bother with the test program.
 [2016-08-21 17:54 UTC] alt dot f2-5ok1zywx at yopmail dot com
all of these cross-compilation problems could easily be solved if php would use the cache variables feature for these variables as well so user can easily override the test from the commandline.
example:

./configure ac_cv_crypt_SHA512=yes ac_cv_linux_lock=yes

however due to lack of it, you need to either patch the configure script, or the configure.ac and rerun all the autoreconf stuff which is highly error prone due to all the involved m4 macros and different tool versions.

note that the cache variable is used for the above SHA512 crypt check

$as_echo_n "checking for SHA512 crypt... " >&6; }
if ${ac_cv_crypt_sha512+:} false; then :
  $as_echo_n "(cached) " >&6                                                    
else

if test "$cross_compiling" = yes; then :                                        

  ac_cv_crypt_sha512=no

else
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext                                   


but not for this check, the one for strcasestr and probably others.
for comparison:

  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for strcasestr" >&5         
$as_echo_n "checking for strcasestr... " >&6; }                                 
  if test "$cross_compiling" = yes; then :                                      
  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5         
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}                                  
as_fn_error $? "cannot run test program while cross compiling                   
See \`config.log' for more details" "$LINENO" 5; }                              
else                                                                            
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 [2016-08-21 18:10 UTC] alt dot f2-5ok1zywx at yopmail dot com
little reminder: 3 years later, as of 2016 and PHP 7.0.10, there are still 3 configure checks that cannot be worked around without patching configure:

1) check for strcasestr
2) this one here
3) pthreads_working. if crosscompiling, and the system is not netware, it is assumed that pthread are broken.
i think if a test compile with link against -lpthread works, it can be assumed that pthreads work. most likely the lib is there for a reason.
they all could be *easily* fixed by enabling a cache variable that the user can set.
 [2020-10-28 11:42 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2020-10-28 11:42 UTC] nikic@php.net
The problematic flock check has been removed in PHP 7.2 via https://github.com/php/php-src/commit/9222702633c63254b08466b322266b647ac3e905.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Dec 04 16:01:29 2024 UTC