php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49314 cross compile fails to find dlopen, libdl, HAVE_DLOPEN, HAVE_LIBDL
Submitted: 2009-08-20 16:13 UTC Modified: 2009-08-21 11:37 UTC
Votes:5
Avg. Score:5.0 ± 0.0
Reproduced:5 of 5 (100.0%)
Same Version:2 (40.0%)
Same OS:2 (40.0%)
From: sbraun at emlix dot com Assigned:
Status: Wont fix Package: Dynamic loading
PHP Version: 5.3.0 OS: linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: sbraun at emlix dot com
New email:
PHP Version: OS:

 

 [2009-08-20 16:13 UTC] sbraun at emlix dot com
Description:
------------
I cross compile libphp5.so in a i486-pc-linux-gnu chroot, the compiler is an i486-pc-linux-gnu-gcc that produces code for an i686-pc-linux-gnu target (the compile runs as part of an embedded systems build system).

When I load the libphp5.so into apache, it fails with:
httpd: Syntax error on line 54 of /etc/httpd/conf/httpd.conf: Cannot load /usr/lib/apache/libphp5.so into server: /usr/lib/apache/libphp5.so: undefined symbol: php_load_extension 

php_load_extension from dl.c is guarded by #ifdef HAVE_LIBDL

objdump -x libphp5.so:
00000000         *UND*  00000000              php_load_extension

In my cross_compile situtation, the #defines for dlopen and libdl are not set, thus HAVE_DLOPEN and HAVE_LIBDL are not in main/php_config.h, yet my system provides dlopen() via dl.so.

Naturally, dl.so is there in my chroot and provides dlopen(), and the configure script finds this fact when searching for dlopen() respectively __dlopen(), yet then it throws the findings away, the relevant lines in the configure script are:
------------------
  if test "$found" = "yes"; then
    ac_libs=$LIBS
    LIBS="$LIBS -ldl"
    if test "$cross_compiling" = yes; then
  found=no
else
------------------
Later, writing the #defines HAVE_DLOPEN and HAVE_LIBDL is guarded by: 
------------------
  if test "$found" = "yes"; then
------------------




Reproduce code:
---------------
autoconf configure.in > configure
build_platform=i486-pc-linux-gnu
target_platform=i486-pc-linux-gnu
PKG_CONFIG_PATH=${sysroot}/usr/lib/pkgconfig \
./configure \
        --prefix=${_prefix} \
        --build=${build_platform} \
        --host=${target_platform} \
        --target=${target_platform} \
        --mandir=${_mandir} \
        --with-apxs2="${sysroot}${_sbindir}/apxs" \
        --with-libxml-dir="${sysroot}${_prefix}" \
        --with-openssl \
        --without-iconv \
        --disable-cli \
        ;

start apache with a line in httpd.conf:
LoadModule php5_module /usr/lib/apache/libphp5.so

you get the error described above

Expected result:
----------------
well, it should load and stuff

Actual result:
--------------
Instead I will provide some bugfix suggestion:

I am not so much a friend of autoconf, so i think i am maybe not the right person to provide a patch directly. Maybe there is a reason for the behaviour. I am going to comment the problematic line out in my project, patch would be welcome.

# phps configure mysteriously refuses to use found libdl
#    if test "$cross_compiling" = yes; then
#  found=no

regards
Simon Braunschmidt


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-08-20 16:15 UTC] sbraun at emlix dot com
The compiler is an i686 compiler, which runs in an i486-pc-linux-gnu chroot. So the first lines should read:

I cross compile libphp5.so in a i486-pc-linux-gnu chroot, the compiler
is an i686-pc-linux-gnu-gcc that produces code for an i686-pc-linux-gnu
target (the compile runs as part of an embedded systems build system).
 [2009-08-21 11:37 UTC] jani@php.net
Unfortunately we don't support cross-compiling out-of-box. Best way to do this is to first generate rough template Makefile (which you bascally got already) and then manually fix the LIBS, and such.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 02:01:29 2024 UTC