[haiku-development] Re: Fixing Jam for Cygwin

  • From: Christian Packmann <Christian.Packmann@xxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Fri, 13 Feb 2009 16:21:18 +0100

Maurice Kalinowski wrote:
If the problem lies only with Jams handling of the __cygwin__ symbol, we
could simply use __CYGWIN__ to make the proper include in
jam/fileunix.c. Jam itself doesn't seem to care about __CYGWIN__, a 'grep __CYGWIN__ *' in its source dir gives no results.

I'd need to set up cygwin again here. So in case you play around with it and recognize that it is possible to successfully build haiku with your changes, I would trust your patch.

I patched Jam with the #ifdef __CYGWIN__, and it builds Haiku just fine, tested with Haiku4 on Cygwin, Haiku2 on Linux. The images work okay in VMWare. I also changed Jams version identifier to the current date, so it's clear that this is a changed version.
I'm sending the patch with this mail - if you prefer this via private email in 
the future, let me know.

And while we're patching: I also did some minor corrections to the Mandelbrot 
demo:
- changed function names iterate() and iterate1() to more descriptive iterate_float() and iterate_double()
- set better starting position for Mandelbrot set
- add higher values to "Iterations" menu: 2048, 4096, 8192


I switched to building haiku in a linux vm, copy the image over and start haiku from Windows VM player. I know this sounds weird, but is still much faster on my machine than using the crippled cygwin/gcc environment.

Wow. Night and day... I'll also build in a Linux VM from now on.
I don't know how everyone else copies data from their VM, but my most 
painless/reliable method is to set up a FTP server in the LinuxVM and then 
fetch the image automatically from the Windows side with a short Python script. 
In case anyone wants it:

------- FetchHaikuImage.py --------------
from ftplib import FTP

print 'Opening FTP connection to server...\n'
ftp = FTP('192.168.0.10')
ftp.login()

ftp.cwd('trunk/generated/')
ftp.retrlines('LIST')

print '\nRetrieving "haiku.vmdk"...'
ftp.retrbinary('RETR haiku.vmdk', open('haiku.vmdk', 'wb').write)

ftp.quit()
-----------------------------------------

You have to adjust the IP, and make sure that your VMs IP doesn't jump due to 
DHCP configuration etc.; I assigned a fixed IP on the Linux side.
The FTP servers root directory is set to my Haiku dev directory which contains 
the trunk and buildtools dirs; it's configured for anon access - otherwise 
you'd need to provide login/password.
The script will fetch to the directory the script is started from.
Oh, and the LIST command is not necessary, just a showoff how easy this stuff 
is in Python. :)

Actually I am not sure if the performance problems with building on Windows is related to cygwin gcc or the case sensitive drive.

Not GCC itself I think, in that case I should get a high CPU load across my 
four cores (Q9550/3.5GHz), but even a jam -j 4 only uses an average of slightly 
more than 50% CPU time. I think it's some problem with file access locking in 
Cygwin - may be the managed volumes, may be some more general Cygin problem. It 
is not the harddisk I/O as such, as Windows buffers all file accesses, so the 
HD light barely flickers.

In comparison: my Linux VM (OpenSuSE 10) with 1GB vRAM and 2 vCPUs takes less 
than half the time with jam -j 2, using less host CPU time and effectively 
using less RAM - the accesses to the VMDKs don't seem to be cached, so a build 
doesn't spam Windows' disk cache. Linux itself buffers the disk accesses nicely 
though, so that after an initial loading frenzy the HD stays pretty quiet, too.

All in all, Cygwin builds really can't be recommended; the time needed for 
setting up a Linux VM will be recovered after doing only a couple of builds.

Christian
Index: fileunix.c
===================================================================
--- fileunix.c  (Revision 29182)
+++ fileunix.c  (Arbeitskopie)
@@ -58,6 +58,10 @@
 # define STRUCT_DIRENT struct dirent 
 # endif
 
+# ifdef __CYGWIN__
+# include <unistd.h>
+# endif
+
 # ifdef OS_COHERENT
 # include <arcoff.h>
 # define HAVE_AR
