PW32: Bootstrapping

In this document, procedure for bootstrapping the PW32 is described. Generally it's only of interest to those who want to walk all path from the beginning (for example, me).

To bootstrap PW32, you'll need GNU C compiler, capable of producing Win32 PE code (including DLLs). I gradually used Mumit Khan's mingw32 egcs/gcc builds for that, with gcc 2.95.2/binutils 2.9.4 release in the meantime. Indeed, build procedure currently relies on some mingw32 features (such as argument globbing). What is also required is of course GNU make. Mingw32 prebuilt is available at Mumit's site. I however sometimes forced to use Cygwin's make, when mingw32 behaves badly.

Step-by-step bootstrapping procedure

  1. Build PW32 library itself
  2. Build bootstrap versions of some GNU (and non-GNU) utilities. This accomplished by applying bootstrap patches (available in binary distributions of bootstrap utilities and all together in separate archive) to GNU distributions. Versions used as bootstrap are outdated, they were taken from Linux Slackware 3.2 distribution (just because I already had them on my hdd, and in case I would distribute PW32 off my site, I just could link to sources, instead of making GNU dump from my ftp).
  3. At this step, all required to run common configure scripts is up, except for make (but we have mingw32's) and cmp (lives in diffutils), but it's only used to facilate some caching between configure runs, and its absence can be ignored for now.
  4. So, time to setup PW32 environment.
    1. Choose $(prefix). For production system, that would be /usr. Use something else for now. As $(core) further referred top dir of PW32 core library (something like /projects/pw32).
    2. Copy all the binaries (i.e. exe files) of stuff built earlier to $(prefix)/bin.
    3. Copy pw32.dll to $(prefix)/bin.
    4. Copy $(core)/include/ from to $(prefix).
    5. Then need to setup mingw32-hosted gcc as compiler for pw32:
      1. Copy ar.exe, ranlib.exe, gcc.exe from Mingw32 to $(prefix)/bin. Rename gcc.exe as gcc.w32. Copy $(core)/utils/exec-w32.exe as $(prefix)/bin/gcc.exe . Make sure that running that gcc.exe gives "No input files" message. Now run it from within sh and make sure you don't get 'Hangup' trailer.
      2. Create $(prefix)/i386-mingw32msvc/lib/ . Put there libkernel32.a, libadvapi32.a, libuser32.a, libwinmm.a of mingw32.
      3. Create $(prefix)/lib/gcc-lib/i386-mingw32msvc/2.95.2/ , and copy cc1.exe, cpp.exe, libgcc.a, all from the corresponding mingw32 dir there. Put mingw32's as.exe and ld.exe there. specs file, hacked for PW32 (available in bootstrap package) also goes there.
      4. Put $(core)/lib/{crt0.a, libcrt0.a, libc.a} to $(prefix)/lib/.
  5. Now test it (from native shell): gcc hello.c -o hello (I'm sure you know what hello.c contains). Make sure that hello.exe references only pw32.dll and system dlls.
  6. Now do the same from sh.
  7. Congratulations!

Paul Sokolovsky | use this form to submit bug