Re: New Cygwin maintainer

Ken Brown <[email protected]>
Newsgroups gmane.lisp.clisp.devel
Message-ID <[email protected]>
On 3/16/2015 2:28 PM, Blake McBride wrote:
> I noticed dynamic modules doesn't work on my 64 bit Linux either.  I too
> am using the respository head.  Any chances your patch will fix my
> problem too?
>
> If so, where do I get your patch?

The patches are pretty Cygwin-specific, but maybe there's an idea in 
there that could help you.  I'm attaching the current version.  (It 
could still change after further testing.)

Ken

------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/

_______________________________________________
clisp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/clisp-devel
build_lisp_dll_cygwin.patch (text/plain, 6.7 KB)
# HG changeset patch
# User Ken Brown <[email protected]>
# Date 1426247865 14400
#      Fri Mar 13 07:57:45 2015 -0400
# Node ID e306f0da362fbef4f307f0ebeceb52c151503528
# Parent  e2f47d3ad784831ace3ab5d4021e5996cf7e1877
Build lisp.dll on Cygwin for use in dynamic loading

* src/spvw.d: Rename "main" to "realmain" on Cygwin for use in
building lisp.dll.  We will then build lisp.exe by compiling
src/lisp.c (which defines "main") and linking it with lisp.dll.
* lisp.c: New file.
* src/makemake.in:
* src/clisp-link.in: Adapt to these changes.

diff -r e2f47d3ad784 -r e306f0da362f src/clisp-link.in
--- a/src/clisp-link.in	Fri Mar 13 07:49:03 2015 -0400
+++ b/src/clisp-link.in	Fri Mar 13 07:57:45 2015 -0400
@@ -83,9 +83,11 @@
 LISPRUN="lisp@LEXE@"
 # ensure that "$1" contains a CLISP linking set
 check_linkset () {
-  test -r "$1"/lisp.a -a -x "$1"/${LISPRUN} -a -r "$1"/lispinit.mem \
-    -a -r "$1"/modules.h -a -r "$1"/modules.o -a -r "$1"/makevars ||
-  fail "directory $1 does not contain a CLISP linking set"
+  local tests="-r $1/lisp.a -a -x $1/${LISPRUN} -a -r $1/lispinit.mem -a -r $1/modules.h -a -r $1/modules.o -a -r $1/makevars"
+  if [ "${HSYSOS}" = cygwin ] ; then
+    tests="${tests} -a -r $1/lisp.c"
+  fi
+  test ${tests} || fail "directory $1 does not contain a CLISP linking set"
 }
 
 # ensure that "$1" contains a CLISP module
@@ -113,7 +115,12 @@
   verbose ${CC} ${CPPFLAGS} ${CFLAGS} -I"$absolute_linkkitdir" -c modules.c
   rm -f modules.c
   # Generate new ${LISPRUN}
-  verbose ${CC} ${CFLAGS} ${CLFLAGS} modules.o ${LIBS} -o ${LISPRUN}
+  if [ "${HSYSOS}" != cygwin ] ; then
+    verbose ${CC} ${CFLAGS} ${CLFLAGS} modules.o ${LIBS} -o ${LISPRUN}
+  else
+    verbose ${CC} -shared ${CFLAGS} ${CLFLAGS} modules.o ${LIBS} -o cyglisp.dll -Wl,--enable-auto-import -Wl,--out-implib=liblisp.dll.a
+    verbose ${CC} ${CFLAGS} ${CLFLAGS} lisp.c -L. -llisp -o ${LISPRUN}
+  fi
 }
 
 # func_tmpdir
@@ -394,6 +401,9 @@
     if [ -z "$moduledirs" ] ; then
       # Just make links from $destinationdir to $sourcedir
       lncp_some "$sourcedir" "$destinationdir" ${LISPRUN} lispinit.mem modules.h modules.o makevars ${FILES};
+      if [ "${HSYSOS}" = cygwin ] ; then
+        lncp_some "$sourcedir" "$destinationdir" cyglisp.dll liblisp.dll.a
+      fi
     else
       cp "$sourcedir"/modules.h "$destinationdir"/modules.h
       FILES=`lncp_some "$sourcedir" "$destinationdir" ${FILES}`