Index: patchlevel.h
===================================================================
--- patchlevel.h        (Revision 29182)
+++ patchlevel.h        (Arbeitskopie)
@@ -1,5 +1,5 @@
 /* Keep JAMVERSYM in sync with VERSION. */
 /* It can be accessed as $(JAMVERSION) in the Jamfile. */
 
-#define VERSION "2.5-haiku-20080327"
+#define VERSION "2.5-haiku-20090213"
 #define JAMVERSYM "JAMVERSION=2.5"

Index: Mandelbrot.cpp
===================================================================
--- Mandelbrot.cpp      (revision 29181)
+++ Mandelbrot.cpp      (working copy)
@@ -72,6 +72,9 @@
        menu->AddItem(new BMenuItem("512", new BMessage(512)));
        menu->AddItem(new BMenuItem("768", new BMessage(768)));
        menu->AddItem(new BMenuItem("1024", new BMessage(1024)));
+       menu->AddItem(new BMenuItem("2048", new BMessage(2048)));
+       menu->AddItem(new BMenuItem("4096", new BMessage(4096)));
+       menu->AddItem(new BMenuItem("8192", new BMessage(8192)));
        menuBar->AddItem(menu);
 
        item->SetMarked(true);
@@ -173,6 +176,9 @@
                case 512:
                case 768:
                case 1024:
+               case 2048:
+               case 4096:
+               case 8192:
                        fView->set_iter(message->what);
                        break;
 
Index: tsb.cpp
===================================================================
--- tsb.cpp     (revision 29181)
+++ tsb.cpp     (working copy)
@@ -150,9 +150,9 @@
        the_bitmap = new BBitmap(bitmap_r, B_COLOR_8_BIT);
        bits = (char *)the_bitmap->Bits();
        memset(bits, 0x00, size_x*size_y);
-       px = -1.5;
-       py = -1.5;
-       scale = 3.0;
+       px = -2.5;
+       py = -2.0;
+       scale = 4.0;
        set_palette(2);
 }
 
@@ -174,7 +174,7 @@
 /*------------------------------------------------------------*/
 
 
-int iterate1(double a, double b)
+int iterate_double(double a, double b)
 {
        double  x;
        double  y;
@@ -203,7 +203,7 @@
 //extern "C" int iterate(float a, float b);
 /*------------------------------------------------------------*/
 
-int iterate(float a, float b)
+int iterate_float(float a, float b)
 {
        float   x;
        float   y;
@@ -309,13 +309,13 @@
                if (scale < 0.000025 || niter != 256) {
                        for (x = 0; x < 32; x++) {
                                cx += sx;
-                               pc[x][y] = iterate1(cx, cy);
+                               pc[x][y] = iterate_double(cx, cy);
                        }
                }
                else
                for (x = 0; x < 32; x++) {
                        cx += sx;
-                       pc[x][y] = iterate(cx, cy);
+                       pc[x][y] = iterate_float(cx, cy);
                }
        }
 }
@@ -366,14 +366,14 @@
                                if (scale < 0.000025 || niter != 256) {
                                        for (x = bx; x < (bx+12); x++) {
                                                cx += sx;
-                                               v = iterate1(cx, cy);
+                                               v = iterate_double(cx, cy);
                                                *b0++ = palette[v];
                                        }
                                }
                                else
                                for (x = bx; x < (bx+12); x++) {
                                        cx += sx;
-                                       v = iterate(cx, cy);
+                                       v = iterate_float(cx, cy);
                                        *b0++ = palette[v];
                                }
                        }
@@ -428,14 +428,14 @@
                                if (scale < 0.000025 || niter != 256) {
                                        for (x = bx; x < (bx+12); x++) {
                                                cx += sx;
-                                               v = iterate1(cx, cy);
+                                               v = iterate_double(cx, cy);
                                                *b0++ = palette[v];
                                        }
                                }
                                else
                                for (x = bx; x < (bx+12); x++) {
                                        cx += sx;
-                                       v = iterate(cx, cy);
+                                       v = iterate_float(cx, cy);
                                        *b0++ = palette[v];
                                }
                        }

Other related posts: