Linking improvements in Cool Stack 1.3
By Basant Kukreja on Jul 22, 2008
- Need to bundle higher version of library than is available in S10. Example is libxml2. php 5 doesn't compile with libxml2 shipped with S10.
- Use as many as /usr/lib and /usr/sfw/lib libraries to avoid huge download size of packages.
- When a library is present at two location, set the RPATH/RUNPATH in libraries correctly so that application will look in /opt/coolstack/lib directory first and then it will look into /usr/sfw/lib directory.
Duplicated libraries caused lots of trouble in coolstack. Here are few issues which we encountered in Cool Stack 1.2.
- CoolStack 1.2 bundled libxml2 but didn't bundle libxslt.
libxslt needs libxml2. Let us run the ldd on php extension
xsl.so. I have edited the output to make it brief :
bash-3.00# ldd /opt/coolstack/php5/lib/php/extensions/no-debug-non-zts-20060613/xsl.soNote that libxml2 is loaded twice. The reason is that when libxslt.so was loaded, it loaded libxml2.so from /usr/lib directory not from /opt/coolstack/lib directory. Reason is obvious /usr/lib/libxslt.so looks for a particular libxml2 (SUNW_1.6) and find it in /usr/lib directory. The result was obvious, xsl application failed to work with coolstack 1.2. Php crashed.
libreadline.so.5 => /opt/coolstack/lib/libreadline.so.5
libcurses.so.1 => /lib/libcurses.so.1
libexslt.so.0 => /usr/lib/libexslt.so.0
libxslt.so.1 => /usr/lib/libxslt.so.1
libxml2.so.2 => /opt/coolstack/lib/libxml2.so.2
libxml2.so.2 => /usr/lib/libxml2.so.2
- CoolStack 1.2 bundled libfreetype but didn't bundle
libfontconfig. Php's gd extension needs libgd.so. Here is the output
(edited) of ldd on libgd.so.
bash-3.00# ldd /opt/coolstack/lib/libgd.soNote that libfreetype.so is loaded twice. Once from /opt/coolstack/lib directory and once from /usr/sfw/lib directory. /usr/sfw/lib/libfreetype.so was loaded by /usr/lib/libfontconfig.so. If you look at the RPATH of libfontconfig, libfontconfig looks for libfreetype from /usr/sfw/lib directory.
libfontconfig.so.1 => /usr/lib/libfontconfig.so.1
libfreetype.so.6 => /opt/coolstack/lib/libfreetype.so.6
libpng12.so.0 => /usr/lib/libpng12.so.0
libiconv.so.2 => /opt/coolstack/lib/libiconv.so.2
libfreetype.so.6 => /usr/sfw/lib/libfreetype.so.6
libexpat.so.0 => /usr/sfw/lib/libexpat.so.0
bash-3.00# dump -Lvp /usr/lib/libfontconfig.so.1 | grep PATHI don't know what was the effect of the above problem but I believe it would have caused problem in gd's functionality.
 RUNPATH /usr/sfw/lib
 RPATH /usr/sfw/lib
- libexpat.so is present in /usr/sfw/lib which can be accedently get preference over /opt/coolstack/apache2/lib/libexpat.so
- libmysqlclient.so is present in /usr/sfw/lib. Clients can accidently load /usr/sfw/lib version, instead of /opt/coolstack/mysql_32bit/lib/mysql/libmysqlclient.so
- 1. libxslt is now bundled in CSKruntime package.
- libfontconfig is now bundled in CSKlibs package.
- To handle dependent libraries on /usr/sfw/lib CoolStack 1.3 now creates symlink in /opt/coolstack/lib directory. Similarily symlinks have been created to include header files from /usr/sfw/include.
- To the best of it's effort, none of the libraries have /usr/sfw/lib in it's RPATH/RUNPATH.
- Almost all of the places where /usr/sfw was passed in configure
options, now /opt/coostack is passed as a configure option. E.g.
--with-ssl=/usr/sfw is replaced with --with-ssl=/opt/coolstack
- Any library which links with libmysqlclient,
/opt/coolstack/mysql_32bit/lib/mysql is added into it's RPATH.
- libtool files create problems in linking other components. Therefore libtool files (.la) are not bundled in coolstack 1.3.