Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: zsh-3.1.0-test3 release

Andrej Borsenkow wrote:
> > It may now support dynamic loading on SVR4 systems.  Try it.  If it does not
> > work, send a patch to fix it.
> > 
> Yes, it works. There is a small problem in linking libzsh.so - I have to
> think it over. In short:
>   zsh is linked with -ltermcap. But now termcap functions are used  in
>   libzsh.so and not in zsh. If termcap is static (and we have only static
>   version), it is not used when linking, and I get run-time error when 
>   accessing termcap functions.
> Probably, we need to split LIBS between those neede for zsh itself (does
> it need any at all?) and libzsh.so. As the whole code is now in libzsh.so,
> probably it is enough:
> zsh: $(PROTO) $(ANSI@U@KNR) $(@L@IBZSH) $(@L@OBJS)                              
>      $(LINK) $(@L@OBJS) -lzsh
> $(LIBZSH): $(LIBOBJS)                                                           
>         $(DLLD) $(LDFLAGS) $(DLLDFLAGS) -o $(LIBZSH) $(LIBOBJS) $(LIBS)         
>         ln -sf $(LIBZSH) libzsh.so                                              
> where libs doesn't include -lzsh?                                              

I'm afraid it's a bit more difficult problem.  Of course executable part
which is main.c only does not need any library other than libzsh.  So if
-ltermcap is not dynamic it must be linked to libzsh.  But is it really
possible?  Dynamic libs usually need -fpic (btw. zsh is quite big, maybe
this should be -fPIC instead) and if termcap is not dynamic it was probably
compiled without -fpic.  On some architectures every code is position
independent so -fpic is not necessary.  With some binary formats libraries
do not have to be position independent. 

If one can use a termcap lib linked to the dynamic libzsh one can also make
a dummy dynamic library linked with termcap which can then be used instead
of the missing libtermcap.so dynamic lib.  Alternatively everyone who can
compile zsh can also compile GNU termcap or ncurses dynamically (with that
I'm just saying that it is a very silly thing from an OS vendor not
providing dynamic termcap, it just encourage its users not to use its

On elf systems a shared library may seem to work even without -fpic since
the dynamic loader can relocate the code but such a library will not be
shared since the relocation will change the text section.

> BTW it would be nice to be able to compile static as well as dynamic
> version of zsh from te same Makefile.

Do you mean without recompiling everything?  There are some conditional
compilation in the source which means that everything has to be recompiled.

You can always build multiple versions using separate build directories
(the build directory is always the directory from where you issued
configure).  This way you can buld static and dynamic versions or
multi-architecture versions without duplicating the code.  I use that
feature regularily building optimized zsh for everyday use and an other
version for debugging without optimization and with all sorts of internal
debugging enabled.


Messages sorted by: Reverse Date, Date, Thread, Author