diff -r e2f47d3ad784 -r e306f0da362f src/lisp.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lisp.c	Fri Mar 13 07:57:45 2015 -0400
@@ -0,0 +1,13 @@
+/*
+ * Copyright (C) 2015 Kenneth Brown
+ * This file is a part of GNU CLISP and is distributed under GNU GPL v2+
+ *
+ * This file is compiled only on Cygwin, to build lisp.exe by linking
+ * against lisp.dll.  */
+
+extern int realmain (int argc, char *argv[]); /* Defined in spvw.d.  */
+
+int
+main (int argc, char* argv[]) {
+  return realmain (argc, argv);
+}
diff -r e2f47d3ad784 -r e306f0da362f src/makemake.in
--- a/src/makemake.in	Fri Mar 13 07:49:03 2015 -0400
+++ b/src/makemake.in	Fri Mar 13 07:57:45 2015 -0400
@@ -1545,6 +1545,9 @@
 FILES="${GLLIB_A} "${FILES}
 
 FILES='lisp.a '$FILES
+if [ "${HSYSOS}" = cygwin ] ; then
+  FILES='lisp.c '$FILES
+fi 
 
 CPARTS='        spvw spvwtabf spvwtabs spvwtabo'
 CPARTS=$CPARTS' eval control'
@@ -2663,12 +2666,22 @@
 }
 fi
 
-echol "lisp${LEXE} : ${GLLIB_A} \$(OBJECTS) modules${TOBJ} ${XCL_GETTEXTLIB} data"
+if [ "${HSYSOS}" != cygwin ] ; then
+  echol "lisp${LEXE} : ${GLLIB_A} \$(OBJECTS) modules${TOBJ} ${XCL_GETTEXTLIB} data"
+else
+  echol "lisp.c : ${SRCDIR}lisp.c"
+  echotab "cp ${SRCDIR}lisp.c ."
+  echol
+  echol "lisp${LEXE} cyglisp.dll liblisp.dll.a : ${GLLIB_A} lisp.a modules${TOBJ} ${XCL_GETTEXTLIB} data lisp.c"
+fi
 if [ $HOS != win32 ] ; then
   if [ $XCC_GCC = true -a -n "$SOLARIS_LINKING" ] ; then
     # Dynamically linking on Solaris 2.[23] is a pain.
     LIBGCC_DIR='`'"${XCC} -print-libgcc-file-name"' | sed -e '"'"'s,[^/]*$$,,'"'"'`'
     echotab "${XCC} ${XCFLAGS} ${XCLFLAGS} \$(OBJECTS) modules${TOBJ} ${LIBS} -o lisp${LEXE} || /usr/ccs/bin/ld -V -dy -Bdynamic -Y P,/usr/ccs/lib:/usr/lib -Qy -o lisp${LEXE} ${LIBGCC_DIR}crt1.o ${LIBGCC_DIR}crti.o /usr/ccs/lib/values-Xa.o ${LIBGCC_DIR}crtbegin.o \$(OBJECTS) modules${TOBJ} -L${LIBGCC_DIR} -L/usr/ccs/bin ${LIBS} -lgcc -lc ${LIBGCC_DIR}crtend.o ${LIBGCC_DIR}crtn.o -lgcc"
+  elif [ "${HSYSOS}" = cygwin ] ; then
+    echotab "${XCC} -shared ${XCFLAGS} ${XCLFLAGS} modules${TOBJ} lisp.a ${LIBS} ${OUT}cyglisp.dll -Wl,--enable-auto-import -Wl,--out-implib=liblisp.dll.a"
+    echotab "${XCC} ${XCFLAGS} ${XCLFLAGS} lisp.c -L. -llisp ${OUT}lisp${LEXE}"
   else
     echotab "${XCC} ${XCFLAGS} ${XCLFLAGS} \$(OBJECTS) modules${TOBJ} ${LIBS} ${OUT}lisp${LEXE}"
   fi
@@ -3159,6 +3172,7 @@
   XCC_CREATESHARED_=`echo "$XCC_CREATESHARED" | sed -e 's,\\$,$$,g'`
   echotab "sed -e 's%@with_dynamic_modules@%${with_dynamic_modules}%' \\"
   echotab "    -e 's%@createsharedlib@%$XCC_CREATESHARED_%' \\"
+  echotab "    -e 's%@HSYSOS@%${HSYSOS}%' \\"
   echotab "    -e 's%@LEXE@%${LEXE}%' -e 's%@SHREXT@%${SHREXT}%' \\"
   if test -z "${CLISP_DEF}"; then
     echotab "    -e 's%@CLISP_DEF@%%' \\"
@@ -3489,7 +3503,7 @@
     echotab "for d in ${line}; do for f in \$\$d/*; do \\"
     echotab "  mkdir -p \$(DESTDIR)\$(lisplibdir)/\$\$d; \\"
     echotab "  case \$\$f in \\"
-    echotab "    */lisp${LEXE}) \$(INSTALL_PROGRAM) \$\$f \$(DESTDIR)\$(lisplibdir)/\$\$f;; \\"
+    echotab "    */lisp${LEXE}|*/cyglisp${SHREXT}) \$(INSTALL_PROGRAM) \$\$f \$(DESTDIR)\$(lisplibdir)/\$\$f;; \\"
     echotab "    *) \$(INSTALL_DATA) \$\$f \$(DESTDIR)\$(lisplibdir)/\$\$f;; \\"
     echotab "  esac; \\"
     echotab "done; done"
@@ -3880,7 +3894,7 @@
 # without changing the bytecode format and the tables in
 # constobj.d, constpack.d, constsym.d, subr.d, fsubr.d, pseudofun.d.
 clean1 : clean0
-	-\$(RM) lispbibl.h clisp.h *.i *.s *${TOBJ} *.a lisp${LEXE} clisp-link makevars ansi-tests-log ${CLISP_DEF}
+	-\$(RM) lispbibl.h clisp.h *.i *.s *${TOBJ} *.a lisp${LEXE} cyglisp${SHREXT} lisp.c clisp-link makevars ansi-tests-log ${CLISP_DEF}
 	-\$(RMRF) ${RECOMPILEDIR}
 	-\$(RMRF) ${TESTSDIR}
 	-\$(RMRF) ${ANSITESTSDIR}
diff -r e2f47d3ad784 -r e306f0da362f src/spvw.d
--- a/src/spvw.d	Fri Mar 13 07:49:03 2015 -0400
+++ b/src/spvw.d	Fri Mar 13 07:57:45 2015 -0400
@@ -3664,7 +3664,16 @@
 #ifndef argc_t
   #define argc_t int            /* Type of argc is mostly 'int'. */
 #endif
+
+/* On Cygwin we build cyglisp.dll with "main" renamed to "realmain".
+ We will then build lisp.exe by compiling lisp.c (which defines
+ "main") and linking with cyglisp.dll.  */
+#if defined(UNIX_CYGWIN32)
+  #define main realmain
+#endif
+
 global int main (argc_t argc, char* argv[]) {
+#undef main
   /* initialization of memory management.
    overall procedure:
    process command-line-options.
fix_dynamic_loading_cygwin.patch (text/plain, 3.7 KB)
# HG changeset patch
# User Ken Brown <[email protected]>
# Date 1426182319 14400
#      Thu Mar 12 13:45:19 2015 -0400
# Node ID 9ff524a1f78ab7fcf5cb25ca55efbf27c0adac61
# Parent  32d6c4cfcef539fd96cfdd7971050d3848f31048
Make dynamic loading work on Cygwin

* src/lispbibl.d [DYNAMIC_MODULES]: Treat Cygwin the same as non-win32
systems.
* src/clisp-link.in:
* src/makemake.in: Fix dynamic loading on Cygwin.

diff -r e306f0da362f src/clisp-link.in
--- a/src/clisp-link.in Fri Mar 13 07:57:45 2015 -0400
+++ b/src/clisp-link.in Fri Mar 13 11:50:24 2015 -0400
@@ -597,6 +597,9 @@
       # in the build directory, avoid "cp: `...' and `...' are the same file"
       if [ "${absolute_moduledir}" != "${absdestdir}/$moduledir" ]; then
         make clisp-module-distrib LN=${INSTALL_DATA-cp} distribdir="${absdestdir}/$moduledir"
+       if [ "${HSYSOS}" = cygwin ] ; then
+          ${INSTALL_DATA-cp} *.dll.a ${absdestdir}/${moduledir}
+       fi
         mkdir -p ${absdestdir}/${DYNMOD};
         for f in ${DYNDIR_FILES}; do
           cp ${f} ${absdestdir}/${DYNMOD}/
diff -r 32d6c4cfcef5 -r 9ff524a1f78a src/lispbibl.d
--- a/src/lispbibl.d	Thu Mar 12 13:23:02 2015 -0400
+++ b/src/lispbibl.d	Thu Mar 12 13:45:19 2015 -0400
@@ -559,7 +559,7 @@
    Info: resolving _mv_space by linking to __imp__mv_space (auto-import)
    on woe32. */
 #if defined(DYNAMIC_MODULES)
-  #if defined(WIN32_NATIVE) || defined(UNIX_CYGWIN32)
+  #if defined(WIN32_NATIVE)
     #define DYNAMIC_TABLES 1
     #define modexp  __declspec(dllexport)
     #define modimp  __declspec(dllimport)
@@ -568,6 +568,9 @@
     #define DYNAMIC_TABLES 0
     #define modexp
     #define modimp  extern
+    #if defined(UNIX_CYGWIN32)
+      #define EXECUTABLE_NAME "lisp.exe"
+    #endif
   #endif
 #else
   #define DYNAMIC_TABLES 0
diff -r 32d6c4cfcef5 -r 9ff524a1f78a src/makemake.in
--- a/src/makemake.in	Thu Mar 12 13:23:02 2015 -0400
+++ b/src/makemake.in	Thu Mar 12 13:45:19 2015 -0400
@@ -1376,13 +1376,24 @@
   # Support for dynamic loading.
   eval "`./libtool --tag=CC --config | grep '^pic_flag='`"
   eval XCC_PICFLAG=\"${pic_flag}\"
-  eval "`./libtool --tag=CC --config | grep '^archive_cmds='`"
+  if [ ${HSYSOS} != cygwin ]; then
+    eval "`./libtool --tag=CC --config | grep '^archive_cmds='`"
+  else
+    archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -L ${absolute_sourcedir} -llisp -o $output_objdir/$soname ${wl}--enable-auto-import ${wl}--out-implib=${dll}.a'
+  fi
   # http://article.gmane.org/gmane.comp.shells.bash.bugs:17158
   CC_set=${CC+set}
   CC_save=$CC
-  CC='${CC}' libobjs='$libs' deplibs='${CLFLAGS}' compiler_flags='${CFLAGS}' \
-    soname='$dll' lib='$lib' output_objdir='$dyndir' \
-    eval XCC_CREATESHARED=\"${archive_cmds}\"
+  if [ "${HSYSOS}" != cygwin ] ; then
+    CC='${CC}' libobjs='$libs' deplibs='${CLFLAGS}' compiler_flags='${CFLAGS}' \
+      soname='$dll' lib='$lib' output_objdir='$dyndir' \
+      eval XCC_CREATESHARED=\"${archive_cmds}\"
+  else
+    CC='${CC}' libobjs='$libs' deplibs='${CLFLAGS}' compiler_flags='${CFLAGS}' \
+      soname='$dll' lib='$lib' output_objdir='$dyndir' wl='-Wl,' \
+      absolute_sourcedir='$absolute_sourcedir' dll='$dll' \
+      eval XCC_CREATESHARED=\"${archive_cmds}\"
+  fi
   if test "$CC_set" = set
   then CC=$CC_save
   else unset CC
@@ -2604,7 +2615,7 @@
   echotab "\$(RANLIB) libnoreadline.a"
   echol
 fi
-if [ ${SHREXT} = .dll -a "${with_dynamic_modules}" != no ]; then
+if [ ${SHREXT} = .dll -a "${with_dynamic_modules}" != no -a "${HSYSOS}" != cygwin ]; then
   # win32 (SHREXT=.dll) requires all accessed libraries when linking a DLL.
   # i.e. when creating a dynamic module dll, we must give lisp.dll to the
   # linker, and when creating lisp.dll, we must give $(LIBS) to it.
no_symlink_dll_cygwin.patch (text/plain, 1.1 KB)
# HG changeset patch
# User Ken Brown <[email protected]>
# Date 1426247343 14400
#      Fri Mar 13 07:49:03 2015 -0400
# Node ID e2f47d3ad784831ace3ab5d4021e5996cf7e1877
# Parent  74b47369b904fba3b89b479173268d5382ab7189
* src/clisp-link.in (lncp): Don't symlink a DLL on Cygwin

diff -r 74b47369b904 -r e2f47d3ad784 src/clisp-link.in
--- a/src/clisp-link.in	Thu Mar 05 12:30:28 2015 -0500
+++ b/src/clisp-link.in	Fri Mar 13 07:49:03 2015 -0400
@@ -23,12 +23,20 @@
   echo `cd $1; cd ${dirname}; pwd`/`basename "$2"`
 }
 
+HSYSOS="@HSYSOS@"
+
 lncp () {
-  # Make a link from $1 to $2. Try symbolic link, hard link, file copying.
+  # Make a link from $1 to $2.  Try symbolic link, hard link, file
+  # copying.  Don't use a link on Cygwin if $1 is a DLL, because the
+  # Windows loader doesn't understand Cygwin symlinks.
   rm -f "$2"
-  ln -s "`normalize . $1`" "$2" 2>/dev/null || \
-    ln "$1" "$2" 2>/dev/null || \
+  if [ "${HSYSOS}" = cygwin -a ${1/.dll} != $1 ] ; then 
     cp -p "$1" "$2"
+  else
+    ln -s "`normalize . $1`" "$2" 2>/dev/null || \
+      ln "$1" "$2" 2>/dev/null || \
+      cp -p "$1" "$2"
+  fi
 }
 
 lncp_some () {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.