List Info

Thread: Building GNU Smalltalk-2.3.5 with MinGW




Building GNU Smalltalk-2.3.5 with MinGW
country flaguser name
United Kingdom
2007-06-14 11:27:31
Hi,

I've been playing with compiling GNU Smalltalk-2.3.5 on
MinGW and had
some success. I have been able to build the code and
"make check" passes
with only one failure (quit.st), but some issues remain with
paths that
need further work and, probably, more knowledge of the
internals of GNU
Smalltalk than I have. With the enclosed changes applied,
remaking the
documentation will fail due to path issues and any paths
supplied need
to be in c:/some/where format rather than c:somewhere. I
haven't
extensively tested the program further than "make
check" so other issues
may be present too, but I'm posting my changes in the hope
that they
might be useful towards a full MinGW port.

The build sequence I used was:

* Run    ./configure --without-readline --without-gmp
* Edit the top Makefile and change  `cygpath -w gsticon.ico`
 to just
gsticon.ico
* in the tests directory run     unix2dos -o *.ok
* Apply the enclosed changes to lib-src/poll.c,
libgst/cint.c,
libgst/sysdep.c, kernel/Directory.st, kernel/File.st and
kernel/FileDescr.st 
* type  make
* type  make  again (the first make fails when rebuilding
the classes
doc)
* make check (maybe more than once if it tries to rebuild
the doc again)

Freddie



## ---------------------- ##
## Detailed failed tests. ##
## ---------------------- ##

#                             -*- compilation -*-
22. testsuite.at:48: testing ...
./testsuite.at:48: cd $abs_srcdir && $GST -r quit.st
2>&1
--- expout      Thu Jun 14 13:21:23 2007
+++
/home/faa59/smalltalk-2.3.5/tests/testsuite.dir/at-stdout  
Thu Jun
14 13:21
:23 2007
 -1,2
+0,0 
-^M
-Execution begins...^M
22. testsuite.at:48: 22. quit.st (testsuite.at:48): FAILED
(testsuite.at:48)


## ---------------------- ##
## Code changes           ##
## ---------------------- ##

--- ../smalltalk-2.3.5-orig/lib-src/poll.c	Wed Jan  3
10:51:30 2007
+++ lib-src/poll.c	Thu Jun 14 13:55:29 2007
 -19,14
+19,45 
    with this program; if not, write to the Free Software
Foundation,
    Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
 
+
 #include "config.h"
 
 #include <sys/types.h>
 #include "poll.h"
 #include <errno.h>
+#include <stdio.h>
 #include <limits.h>
-#include <sys/socket.h>
-#include <sys/select.h>
+#include <windows.h>
+#include <winsock2.h>
+#include <io.h>
+
+#undef FD_ISSET
+#define FD_ISSET(fd, set) my_fd_isset(fd, set)  /* to avoid
a WSA call
*/
+
+static int my_fd_isset(int fd, fd_set* set)
+{
+	int i;
+	if (set == NULL)
+	{
+	    return 0;
+	}
+	for(i=0; i < set->fd_count; i++)
+	{
+		if (set->fd_array[i] == fd)
+		{
+			return 1;
+		}
+	}
+	return 0;
+}
+
+#define ESHUTDOWN WSAESHUTDOWN
+#define ENOTCONN WSAENOTCONN
+#define ECONNRESET WSAECONNRESET
+#define ECONNABORTED WSAECONNABORTED
+#define ENETRESET WSAENETRESET
+
+typedef int nfds_t;
 #include <unistd.h>
 
 #ifdef HAVE_SYS_IOCTL_H
 -55,6
+86,76 
 #define EOVERFLOW EINVAL
 #endif
 
+// n = maxfd + 1
+#define MAX_WIN_HANDLES	300
+static int win_select(int n, fd_set *rfds, fd_set *wfds,
fd_set *efds,
struct timeval *ptv)
+{
+	HANDLE handle_array[MAX_WIN_HANDLES];
+        int handle_fd[MAX_WIN_HANDLES];
+	fd_set* handle_set[MAX_WIN_HANDLES];
+	int i;
+	DWORD ret, wait_timeout, nhandles = 0;
+	int nset, done;
+	done = 0;
+	nset = 0;
+	_flushall();
+		for(i=0; i<n; i++)
+		{
+			if ((efds != NULL) && FD_ISSET(i, efds))
+			{
+				FD_CLR(i, efds);		/*
assume no exceptions */
+			}
+			if ((wfds != NULL) && FD_ISSET(i, wfds))
+			{
+				handle_array[nhandles] =
(HANDLE)_get_osfhandle(i);
+				handle_fd[nhandles] = i;
+				handle_set[nhandles] = wfds;
+				nhandles++;
+				FD_CLR(i, wfds);		/* we
will set it later if there is output */
+			}
+			if ((rfds != NULL) && FD_ISSET(i, rfds))
+			{
+				handle_array[nhandles] =
(HANDLE)_get_osfhandle(i);
+				handle_fd[nhandles] = i;
+				handle_set[nhandles] = rfds;
+				nhandles++;
+				FD_CLR(i, rfds);		/* we
will set it later if there is input */
+			}
+		}
+/* do a quick poll - WaitForMultipleObjects only tells us
if 1 handle
+ is ready and there may be more */
+		for(i=0; i<nhandles; i++)
+		{
+		    ret = WaitForSingleObject(handle_array[i], 0);
+		    if (ret == WAIT_OBJECT_0)
+		    {
+			FD_SET(handle_fd[i], handle_set[i]);
+			nset++;
+		    }
+		}
+		if ((nset == 0) && (nhandles > 0)) // nothing
set, so
wait full time
+		{
+		    if (ptv == NULL)
+		    {
+			wait_timeout = INFINITE;
+		    }
+		    else
+		    {
+			wait_timeout = ptv->tv_sec * 1000 + ptv->tv_usec
/ 1000;
+		    }
+/* Need to use MsgWaitForMultipleObjects and maybe pump
messages if a
GUI application? */
+
+			ret = WaitForMultipleObjectsEx(nhandles,
handle_array, FALSE, wait_timeout, FALSE);
+			i = ret - WAIT_OBJECT_0;
+			if (i >= 0 && i < nhandles)
+			{
+				FD_SET(handle_fd[i], handle_set[i]);
+				nset++;
+			}
+		}
+	return nset;
+}
+
 int
 poll (pfd, nfd, timeout)
      struct pollfd *pfd;
 -142,8
+243,9 
     }
 
   /* examine fd sets */
-  rc = select (maxfd + 1, &rfds, &wfds, &efds,
ptv);
-  if (rc < 0)
+   rc = win_select (maxfd + 1, &rfds, &wfds,
&efds, ptv);
+    
+	if (rc < 0)
     return rc;
 
   /* establish results */
 -158,6
+260,7 
 	  {
 	    int r;
 	    
+	    char data[64];
 #if defined __MACH__ && defined __APPLE__
 	    /* There is a bug in Mac OS X that causes it to
ignore
MSG_PEEK
 	       for some kinds of descriptors.  Detect if this
descriptor
is a
 -167,9
+270,9 
 	    if (r == 0 || errno == ENOTSOCK)
 	      ioctl(pfd[i].fd, FIONREAD, &r);
 #else
-	    char data[64];
-	    r = recv (pfd[i].fd, data, sizeof (data), MSG_PEEK);
+//	    r = recv (pfd[i].fd, data, sizeof (data),
MSG_PEEK);
 #endif
+	    r = 1;
 	    if (r == 0)
 	      happened |= POLLHUP;
 	    
--- ../smalltalk-2.3.5-orig/libgst/cint.c	Thu Dec  7
08:09:12 2006
+++ libgst/cint.c	Thu Jun 14 12:19:44 2007
 -341,7
+341,8 
   times[0].tv_sec = new_atime + 86400 * 10957;
   times[1].tv_sec = new_mtime + 86400 * 10957;
   times[0].tv_usec = times[1].tv_usec = 0;
-  result = utimes (name, times);
+  result = 0;
+  printf("utimes calledn"); /* needs fixing */
   if (!result)
     errno = 0;
   return (result);
--- ../smalltalk-2.3.5-orig/libgst/sysdep.c	Mon May  7
14:12:04 2007
+++ libgst/sysdep.c	Thu Jun 14 12:18:17 2007
 -710,7
+710,7 
   char *cwd;
   char *ret;
   unsigned path_max;
-  int save_errno;
+  int i, save_errno;
 
   path_max = (unsigned) PATH_MAX;
   path_max += 2;		/* The getcwd docs say to do this.  */
 -721,6
+721,11 
   do
     {
       ret = getcwd (cwd, path_max);
+      for(i=0; i<strlen(cwd); i++)
+      {
+        if (cwd[i] == '\')
+          cwd[i] = '/';
+      }
       if (ret)
 	return (cwd);
 
--- ../smalltalk-2.3.5-orig/kernel/Directory.st	Sun Feb  5
18:41:26 2006
+++ kernel/Directory.st	Thu Jun 14 12:17:52 2007
 -108,6
+108,10 
     directory isEmpty ifTrue: [ ^fileName ].
     (fileName at: 1) = self pathSeparator
 	ifTrue: [ ^fileName ].
+    "Check to see if building up a windows absolute
path from scratch
i.e. appending X: to /"
+    ((directory = '/') and: [ (fileName size = 2) and: [
((fileName at:
2) = $
]]) ifTrue: [ ^fileName ].
+    "Check for a complete absolute windows path of
form X:/"
+    ((fileName size >= 3) and: [ ((fileName at: 2) =
$ and:
[
((fileName at: 3) = $/) ]]) ifTrue: [ ^fileName ].
     (self pathSeparator = $ and: [ fileName size >= 2
and: [
 	(fileName at: 2) = $: ]]) ifTrue: [ ^fileName ].
     ^(directory at: directory size) = self pathSeparator
--- ../smalltalk-2.3.5-orig/kernel/File.st	Sun Feb  5
18:41:26 2006
+++ kernel/File.st	Thu Jun 14 12:17:00 2007
 -132,9
+132,19 
     "Answer the full path to a file called `aString',
resolving the `.'
and
      `..' directory entries, and answer the result.  `/..'
is the same
as '/'."
 
-    | path substrings |
+    | path substrings respath isAbsolute |
+    isAbsolute _ false.
+    "Windows paths starting X:/ are absolute"
+    (aString size >= 3) ifTrue: [ 
+	( ((aString at: 2) = $ &
((aString at: 3) = $/) ) ifTrue: [
+	    isAbsolute _ true
+	]
+    ].
+    ((aString at: 1) = Directory pathSeparator) ifTrue: [
+        isAbsolute _ true.
+    ].
     path := OrderedCollection new.
-    (aString at: 1) = Directory pathSeparator ifFalse: [
+    isAbsolute ifFalse: [
 	path addAll: (Directory working substrings: Directory
pathSeparator).
     ].
     substrings := aString substrings: Directory
pathSeparator.
 -148,9
+158,16 
 	]
     ].
 
-    ^path inject: '/' into: [ :old :each |
+    respath _ path inject: '/' into: [ :old :each |
 	Directory append: each to: old
-    ]
+    ].
+    "remove initial / from /C:/"
+    (respath size >= 4) ifTrue: [ 
+	( ((respath at: 1) = $/) & ((respath at: 3) = $ &
((respath
at: 4) = $/) ) ifTrue: [
+	    respath _ respath copyFrom: 2
+	]
+    ].
+    ^respath
 ! !
 
 
--- ../smalltalk-2.3.5-orig/kernel/FileDescr.st	Fri May 18
12:35:09 2007
+++ kernel/FileDescr.st	Thu Jun 14 12:16:21 2007
 -103,7
+103,8 
      finished with it anyway, using #close. To keep a file
open even
when
      no references exist anymore, send it
#removeToBeFinalized"
 
-    ((fileName indexOfSubCollection: ':/') > 0 and: [
+"look for :// rather than :/ to avoid matching
C:/some/where on
windows"
+    ((fileName indexOfSubCollection: '://') > 0 and: [
         fileMode = FileStream read ]) ifTrue: [
            ^NetClients.URIResolver openStreamOn: fileName
].



_______________________________________________
help-smalltalk mailing list
help-smalltalkgnu.org

http://lists.gnu.org/mailman/listinfo/help-smalltalk

Re: Building GNU Smalltalk-2.3.5 with MinGW
country flaguser name
Switzerland
2007-06-15 10:27:53
Akeroyd, FA (Freddie) wrote:
 > Hi,
 >
 > I've been playing with compiling GNU Smalltalk-2.3.5
on MinGW and had
 > some success.

Great!

 > With the enclosed changes applied, remaking the
 > documentation will fail due to path issues and any
paths supplied need
 > to be in c:/some/where format rather than
c:somewhere.

The attached patch, on top of 2.3.5, is my take on this.  It
fixes all 
path issues, so the only things left should be:

1) modifying _gst_set_file_access_times to use the
appropriate Windows 
API function

2) figuring out what to do with poll

3) figuring out why tests are failing without unix2dos.  One
possibility 
could be the second patch I attach, please tell me if it
works.

Please send future patches relative to this one (I suggest
that you 
create your own CVS/svn/Arch/git repository).  Thanks!

Paolo


_______________________________________________
help-smalltalk mailing list
help-smalltalkgnu.org

http://lists.gnu.org/mailman/listinfo/help-smalltalk

  
  
Re: Building GNU Smalltalk-2.3.5 with MinGW
country flaguser name
Italy
2007-06-16 04:51:25
Akeroyd, FA (Freddie) wrote:
> Thanks for the patches ... unfortunately I've been
busier today than I
> though and so haven't been able to try them out
properly, but will be
> able to do that next week. With regard to patch 2 for
the testsuite, I
> think what you suggest would work but unfortunately the
diff supplied
> with MinGW does not seem to support that option. Using
"diff
> --ignore-space-change" works, but is not an ideal
solution. 

Could you check instead if "sed b < foo >
bar" has the same effect as 
"unix2dos"?

Thanks,

Paolo


_______________________________________________
help-smalltalk mailing list
help-smalltalkgnu.org

http://lists.gnu.org/mailman/listinfo/help-smalltalk

RE: Building GNU Smalltalk-2.3.5 with MinGW
country flaguser name
United Kingdom
2007-06-18 09:57:08
> The attached patch, on top of 2.3.5, is my take on
this.  It fixes all

> path issues, so the only things left should be:

I've rebuilt my MinGW version using the supplied patches and
the program
compiles and creates an image OK. There are, however, two
test failures
on a make check (quit.st and fileext.st). The quit test is
probably to
do with buffer flushing at program exit and I will look at
that; the
details of the filext failure are:

18. testsuite.at:44: testing ...
./testsuite.at:44: cd $abs_srcdir && $GST -r
fileext.st 2>&1
--- expout	Mon Jun 18 13:54:50 2007
+++ tests/testsuite.dir/at-stdout	Mon Jun 18 13:54:50 2007
 -11,18
+11,18 
 true
 true
 true
+false
 true
 true
 true
 true
+false
 true
 true
 true
 true
 true
-true
-true
-true
+false
 true
 true
 true
18. testsuite.at:44: 18. fileext.st (testsuite.at:44):
FAILED
(testsuite.at:44)

Also if I try to rebuild the documentation with

touch kernel/File.st
make

It fails with the following error:

Making all in doc
make[2]: Entering directory
`/home/faa59/Smalltalk_gnu/smalltalk-2.3.5/doc'
rm -f ./classes.texi
builddir=`pwd`; gst=$builddir/../gst;
gst_im=$builddir/../gst.im; 
cd . && 
  $gst -I $gst_im -f ../scripts/GenBaseDoc.st 
  Smalltalk SystemExceptions NetClients VFS
writing documentation for AbstractNamespace
Object: FileStream error: could not open
C:msys1.0homefaa59Smalltalk_gnusmalltalk-2.3.5/C:/msys
/1.0/home/fa
a59/Smalltalk_gnu/smalltalk-2.3.5/kernel/AbstNamespc.st
SystemExceptions.FileError(Exception)>>#signal
SystemExceptions.FileError class(Exception
class)>>#signal:
[] in FileStream class(FileDescriptor
class)>>#open:mode:
[] in FileStream class(FileDescriptor
class)>>#fopen:mode:ifFail:
FileStream(FileDescriptor)>>#fileOp:with:with:ifFail:
FileStream class(FileDescriptor
class)>>#fopen:mode:ifFail:
VFS.RealFileHandler>>#open:mode:ifFail:
FileStream class(FileDescriptor class)>>#open:mode:
FileSegment>>#withFileDo:
FileSegment>>#asString
MethodInfo>>#sourceString
 

> Could you check instead if "sed b < foo >
bar" has the same effect as
"unix2dos"?

Unfortunately not - no r characters are added to the lines
and so the
tests still fail. However the Windows putchar() function
intercepts a
bare n and substitutes rn so the following piece of C
code will do
the conversion on windows and leave things unchanged on
unix:

#include <stdio.h>
int main(int argc, char* argv[])
{
    int c;
    while( (c = getchar()) != EOF )
    {
	putchar(c);
    }
    return 0;
}

> modifying _gst_set_file_access_times to use the
appropriate Windows
API function

Windows provides an implementation of the POSIX utime()
function which
should do the job for us. I notice the current code uses
utimes() rather
than utime() - is utimes() generally more widely available
or is this
usage purely for historical reasons?

Freddie



_______________________________________________
help-smalltalk mailing list
help-smalltalkgnu.org

http://lists.gnu.org/mailman/listinfo/help-smalltalk

Re: Building GNU Smalltalk-2.3.5 with MinGW
country flaguser name
United States
2007-06-20 20:09:26
On Tue, 2007-06-19 at 14:22 +0200, Paolo Bonzini wrote:
> The bug you found in fullNameFor: is also real; to fix
it, you can 
> simply use "old, self pathSeparatorString,
each" instead of "Directory 

Or, better yet, "{old. self pathSeparatorString. each}
joinAll", in
devo. 

-- 
;;; Stephen Compall ** http://scompall.no
candysw.com/blog **
"Peta" is Greek for fifth; a petabyte is 10 to the
fifth power, as
well as fifth in line after kilo, mega, giga, and tera.
  -- Lee Gomes, performing every Wednesday in his tech
column
     "Portals" on page B1 of The Wall Street
Journal

_______________________________________________
help-smalltalk mailing list
help-smalltalkgnu.org

http://lists.gnu.org/mailman/listinfo/help-smalltalk

[1-5]

about | contact  Other archives ( Real Estate discussion Medical topics )