note 31749 deleted from ref.java by aidan
| From: | aidan@php.net | Date: | Wed, 01 Sep 2004 00:09:13 +0000 |
| Subject: | note 31749 deleted from ref.java by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-75805@lists.php.net to get a copy of this message | ||
Note Submitter: francois dot turi at globecast dot com
----
as stated in Bug #19937 dynamic extension loading fails
the construction of extension on Aix is buggy.
After a week research I found the following fix:
The following patch should fix problem of loading extension under AIX
4.3.3 like the java extension.
Under AIX, shared object are different from shared library.
The default library construction (as in the construction of
the JAVA extension) doesnt work correctly as it relies on dynamic
linking from a library when only a shared object is given.
An exception appear as illegal instruction.
The following configuration are missing:
First of all:
=============
one should construct correctly the export definition of libphp4.so.
In configure the following line should be changed:
********************************
diff configure configure.orig (sorry no -b available under AIX)
78084,78086c78084
< # FTU export_symbols_cmds='$NM $libobjs $convenience |
$global_symbol_pipe | sed '\''s/.* //'\'' | sort | uniq >
$export_symbols'
< export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe |
sed '\''s/.* //'\'' | sort | uniq|awk -vlib=$SOHOME/$soname
'\''BEGIN{printf "#!%s\n",lib}{print \$0}'\'' >
$export_symbols'
< echo "FTU export_symbols_cmds=$export_symbols_cmds"
---
> export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe |
sed '\''s/.* //'\'' | sort | uniq > $export_symbols'
***************************
I added awk -vlib=$SOHOME/$soname
'\''BEGIN{printf "#!%s\n",lib}{print \$0}'\''
To the pipe so the first line will be read as:
#!/your/path/to/your/libphp4.so
And the rest is identical.
Before compiling your library you should setup the SOHOME variable as
the path where your shared object (libphp4.so.0) will be running:
************
export SOHOME=/s00/opendata/build/SSOD/php.430/current
************
Second important point:
========================
Refer the export file of php shared object in the construction of the
java extension:
When compiling the JAVA extension you have to setup the following
environement VARIABLE
*****************
export JAVA_SHARED_LIBADD="-Wl,-bI:.libs/libphp4.exp"
*****************
That line state that in the linking process (ld), the java extension
will use the libphp4.exp file to find undefined function or global
variable. By defaut such function will be resolve as running time.
On AIX such binding doesnt work because the libphp4.so is not a shared
library (doesnt appear in the genmkd listing) but a share object.
You have to specify the full path to your share object while linking it
to make him resolve correctly the reference to the Zend API.
Nota: the default exemple given to make an extension doesnt have that
problem because it doesnt call any Zend API function stored in the
libphp4.so.
External reference:
The followings redbooks explain the subtle difference between share
objects and shared library under AIX:
Understanding C and C++ development on AIX
chapter 3 Compiling and Linking
original
http://www.redbooks.ibm.com/pubs/pdfs/redbooks/sg245674.pdf
latest draft (for 5.L)
http://www.redbooks.ibm.com/redpieces/pdfs/sg245674.pdf
Last point:
===========
The extension java should be rename after construction to
cp -p libjava.so.0 libphp_java.so
to work correctly.
About libtool:
==============
The first line in configure change the libtool which is in charge of
creating the dynamic library. I cannot figure out if the bug is a php
bug or a libtool bug.