3

When downloading open-source software from the internet (in this case: PHP 5.5.5), they often come with an Automake "script" (if I can call it a script) for building from source.

Now I'm trying to cross-compile for a different architecture, but I keep getting a different error whenever I specify a different ./configure --switch. Typically, this error is a short non-descriptive message that means absolutely nothing to anyone except the developer.

checking "whether flock struct is linux ordered"... configure: error: in `/usr/src/hd/lib/php-5.5.5': configure: error: cannot run test program while cross compiling

Followed by:

See `config.log' for more details

So I type:

cat ./config.log

But really, the only thing out of the ordinary that it's showing me is this:

configure: exit 1

--

So what gives? How can I tell what the problem is?

FYI, my configure options look somewhat like this:

./configure --prefix="`pwd`/install/" \
--build="i386-pc-linux-gnu" \
--host="mips-linux-gnu" \
--target="mips-linux-gnu" \
--with-libxml-dir="/usr/src/hd/lib/libxml2-2.7.8/install/" \
--enable-soap \
CC="mips-linux-gnu-gcc" \
CFLAGS="-O2 -EL -march=74kf" \
CPP="mips-linux-gnu-cpp" \
CPPFLAGS="-I$CROSS_ROOTFS/include" \
CXX="mips-linux-gnu-g++" \
CXXFLAGS="-O2 -EL -march=74kf" \
CXXCPP="mips-linux-gnu-cpp" \
AR="mips-linux-gnu-ar" \
RANLIB="mips-linux-gnu-ranlib" \
AS="mips-linux-gnu-as" \
NM="mips-linux-gnu-nm" \
LD="mips-linux-gnu-ld" \
LDFLAGS="-L$CROSS_ROOTFS/lib" \
ADDR2LINE="mips-linux-gnu-addr2line"

As you may not know, I'm using the CodeSourcery toolchain to cross-compile for mips. I am aware that I don't need to specify all of the variables (such as RANLIB), but I don't see how it could hurt.

UPDATE

The problem seems to lie in one (or more) of the bundled extensions, as listed here: http://php.net/manual/en/extensions.membership.php

Configuring with --disable-all works. But obviously, I do need at least some of those bundled extensions in order to do some real work.

Still, how can I tell which one?

UPDATE

I narrowed the problem down to an extension called OPcache that was enabled by default (see: https://www.php.net/manual/en/opcache.installation.php). It successfully compiled after disabling that, along with some other extensions that wouldn't work on my target system anyway.

Still, this was not obvious to me at all. What I did was work my way backwards from the output log, disabling listed extensions one by one until the stupid thing would finally work.

Surely there has to exist a better way to pinpoint problems like these? Otherwise what the hell is the entire point of this automake nonsense?

2
  • You've done well. Rather than enabling the extensions one-by-one, try a binary search. Commented Dec 16, 2013 at 3:23
  • Maybe I'm just not experienced enough to understand where autoconfig fits in the world of open-source, but to me it seems like one of the dumbest ideas ever conceived. Then again, the PHP guys do state that they do not/will not support cross-compiling. These problems didn't come as a surprise. Commented Dec 16, 2013 at 14:14

1 Answer 1

1

The opscache requires libtdl, which is part of GNU Libtool.

Linux

On Linux, get the libltdl-dev package, for example on Ubuntu:

$ sudo apt-get install libltdl-dev

Mac OSX

For OSX, the easiest way to install GNU Libtool is to install it through Homebrew

$ brew install libtool

Specifically, GNU Libtool will provide the following files which is used for PHP compilation

/usr/local/lib/libltdl.dylib
/usr/local/lib/libltdl.a
/usr/local/lib/libltdl.7.dylib

As a side note, OSX ships with its own copy of libtool which does not include libtdl interface. To avoid conflicts, GNU Libtool tools are prefixed with 'g', e.g. glibtool and glibtoolize

Libtdl

For more information, please refer to http://www.gnu.org/software/libtool/manual/html_node/Libltdl-interface.html

2
  • Thanks. I'm currently still using PHP without OPcache, but I'll look into this. I do have to ask, where do you find this sort of information? I don't recall libdtl being referenced anywhere, ever. Commented May 2, 2014 at 11:41
  • @StevenLiekens I got lucky - was searching with the error message, specifically around struct flock and stumbled upon vasilis' solution at bugs.php.net/bug.php?id=65423 . I'm hoping the PHP devs will either add libtool as dep when opcache's enabled, or give a more useful autoconf / make error message. I've also submitted a similar patch for github.com/Homebrew/homebrew-php PHP >5.5 and hope it gets accepted
    – hanxue
    Commented May 2, 2014 at 15:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .