* termcap moodule problem on Cygwin @ 2001-01-29 14:55 Andrej Borsenkow 2001-01-29 15:10 ` Peter Stephenson 2001-01-29 16:48 ` Zefram 0 siblings, 2 replies; 12+ messages in thread From: Andrej Borsenkow @ 2001-01-29 14:55 UTC (permalink / raw) To: ZSH workers mailing list Cygwin has only static libtermcap. It gets linked twice - into main zsh (libzsh to be sure) where term is (re-)initalized and into termcap.dll where bin_echotc is defined. Only first one calls tgetent() so every call to `echotc cap' crashes somewhere in termcap. Calling tgetent in bin_echotc is not an option because it won't catch changed TERM. It means that code to deal with terminal should exist exactly once - in main zsh or in module. I vote for moving it into zle (after all, it is the only module that should care for TERM) together with bin_echotc. In any case, it makes idea of echotc in seperate module very questionable. Note, that Cygwin is not the only system with static termcap/terminfo. -andrej Have a nice DOS! B >> ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: termcap moodule problem on Cygwin 2001-01-29 14:55 termcap moodule problem on Cygwin Andrej Borsenkow @ 2001-01-29 15:10 ` Peter Stephenson 2001-01-30 8:25 ` Andrej Borsenkow 2001-01-29 16:48 ` Zefram 1 sibling, 1 reply; 12+ messages in thread From: Peter Stephenson @ 2001-01-29 15:10 UTC (permalink / raw) To: Zsh hackers list > Cygwin has only static libtermcap. It gets linked twice - into main zsh > (libzsh to be sure) where term is (re-)initalized and into termcap.dll where > bin_echotc is defined. Only first one calls tgetent() so every call to `echot > c > cap' crashes somewhere in termcap. It must surely be possible to make sure it is linked in once only, which would be the right thing to do. If the worst comes to the worst, get configure to detect a static termcap and only link it into the main module. -- Peter Stephenson <pws@csr.com> Software Engineer Cambridge Silicon Radio, Unit 300, Science Park, Milton Road, Cambridge, CB4 0XL, UK Tel: +44 (0)1223 392070 ^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: termcap moodule problem on Cygwin 2001-01-29 15:10 ` Peter Stephenson @ 2001-01-30 8:25 ` Andrej Borsenkow 2001-01-30 10:34 ` Peter Stephenson 0 siblings, 1 reply; 12+ messages in thread From: Andrej Borsenkow @ 2001-01-30 8:25 UTC (permalink / raw) To: Zsh hackers list Answering both Peter and Zefram: - it is not possible to simply link termcap into libzsh and then link termcap module against libzsh (if that is what Peter means). AFAIK it may be impossible on Win32 (it is not Cygwin limitation) - in any case, it needs completely different configuration system to find out exact set of libraries for every module. I am not even sure if any general solution is possible. I have to look what libtool can do. - even if it is possible to check for static vs. shared libtermcap (like currently with environ) it will disable modules (note, that on Cygwin environ check is explicitly disabled as it is misleading there). What is worse modules will be disabled on all systems that have static termcap/curses, and that are possibly many SVR4-derivates, mine including :-) Having termcap/terminfo as separate modules hardly justifies this. - the problem is not limited to Cygwin (obviously). Depending of used terminal library program may crash, echotc may not track terminal changes or everything may be O.K. You cannot tell in advance, sigh. - finally, having the whole terminal related code in main zsh and moving just a single builtin in seperate module looks funny. what we can do know is - add wrappers for tgetent & Co. and add note to zsh-development-guide that people should not use original functions. - move termcap (and terminfo) back into main zsh. Somehow I'm inclined to the latter. cheers -andrej ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: termcap moodule problem on Cygwin 2001-01-30 8:25 ` Andrej Borsenkow @ 2001-01-30 10:34 ` Peter Stephenson 2001-01-31 8:50 ` Somebody with gcc knowledge here? (Was: termcap moodule problem on Cygwin ) Andrej Borsenkow 2001-01-31 10:37 ` PATCH: RE: termcap moodule problem on Cygwin Andrej Borsenkow 0 siblings, 2 replies; 12+ messages in thread From: Peter Stephenson @ 2001-01-30 10:34 UTC (permalink / raw) To: Zsh hackers list > - move termcap (and terminfo) back into main zsh. You could force it to be statically linked by changing the `link' line to test for cygwin in termcap.mdd. See existing `link=' in terminfo.mdd for how this works. You can make this depend on a configure test for whether termcap is static. -- Peter Stephenson <pws@csr.com> Software Engineer Cambridge Silicon Radio, Unit 300, Science Park, Milton Road, Cambridge, CB4 0XL, UK Tel: +44 (0)1223 392070 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Somebody with gcc knowledge here? (Was: termcap moodule problem on Cygwin ) 2001-01-30 10:34 ` Peter Stephenson @ 2001-01-31 8:50 ` Andrej Borsenkow 2001-01-31 10:37 ` PATCH: RE: termcap moodule problem on Cygwin Andrej Borsenkow 1 sibling, 0 replies; 12+ messages in thread From: Andrej Borsenkow @ 2001-01-31 8:50 UTC (permalink / raw) To: Zsh hackers list > > - move termcap (and terminfo) back into main zsh. > > You could force it to be statically linked by changing the `link' line to > test for cygwin in termcap.mdd. See existing `link=' in terminfo.mdd for > how this works. You can make this depend on a configure test for whether > termcap is static. > Of course, I am idiot. Even more so as I cannot build zsh with static termcap: dllwrap -g --export-all-symbols -o libzsh-3.1.9-dev-8.dll `cat stamp-modobjs` -ltermcap -lm -lc dllwrap: no export definition file provided dllwrap: creating one, but that may not be what you want Modules/termcap.o(.text+0x318): multiple definition of `setup_zshQstermcap' Modules/termcap.o(.text+0x318): first defined here Modules/termcap.o(.text+0x324): multiple definition of `boot_zshQstermcap' Modules/termcap.o(.text+0x324): first defined here Modules/termcap.o(.text+0x354): multiple definition of `cleanup_zshQstermcap' Modules/termcap.o(.text+0x354): first defined here Modules/termcap.o(.text+0x37c): multiple definition of `finish_zshQstermcap' Modules/termcap.o(.text+0x37c): first defined here collect2: ld returned 1 exit status This happens with both dllwrap and gcc; I do not understand the error message at all. It does not happen when building static zsh. Anybody have some insight on what these errors mean? -andrej ^ permalink raw reply [flat|nested] 12+ messages in thread
* PATCH: RE: termcap moodule problem on Cygwin 2001-01-30 10:34 ` Peter Stephenson 2001-01-31 8:50 ` Somebody with gcc knowledge here? (Was: termcap moodule problem on Cygwin ) Andrej Borsenkow @ 2001-01-31 10:37 ` Andrej Borsenkow 2001-01-31 11:30 ` Peter Stephenson 1 sibling, 1 reply; 12+ messages in thread From: Andrej Borsenkow @ 2001-01-31 10:37 UTC (permalink / raw) To: Zsh hackers list [-- Attachment #1: Type: text/plain, Size: 731 bytes --] > > You could force it to be statically linked by changing the `link' line to > test for cygwin in termcap.mdd. See existing `link=' in terminfo.mdd for > how this works. You can make this depend on a configure test for whether > termcap is static. > This implements the latter. On two systems with static termcap/terminfo both are now compiled into main executable. I do not have any system with shared term library. I could try using ncurses on Cygwin, but zsh unconditionally includes termcap.h and it is incompatible with ncurses. Please, check with shared termcap if both modules are still built as shared :) I am fairly sure that check in current form does not work correctly on Cygwin (due to stab libraries). -andrej [-- Attachment #2: zsh.termcap.diff --] [-- Type: application/octet-stream, Size: 7711 bytes --] Index: aczsh.m4 =================================================================== RCS file: /cvsroot/zsh/zsh/aczsh.m4,v retrieving revision 1.6 diff -u -r1.6 aczsh.m4 --- aczsh.m4 2000/10/11 12:26:13 1.6 +++ aczsh.m4 2001/01/31 10:32:38 @@ -111,28 +111,30 @@ dnl -dnl zsh_SYS_DYNAMIC_BROKEN -dnl Check whether static/shared library linking is broken. +dnl zsh_SHARED_SYMBOL +dnl Check whether symbol is available in static or shared library dnl dnl On some systems, static modifiable library symbols (such as environ) dnl may appear only in statically linked libraries. If this is the case, dnl then two shared libraries that reference the same symbol, each linked dnl with the static library, could be given distinct copies of the symbol. -dnl If this is the case then dynamic linking is FUBAR. dnl +dnl Usage: zsh_SHARED_SYMBOL(ident,type) +dnl Sets zsh_cv_shared_$1 cache variable to yes/no +dnl -AC_DEFUN(zsh_SYS_DYNAMIC_BROKEN, -[AC_CACHE_CHECK([if static/shared library linking is broken], -zsh_cv_sys_dynamic_broken, +AC_DEFUN(zsh_SHARED_SYMBOL, +[AC_CACHE_CHECK([if $1 is available in shared libraries], +zsh_cv_shared_$1, [if test "$zsh_cv_func_dlsym_needs_underscore" = yes; then us=_ else us= fi echo ' - extern char **environ; + extern $2 **$1; void *symlist1[[]] = { - (void *)&environ, + (void *)&$1, (void *)0 }; ' > conftest1.c @@ -185,12 +187,12 @@ exit(1); exit(0); } -], [zsh_cv_sys_dynamic_broken=no], -[zsh_cv_sys_dynamic_broken=yes], -[zsh_cv_sys_dynamic_broken=yes] +], [zsh_cv_shared_$1=yes], +[zsh_cv_shared_$1=no], +[zsh_cv_shared_$1=no] ) else - zsh_cv_sys_dynamic_broken=yes + zsh_cv_shared_$1=no fi ]) ]) Index: configure.in =================================================================== RCS file: /cvsroot/zsh/zsh/configure.in,v retrieving revision 1.39 diff -u -r1.39 configure.in --- configure.in 2001/01/19 14:47:44 1.39 +++ configure.in 2001/01/31 10:32:39 @@ -557,37 +557,6 @@ AC_DEFINE(MUST_DEFINE_OSPEED) fi -dnl Check if tgetent accepts NULL (and will allocate its own termcap buffer) -dnl Some termcaps reportedly accept a zero buffer, but then dump core -dnl in tgetstr(). -dnl Under Cygwin test program crashes but exit code is still 0. So, -dnl we test for a file that porgram should create -AC_CACHE_CHECK(if tgetent accepts NULL, -zsh_cv_func_tgetent_accepts_null, -[AC_TRY_RUN([ -main() -{ - int i = tgetent((char*)0,"vt100"); - if (i > 0) { - char tbuf[1024], *u; - u = tbuf; - tgetstr("cl", &u); - creat("conftest.tgetent", 0640); - } - exit(!i || i == -1); -} -], - if test -f conftest.tgetent; then - zsh_cv_func_tgetent_accepts_null=yes - else - zsh_cv_func_tgetent_accepts_null=no - fi, - zsh_cv_func_tgetent_accepts_null=no, - zsh_cv_func_tgetent_accepts_null=no)]) -if test $zsh_cv_func_tgetent_accepts_null = yes; then - AC_DEFINE(TGETENT_ACCEPTS_NULL) -fi - dnl -------------- dnl CHECK TYPEDEFS dnl -------------- @@ -845,9 +814,40 @@ putenv getenv \ brk sbrk \ pathconf sysconf \ - tigetflag tigetnum tigetstr) + tgetent tigetflag tigetnum tigetstr) AC_FUNC_STRCOLL +dnl Check if tgetent accepts NULL (and will allocate its own termcap buffer) +dnl Some termcaps reportedly accept a zero buffer, but then dump core +dnl in tgetstr(). +dnl Under Cygwin test program crashes but exit code is still 0. So, +dnl we test for a file that porgram should create +AC_CACHE_CHECK(if tgetent accepts NULL, +zsh_cv_func_tgetent_accepts_null, +[AC_TRY_RUN([ +main() +{ + int i = tgetent((char*)0,"vt100"); + if (i > 0) { + char tbuf[1024], *u; + u = tbuf; + tgetstr("cl", &u); + creat("conftest.tgetent", 0640); + } + exit(!i || i == -1); +} +], + if test -f conftest.tgetent; then + zsh_cv_func_tgetent_accepts_null=yes + else + zsh_cv_func_tgetent_accepts_null=no + fi, + zsh_cv_func_tgetent_accepts_null=no, + zsh_cv_func_tgetent_accepts_null=no)]) +if test $zsh_cv_func_tgetent_accepts_null = yes; then + AC_DEFINE(TGETENT_ACCEPTS_NULL) +fi + AC_FUNC_MMAP if test x$ac_cv_func_mmap_fixed_mapped = xyes; then AC_CHECK_FUNCS(munmap msync) @@ -1471,7 +1471,10 @@ zsh_cv_sys_dynamic_execsyms="${zsh_cv_sys_dynamic_execsyms=no}" zsh_cv_sys_dynamic_strip_exe="${zsh_cv_sys_dynamic_strip_exe=yes}" zsh_cv_sys_dynamic_strip_lib="${zsh_cv_sys_dynamic_strip_lib=yes}" - zsh_cv_sys_dynamic_broken="${zsh_cv_sys_dynamic_broken=no}" + # + # THAT SUCKS! and must be changed + # + zsh_cv_shared_environ="${zsh_cv_shared_environ=yes}" LINKMODS=LINKMODS MOD_EXPORT="__attribute__((__dllexport__))" MOD_IMPORT_VARIABLE="__attribute__((__dllimport__))" @@ -1616,8 +1619,15 @@ fi if test "x$dynamic" = xyes; then - zsh_SYS_DYNAMIC_BROKEN - test "$zsh_cv_sys_dynamic_broken" = no || dynamic=no + zsh_SHARED_SYMBOL([environ], [char **]) + test "$zsh_cv_shared_environ" = yes || dynamic=no +dnl test "$zsh_cv_sys_dynamic_broken" = no || dynamic=no + if test "$ac_cv_func_tgetent" = yes; then + zsh_SHARED_SYMBOL([tgetent], [(void (*)())]) + fi + if test "$ac_cv_func_tigetstr" = yes; then + zsh_SHARED_SYMBOL([tigetstr], [(void (*)())]) + fi fi if test "x$dynamic" = xyes; then Index: Src/Modules/termcap.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Modules/termcap.c,v retrieving revision 1.1 diff -u -r1.1 termcap.c --- Src/Modules/termcap.c 2000/12/03 20:53:25 1.1 +++ Src/Modules/termcap.c 2001/01/31 10:32:40 @@ -33,7 +33,7 @@ /* echotc: output a termcap */ /**/ -int +static int bin_echotc(char *name, char **argv, char *ops, int func) { char *s, buf[2048], *t, *u; Index: Src/Modules/termcap.mdd =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Modules/termcap.mdd,v retrieving revision 1.1 diff -u -r1.1 termcap.mdd --- Src/Modules/termcap.mdd 2000/12/03 20:53:25 1.1 +++ Src/Modules/termcap.mdd 2001/01/31 10:32:40 @@ -1,5 +1,15 @@ name=zsh/termcap -link=either + +link='if test "x$ac_cv_func_tgetent" = xyes; then + if test "x$zsh_cv_shared_tgetent" = xyes; then + echo either + else + echo static + fi + else + echo no; + fi +' load=yes autobins="echotc" Index: Src/Modules/terminfo.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Modules/terminfo.c,v retrieving revision 1.4 diff -u -r1.4 terminfo.c --- Src/Modules/terminfo.c 2000/12/06 01:16:15 1.4 +++ Src/Modules/terminfo.c 2001/01/31 10:32:40 @@ -36,7 +36,7 @@ /* echoti: output a terminfo capability */ /**/ -int +static int bin_echoti(char *name, char **argv, char *ops, int func) { char *s, *t; Index: Src/Modules/terminfo.mdd =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Modules/terminfo.mdd,v retrieving revision 1.3 diff -u -r1.3 terminfo.mdd --- Src/Modules/terminfo.mdd 2000/12/05 11:00:09 1.3 +++ Src/Modules/terminfo.mdd 2001/01/31 10:32:40 @@ -1,5 +1,15 @@ name=zsh/terminfo -link='if test "x$ac_cv_func_tigetstr" = xyes; then echo either; else echo no; fi' + +link='if test "x$ac_cv_func_tigetstr" = xyes; then + if test "x$zsh_cv_shared_tigetstr" = xyes; then + echo either + else + echo static + fi + else + echo no; + fi +' load=yes autobins="echoti" ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: PATCH: RE: termcap moodule problem on Cygwin 2001-01-31 10:37 ` PATCH: RE: termcap moodule problem on Cygwin Andrej Borsenkow @ 2001-01-31 11:30 ` Peter Stephenson 2001-01-31 12:42 ` Andrej Borsenkow 0 siblings, 1 reply; 12+ messages in thread From: Peter Stephenson @ 2001-01-31 11:30 UTC (permalink / raw) To: Zsh hackers list > This implements the latter. On two systems with static termcap/terminfo both > are now compiled into main executable. This turns the linking on SunOS 5.6 from dynamic to static for the two modules. It was working OK before with dynamic. However, the curses library which is linked in does appear to be static. On the other hand, our new server with SunOS 5.8 appears to have a dynamic curses library, but the test still fails, although: % nm /lib/libcurses.so | grep tgetent [1176] | 95876| 52|FUNC |GLOB |0 |9 |tgetent The libraries used are `-lsocket -ldl -lnsl -lcurses -lm -lc'. Does anyone have any evidence of termcap still being linked in dynamically with the patch in place? I can't promise I'll get a chance to look at what's happening immediately. -- Peter Stephenson <pws@csr.com> Software Engineer Cambridge Silicon Radio, Unit 300, Science Park, Milton Road, Cambridge, CB4 0XL, UK Tel: +44 (0)1223 392070 ^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: PATCH: RE: termcap moodule problem on Cygwin 2001-01-31 11:30 ` Peter Stephenson @ 2001-01-31 12:42 ` Andrej Borsenkow 2001-01-31 13:49 ` Peter Stephenson 0 siblings, 1 reply; 12+ messages in thread From: Andrej Borsenkow @ 2001-01-31 12:42 UTC (permalink / raw) To: Zsh hackers list > > This turns the linking on SunOS 5.6 from dynamic to static for the two > modules. It was working OK before with dynamic. However, the curses > library which is linked in does appear to be static. On the other hand, > our new server with SunOS 5.8 appears to have a dynamic curses library, but > the test still fails, although: > % nm /lib/libcurses.so | grep tgetent > [1176] | 95876| 52|FUNC |GLOB |0 |9 |tgetent > The libraries used are `-lsocket -ldl -lnsl -lcurses -lm -lc'. > Yes, test was broken, sorry. Try this patch (on top of previous). The situation looks a bit more complicated. On my system name resolution in shared modules happens at runtime (unless you override it) so all modules pick up just one copy of curses library linked into main executable. Cool. -andrej --- aczsh.m4.old Wed Jan 31 13:31:38 2001 +++ aczsh.m4 Wed Jan 31 15:31:46 2001 @@ -111,6 +111,38 @@ dnl +dnl zsh_SHARED_FUNCTION +dnl Check whether symbol is available in static or shared library +dnl +dnl On some systems, static modifiable library symbols (such as environ) +dnl may appear only in statically linked libraries. If this is the case, +dnl then two shared libraries that reference the same symbol, each linked +dnl with the static library, could be given distinct copies of the symbol. +dnl +dnl Usage: zsh_SHARED_FUNCTION(name) +dnl Sets zsh_cv_shared_$1 cache variable to yes/no +dnl + +AC_DEFUN(zsh_SHARED_FUNCTION, +[zsh_SHARED_SYMBOL($1, [char *$1()], [$1])]) + +dnl +dnl zsh_SHARED_VARIABLE +dnl Check whether symbol is available in static or shared library +dnl +dnl On some systems, static modifiable library symbols (such as environ) +dnl may appear only in statically linked libraries. If this is the case, +dnl then two shared libraries that reference the same symbol, each linked +dnl with the static library, could be given distinct copies of the symbol. +dnl +dnl Usage: zsh_SHARED_VARIABLE(name,type) +dnl Sets zsh_cv_shared_$1 cache variable to yes/no +dnl + +AC_DEFUN(zsh_SHARED_VARIABLE, +[zsh_SHARED_SYMBOL($1, [ $2 $1], [&$1])]) + +dnl dnl zsh_SHARED_SYMBOL dnl Check whether symbol is available in static or shared library dnl @@ -119,7 +151,7 @@ dnl then two shared libraries that reference the same symbol, each linked dnl with the static library, could be given distinct copies of the symbol. dnl -dnl Usage: zsh_SHARED_SYMBOL(ident,type) +dnl Usage: zsh_SHARED_SYMBOL(name,declaration) dnl Sets zsh_cv_shared_$1 cache variable to yes/no dnl @@ -132,9 +164,12 @@ us= fi echo ' - extern $2 **$1; - void *symlist1[[]] = { - (void *)&$1, +#ifdef __CYGWIN__ + __attribute__((__dllimport__)) +#endif + extern $2; + void *symlist[[]] = { + (void *)$3, (void *)0 }; ' > conftest1.c @@ -179,8 +214,8 @@ if(!handle1) exit(1); handle2 = dlopen("./conftest2.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL); if(!handle2) exit(1); - symlist1 = (void **) dlsym(handle1, "${us}symlist1"); - symlist2 = (void **) dlsym(handle2, "${us}symlist2"); + symlist1 = (void **) dlsym(handle1, "${us}symlist"); + symlist2 = (void **) dlsym(handle2, "${us}symlist"); if(!symlist1 || !symlist2) exit(1); for(; *symlist1; symlist1++, symlist2++) if(*symlist1 != *symlist2) bor@itsrm2% gdiff -u configure.in.old configure.in --- configure.in.old Wed Jan 31 14:45:05 2001 +++ configure.in Wed Jan 31 15:32:05 2001 @@ -1619,17 +1619,16 @@ fi if test "x$dynamic" = xyes; then - zsh_SHARED_SYMBOL([environ], [char **]) + zsh_SHARED_VARIABLE([environ], [char **]) test "$zsh_cv_shared_environ" = yes || dynamic=no dnl test "$zsh_cv_sys_dynamic_broken" = no || dynamic=no if test "$ac_cv_func_tgetent" = yes; then - zsh_SHARED_SYMBOL([tgetent], [(void (*)())]) + zsh_SHARED_FUNCTION([tgetent]) fi if test "$ac_cv_func_tigetstr" = yes; then - zsh_SHARED_SYMBOL([tigetstr], [(void (*)())]) + zsh_SHARED_FUNCTION([tigetstr]) fi fi - zsh_SHARED_SYMBOL([socket], [(void (*)())]) if test "x$dynamic" = xyes; then zsh_SYS_DYNAMIC_CLASH ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: PATCH: RE: termcap moodule problem on Cygwin 2001-01-31 12:42 ` Andrej Borsenkow @ 2001-01-31 13:49 ` Peter Stephenson 2001-02-05 15:31 ` Andrej Borsenkow 0 siblings, 1 reply; 12+ messages in thread From: Peter Stephenson @ 2001-01-31 13:49 UTC (permalink / raw) To: Zsh hackers list > Yes, test was broken, sorry. Try this patch (on top of previous). That's fine, both libraries are now dynamically linked on both versions of Solaris, which is what was happening before the patch. -- Peter Stephenson <pws@csr.com> Software Engineer Cambridge Silicon Radio, Unit 300, Science Park, Milton Road, Cambridge, CB4 0XL, UK Tel: +44 (0)1223 392070 ^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: PATCH: RE: termcap moodule problem on Cygwin 2001-01-31 13:49 ` Peter Stephenson @ 2001-02-05 15:31 ` Andrej Borsenkow 2001-02-13 14:36 ` Andrej Borsenkow 0 siblings, 1 reply; 12+ messages in thread From: Andrej Borsenkow @ 2001-02-05 15:31 UTC (permalink / raw) To: Peter Stephenson, Zsh hackers list [-- Attachment #1: Type: text/plain, Size: 1062 bytes --] > > > > Yes, test was broken, sorry. Try this patch (on top of previous). > > That's fine, both libraries are now dynamically linked on both versions of > Solaris, which is what was happening before the patch. > O.K., hopefully the last version. Now it really works for Cygwin, both shared and static libs. I tested it with: - Unix, pseudo-shared (see below) static curses - Cygwin, static termcap - Cygwin, shared ncurses So, remaining case is Unix with real shared library and possibly Unix with bad-behaving static library. Solaris 2.6 and my system both provide pseudo-shared implementation - static symbols are linked into every shared object, but references to them are resolved at runtime and point to the single copy of static symbol. It has one possible drawback - if shared object that owns this static symbol is unloaded, references are no more valid. So far, my system seems to correctly keep reference count. It depends on coimpiler options (I can force local binding). So I added test for this case as well - dunno if it really helps. -andrej [-- Attachment #2: zsh.termcap.diff --] [-- Type: application/octet-stream, Size: 10217 bytes --] Index: aczsh.m4 =================================================================== RCS file: /cvsroot/zsh/zsh/aczsh.m4,v retrieving revision 1.6 diff -u -r1.6 aczsh.m4 --- aczsh.m4 2000/10/11 12:26:13 1.6 +++ aczsh.m4 2001/02/05 15:24:13 @@ -111,32 +111,59 @@ dnl -dnl zsh_SYS_DYNAMIC_BROKEN -dnl Check whether static/shared library linking is broken. +dnl zsh_SHARED_FUNCTION dnl +dnl This is just a frontend to zsh_SHARED_SYMBOL +dnl +dnl Usage: zsh_SHARED_FUNCTION(name[,rettype[,paramtype]]) +dnl + +AC_DEFUN(zsh_SHARED_FUNCTION, +[zsh_SHARED_SYMBOL($1, ifelse([$2], ,[int ],[$2]) $1 [(]ifelse([$3], ,[ ],[$3])[)], $1)]) + +dnl +dnl zsh_SHARED_VARIABLE +dnl +dnl This is just a frontend to zsh_SHARED_SYMBOL +dnl +dnl Usage: zsh_SHARED_VARIABLE(name[,type]) +dnl + +AC_DEFUN(zsh_SHARED_VARIABLE, +[zsh_SHARED_SYMBOL($1, ifelse([$2], ,[int ],[$2]) $1, [&$1])]) + +dnl +dnl zsh_SHARED_SYMBOL +dnl Check whether symbol is available in static or shared library +dnl dnl On some systems, static modifiable library symbols (such as environ) dnl may appear only in statically linked libraries. If this is the case, dnl then two shared libraries that reference the same symbol, each linked dnl with the static library, could be given distinct copies of the symbol. -dnl If this is the case then dynamic linking is FUBAR. +dnl +dnl Usage: zsh_SHARED_SYMBOL(name,declaration,address) +dnl Sets zsh_cv_shared_$1 cache variable to yes/no dnl -AC_DEFUN(zsh_SYS_DYNAMIC_BROKEN, -[AC_CACHE_CHECK([if static/shared library linking is broken], -zsh_cv_sys_dynamic_broken, +AC_DEFUN(zsh_SHARED_SYMBOL, +[AC_CACHE_CHECK([if $1 is available in shared libraries], +zsh_cv_shared_$1, [if test "$zsh_cv_func_dlsym_needs_underscore" = yes; then us=_ else us= fi echo ' - extern char **environ; - void *symlist1[[]] = { - (void *)&environ, - (void *)0 - }; +void *zsh_getaddr1() +{ +#ifdef __CYGWIN__ + __attribute__((__dllimport__)) +#endif + extern $2; + return $3; +}; ' > conftest1.c -sed 's/symlist1/symlist2/' < conftest1.c > conftest2.c +sed 's/zsh_getaddr1/zsh_getaddr2/' < conftest1.c > conftest2.c if $CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&5 2>&5 && $DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS 1>&5 2>&5 && $CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest2.c 1>&5 2>&5 && @@ -172,25 +199,33 @@ main() { void *handle1, *handle2; - void **symlist1, **symlist2; + void *(*zsh_getaddr1)(), *(*zsh_getaddr2)(); + void *sym1, *sym2; handle1 = dlopen("./conftest1.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL); if(!handle1) exit(1); handle2 = dlopen("./conftest2.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL); if(!handle2) exit(1); - symlist1 = (void **) dlsym(handle1, "${us}symlist1"); - symlist2 = (void **) dlsym(handle2, "${us}symlist2"); - if(!symlist1 || !symlist2) exit(1); - for(; *symlist1; symlist1++, symlist2++) - if(*symlist1 != *symlist2) - exit(1); + zsh_getaddr1 = (void *(*)()) dlsym(handle1, "${us}zsh_getaddr1"); + zsh_getaddr2 = (void *(*)()) dlsym(handle2, "${us}zsh_getaddr2"); + sym1 = zsh_getaddr1(); + sym2 = zsh_getaddr2(); + if(!sym1 || !sym2) exit(1); + if(sym1 != sym2) exit(1); + dlclose(handle1); + handle1 = dlopen("./conftest1.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL); + if(!handle1) exit(1); + zsh_getaddr1 = (void *(*)()) dlsym(handle1, "${us}zsh_getaddr1"); + sym1 = zsh_getaddr1(); + if(!sym1) exit(1); + if(sym1 != sym2) exit(1); exit(0); } -], [zsh_cv_sys_dynamic_broken=no], -[zsh_cv_sys_dynamic_broken=yes], -[zsh_cv_sys_dynamic_broken=yes] +], [zsh_cv_shared_$1=yes], +[zsh_cv_shared_$1=no], +[zsh_cv_shared_$1=no] ) else - zsh_cv_sys_dynamic_broken=yes + zsh_cv_shared_$1=no fi ]) ]) Index: configure.in =================================================================== RCS file: /cvsroot/zsh/zsh/configure.in,v retrieving revision 1.39 diff -u -r1.39 configure.in --- configure.in 2001/01/19 14:47:44 1.39 +++ configure.in 2001/02/05 15:24:14 @@ -493,7 +493,9 @@ dnl On some systems, modules need to be linked against libc explicitly, dnl in case they require objects that exist only in the static version dnl and might not be compiled into the zsh executable. -AC_CHECK_LIB(c, printf) +dnl On ReliantUNIX -lc better be the last library, else funny things +dnl may happen. +AC_CHECK_LIB(c, printf, [LIBS="$LIBS -lc"]) AC_CHECK_LIB(m, pow) @@ -557,37 +559,6 @@ AC_DEFINE(MUST_DEFINE_OSPEED) fi -dnl Check if tgetent accepts NULL (and will allocate its own termcap buffer) -dnl Some termcaps reportedly accept a zero buffer, but then dump core -dnl in tgetstr(). -dnl Under Cygwin test program crashes but exit code is still 0. So, -dnl we test for a file that porgram should create -AC_CACHE_CHECK(if tgetent accepts NULL, -zsh_cv_func_tgetent_accepts_null, -[AC_TRY_RUN([ -main() -{ - int i = tgetent((char*)0,"vt100"); - if (i > 0) { - char tbuf[1024], *u; - u = tbuf; - tgetstr("cl", &u); - creat("conftest.tgetent", 0640); - } - exit(!i || i == -1); -} -], - if test -f conftest.tgetent; then - zsh_cv_func_tgetent_accepts_null=yes - else - zsh_cv_func_tgetent_accepts_null=no - fi, - zsh_cv_func_tgetent_accepts_null=no, - zsh_cv_func_tgetent_accepts_null=no)]) -if test $zsh_cv_func_tgetent_accepts_null = yes; then - AC_DEFINE(TGETENT_ACCEPTS_NULL) -fi - dnl -------------- dnl CHECK TYPEDEFS dnl -------------- @@ -845,9 +816,40 @@ putenv getenv \ brk sbrk \ pathconf sysconf \ - tigetflag tigetnum tigetstr) + tgetent tigetflag tigetnum tigetstr) AC_FUNC_STRCOLL +dnl Check if tgetent accepts NULL (and will allocate its own termcap buffer) +dnl Some termcaps reportedly accept a zero buffer, but then dump core +dnl in tgetstr(). +dnl Under Cygwin test program crashes but exit code is still 0. So, +dnl we test for a file that porgram should create +AC_CACHE_CHECK(if tgetent accepts NULL, +zsh_cv_func_tgetent_accepts_null, +[AC_TRY_RUN([ +main() +{ + int i = tgetent((char*)0,"vt100"); + if (i > 0) { + char tbuf[1024], *u; + u = tbuf; + tgetstr("cl", &u); + creat("conftest.tgetent", 0640); + } + exit(!i || i == -1); +} +], + if test -f conftest.tgetent; then + zsh_cv_func_tgetent_accepts_null=yes + else + zsh_cv_func_tgetent_accepts_null=no + fi, + zsh_cv_func_tgetent_accepts_null=no, + zsh_cv_func_tgetent_accepts_null=no)]) +if test $zsh_cv_func_tgetent_accepts_null = yes; then + AC_DEFINE(TGETENT_ACCEPTS_NULL) +fi + AC_FUNC_MMAP if test x$ac_cv_func_mmap_fixed_mapped = xyes; then AC_CHECK_FUNCS(munmap msync) @@ -1471,7 +1473,10 @@ zsh_cv_sys_dynamic_execsyms="${zsh_cv_sys_dynamic_execsyms=no}" zsh_cv_sys_dynamic_strip_exe="${zsh_cv_sys_dynamic_strip_exe=yes}" zsh_cv_sys_dynamic_strip_lib="${zsh_cv_sys_dynamic_strip_lib=yes}" - zsh_cv_sys_dynamic_broken="${zsh_cv_sys_dynamic_broken=no}" + # + # THAT SUCKS! and must be changed + # + zsh_cv_shared_environ="${zsh_cv_shared_environ=yes}" LINKMODS=LINKMODS MOD_EXPORT="__attribute__((__dllexport__))" MOD_IMPORT_VARIABLE="__attribute__((__dllimport__))" @@ -1616,8 +1621,15 @@ fi if test "x$dynamic" = xyes; then - zsh_SYS_DYNAMIC_BROKEN - test "$zsh_cv_sys_dynamic_broken" = no || dynamic=no + zsh_SHARED_VARIABLE([environ], [char **]) + test "$zsh_cv_shared_environ" = yes || dynamic=no +dnl test "$zsh_cv_sys_dynamic_broken" = no || dynamic=no + if test "$ac_cv_func_tgetent" = yes; then + zsh_SHARED_FUNCTION([tgetent]) + fi + if test "$ac_cv_func_tigetstr" = yes; then + zsh_SHARED_FUNCTION([tigetstr]) + fi fi if test "x$dynamic" = xyes; then Index: Src/Modules/termcap.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Modules/termcap.c,v retrieving revision 1.1 diff -u -r1.1 termcap.c --- Src/Modules/termcap.c 2000/12/03 20:53:25 1.1 +++ Src/Modules/termcap.c 2001/02/05 15:24:16 @@ -33,7 +33,7 @@ /* echotc: output a termcap */ /**/ -int +static int bin_echotc(char *name, char **argv, char *ops, int func) { char *s, buf[2048], *t, *u; Index: Src/Modules/termcap.mdd =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Modules/termcap.mdd,v retrieving revision 1.1 diff -u -r1.1 termcap.mdd --- Src/Modules/termcap.mdd 2000/12/03 20:53:25 1.1 +++ Src/Modules/termcap.mdd 2001/02/05 15:24:16 @@ -1,5 +1,15 @@ name=zsh/termcap -link=either + +link='if test "x$ac_cv_func_tgetent" = xyes; then + if test "x$zsh_cv_shared_tgetent" = xyes; then + echo either + else + echo static + fi + else + echo no; + fi +' load=yes autobins="echotc" Index: Src/Modules/terminfo.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Modules/terminfo.c,v retrieving revision 1.4 diff -u -r1.4 terminfo.c --- Src/Modules/terminfo.c 2000/12/06 01:16:15 1.4 +++ Src/Modules/terminfo.c 2001/02/05 15:24:16 @@ -36,7 +36,7 @@ /* echoti: output a terminfo capability */ /**/ -int +static int bin_echoti(char *name, char **argv, char *ops, int func) { char *s, *t; Index: Src/Modules/terminfo.mdd =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Modules/terminfo.mdd,v retrieving revision 1.3 diff -u -r1.3 terminfo.mdd --- Src/Modules/terminfo.mdd 2000/12/05 11:00:09 1.3 +++ Src/Modules/terminfo.mdd 2001/02/05 15:24:16 @@ -1,5 +1,15 @@ name=zsh/terminfo -link='if test "x$ac_cv_func_tigetstr" = xyes; then echo either; else echo no; fi' + +link='if test "x$ac_cv_func_tigetstr" = xyes; then + if test "x$zsh_cv_shared_tigetstr" = xyes; then + echo either + else + echo static + fi + else + echo no; + fi +' load=yes autobins="echoti" ^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: PATCH: RE: termcap moodule problem on Cygwin 2001-02-05 15:31 ` Andrej Borsenkow @ 2001-02-13 14:36 ` Andrej Borsenkow 0 siblings, 0 replies; 12+ messages in thread From: Andrej Borsenkow @ 2001-02-13 14:36 UTC (permalink / raw) To: Zsh hackers list > > O.K., hopefully the last version. Nobody answered and it works fine here so I've committed it (13431) -andrej ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: termcap moodule problem on Cygwin 2001-01-29 14:55 termcap moodule problem on Cygwin Andrej Borsenkow 2001-01-29 15:10 ` Peter Stephenson @ 2001-01-29 16:48 ` Zefram 1 sibling, 0 replies; 12+ messages in thread From: Zefram @ 2001-01-29 16:48 UTC (permalink / raw) To: Andrej Borsenkow; +Cc: ZSH workers mailing list Andrej Borsenkow wrote: >Cygwin has only static libtermcap. It gets linked twice - into main zsh >(libzsh to be sure) where term is (re-)initalized and into termcap.dll where >bin_echotc is defined. Only first one calls tgetent() so every call to `echotc >cap' crashes somewhere in termcap. We've had this problem before, with a static `environ' symbol. There's an autoconf test for it in aczsh.m4. Is there an appropriate symbol here that we can use to test for a static termcap, to extend the test? -zefram ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2001-02-13 14:36 UTC | newest] Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2001-01-29 14:55 termcap moodule problem on Cygwin Andrej Borsenkow 2001-01-29 15:10 ` Peter Stephenson 2001-01-30 8:25 ` Andrej Borsenkow 2001-01-30 10:34 ` Peter Stephenson 2001-01-31 8:50 ` Somebody with gcc knowledge here? (Was: termcap moodule problem on Cygwin ) Andrej Borsenkow 2001-01-31 10:37 ` PATCH: RE: termcap moodule problem on Cygwin Andrej Borsenkow 2001-01-31 11:30 ` Peter Stephenson 2001-01-31 12:42 ` Andrej Borsenkow 2001-01-31 13:49 ` Peter Stephenson 2001-02-05 15:31 ` Andrej Borsenkow 2001-02-13 14:36 ` Andrej Borsenkow 2001-01-29 16:48 ` Zefram
Code repositories for project(s) associated with this public inbox https://git.vuxu.org/mirror/zsh/ This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).