Local MXR, or, "How I hate and love cygwin"

I've spent the past few days trying to get my Frankenstein-MXR working locally.  I'll blog about the project in more detail when I have more time, and update the wiki page.  But I had to share a small victory.

My goal has been to get a minimal--I mean small with a capital TINY--web+perl+mxr working in Windows.  I actually got it all working last week with a crazy uninstallable mishmash of cygwin, msys, and win32 software.

So once I had proof of concept working, I decided to get it to fit into a neat little package and all run from cygwin.  I'm using lighttpd stripped of excess stuff I don't need, glimpse built from source for cygwin (make sure you downgrade your make to 3.81 before you try to build), and cygwin perl with DB_File installed from CPAN.  I've slowly been carving out bits of things I don't need to get this all to run, and I've got a pretty good set of .pm files now, and have managed to dump a ton of things I won't use for this.

Anyway, after rebuilding pretty much everything so it would work with a single version of cygwin, I tried to reproduce my earlier result.  The web server died on any attempt to access a .cgi or perl file, however not with enough info to help me much.

Chris suggested I try using strace to watch file access, and I thought cygwin wouldn't have it, but lo and behold!  It's there by default!  So I dumped a ton of strace logs and got into a very comfortable chair to try and understand what was going on.  After much squinting and swearing, I see:

56 8697409 [main] perl 796 perhapssuffix: buf c:\moz\mxr\lib\auto\DBFile\DB
File.dll, suffix found '.dll'
53 8697462 [main] perl 796 find
exec: c:\moz\mxr\lib\auto\DBFile\DBFile.dll
= findexec (lib/auto/DBFile/DBFile.dll)
1954 8699416 [main] perl 796 seterrno
fromwinerror: /ext/build/netrel/src/cyg
win-1.5.25-7/winsup/cygwin/dlfcn.cc:103 windows error 126
Nice, now I can see that the DBFile.dll is not loading properly (error 126 means it found the DLL but not a dependent lib).  So I grabbed Dependency Walker and notice that cygdb2.dll is not found for DBFile.dll.  Clickity-click, Barba-trick and I have the file in my path!

MXR never looked so good, especially when I spent the day reading Perl execution underneath via system calls.  I didn't like Perl before, and I don't like it any better now.  But I'm very happy to see MXR on my local box, and ready to be packaged.  I'll leave that fun for tomorrow.