Parent: [12d14e] (diff)

Download this file

README-DYNAMIC    161 lines (134 with data), 5.5 kB

On most modern systems, TCL can load shared objects at run time (the
"load" command). This allows having only one interpreter executable
and let it load extensions as needed, as opposed to linking statically
with all the extensions you need, or having as many interpreters as
extensions or combinations thereof.

As far as I know, things work allright with the standard sqlscreens
configure script and Makefile for the systems on which I develop and test:
 - gcc 2.7 or egcs 1.1
 - mysql-3.21 or 3.22
 - FreeBSD 2.2.8 and 3.1, Linux rh4.2 and 5.2, solaris2.5

In case things don't workout here follows a small cookbook to get
things to work under different circumstances:

TCL issues:
===========
On FreeBSD 3.2 and later which are ELF-based, tclsh (up to and including
8.2.0) and wish should be linked with the -rdynamic gcc option (or
equivalently -Wl,-export-dynamic, or -export-dynamic for ld). The
standard TCL Makefiles don't do it. This will preclude any kind of
dynamic loading because Tcl_PkgProvide() will be undefined when trying 
to load the module. -rdynamic should probably be used on all ELF-based 
systems (it is used on Linux already).

Fix: edit the tclsh and wish Makefiles and add -rdynamic to the link
command (if gcc is used, or -export-dynamic if ld is used).


MySQL issues:
=============
- If you're using MySQL 3.22.xx or newer, MySQL has full shared lib
  support, you can skip this paragraph.

- Before release 3.22, MySQL doesn't compile the client library as a
  shared object by default. On some systems, if you try to build
  mysqltcl.so in this case, you may get a myriad errors and a
  final message like: 

   ld: fatal: relocations remain against allocatable but non-writable
   sections 

In this case, you have to build a shared mysqlclient library.

 There is an option to do it under Linux, but it fails on other
systems because the object files are not generated with correct
compilation flags.

 So the recipe is:

 1- If you installed MySQL from a binary distribution, get the MySQL
 source distribution, unpack it, do a 
 "configure --without-server --enable-shared" and a "make". 
 2- Then cd to the client/ subdirectory
 3- Under Linux, run a "make shlib" there. Under solaris and FreeBSD,
 you can use the small makefiles provided in the sqlscreens "aux"
 directory. There are two versions for mysql3.20 and 3.21, they should
 work with similar versions as long as the client library file list
 does not change. 
 4- Copy the shared library file (libmysqlclient.so.xx) to
 /usr/local/mysql/lib or /usr/local/lib/mysql, depending on your
 configuration 
 5- Then "make distclean" in the sqlscreens directory, and rerun
 configuration and installation there

On some systems, you'll also have to add the mysql library directory
to your LD_LIBRARY_PATH, or change the "ldconfig" boot time cmd.


libgcc issues
=============
 On most systems, libgcc is not compiled as a shared library (one
exception being FreeBSD).

 The mysqltcl shared object (or any other extension) may need routines
from libgcc that were not statically loaded when wish or tclsh was
generated. When the extension is loaded at run time, this produces
error messages in the fashion of: 

    can't resolve symbol '__moddi3'

A way out of this is to link mysqltcl.so with libgcc 
by adding  -L<ligccdir> -lgcc to the link command, as 
the standard script does for solaris.
  Ex: -L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.7.2.3/ -lgcc
The exact values depend on the compiler you're using, you can get the
name of the library by running "gcc -v".

In case this doesn't work, another way out is to is to generate the
interpreters again, in a way that they load all symbols from libgcc. This
doesn't make them much bigger, because libgcc is small. Actually you
only need to deal with 'wish' as 'tclsh' is not needed to use
sqlscreens.

To do this, you add "-u" options to the 'wish' link command line in
the 'wish' Makefile to force loading all symbols from libgcc, and then
relink.

You'll have to get the source code for tcl and tk, configure and
compile them normally, then edit the Makefile (wish?.?/unix/Makefile)
to add the -u options, and rerun the link (remove tclsh or wish, then
run make again). You can find the "link" command easily by searching
for '-o'.

Then install the new wish, and make sure that it is the one that gets
executed when you type 'wish' (there might be another version on the
system).

The following "-u" list works for me (gcc 2.7.2). If this is not Ok
for you, you'll have to run an "nm" on libgcc, and make another list
(that's what I did):


GCCUNDEFS = -u __gcc_bcmp  \
-u __ashldi3  \
-u __ashrdi3  \
-u __bb_exit_func  \
-u __bb_init_func  \
-u __clear_cache  \
-u __cmpdi2  \
-u __divdi3  \
-u __find_first_exception_table_match  \
-u __register_exceptions  \
-u __throw_type_match  \
-u __unwind_function  \
-u __eprintf  \
-u _exit_dummy_decl  \
-u __ffsdi2  \
-u __fixdfdi  \
-u __fixsfdi  \
-u __fixtfdi  \
-u __fixunsdfdi  \
-u __fixunsdfsi  \
-u __fixunssfdi  \
-u __fixunssfsi  \
-u __fixunstfdi  \
-u __floatdidf  \
-u __floatdisf  \
-u __floatditf  \
-u __lshrdi3  \
-u __moddi3  \
-u __muldi3  \
-u __negdi2  \
-u __default_new_handler  \
-u __new_handler  \
-u set_new_handler  \
-u ___builtin_delete  \
-u ___builtin_new  \
-u ___builtin_vec_delete  \
-u ___builtin_vec_new  \
-u __pure_virtual  \
-u __shtab  \
-u __ucmpdi2  \
-u __udiv_w_sdiv  \
-u __udivdi3  \
-u __udivmoddi4  \
-u __umoddi3  \
-u ___builtin_saveregs  \
-u __builtin_saveregs