Skip to content

Instantly share code, notes, and snippets.

@fasterthanlime
Last active December 24, 2022 22:46
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save fasterthanlime/df7b9a88167de53636fc to your computer and use it in GitHub Desktop.
Save fasterthanlime/df7b9a88167de53636fc to your computer and use it in GitHub Desktop.
Getting rock 0.9.9 to make 32-bit binaries with MSYS2 on Windows

It seems the command-line toolchain of choice changes every fortnight on Windows (except if you're in the MSVC camp, but that's a no-go for ooc at the time of this writing).

The new kid on the block is msys2, which I first had doubts about, but it turns out it's a great way to get a shell, install the packages you need via pacman (!) and get started with ooc on windows.

MSYS2 32-bit

  1. Follow the detailed MSYS2 installation guide, installing the 32-bit version (i686).
  2. pacman -S git make wget tar mingw-w64-i686-gcc
  3. export PATH=/mingw32/bin:$PATH
  4. git clone https://github.com/fasterthanlime/rock.git
  5. cd rock
  6. GC_FLAGS="--build=i686-pc-mingw32 --enable-threads=win32" make rescue
  7. Congrats, you've got a fresh rock!

You might want to add that PATH-setting command to your ~/.profile or your ~/.bashrc so you don't forget about it when running MSYS2 again. The reason it's needed is that the default gcc package while build msys binaries (that depend on their version of cygwin, a weird unix/windows hybrid) instead of mingw32 binaries (only native win32 stuff).

If you get errors while running make, something about mismatched memory addresses between child & parent when loading a DLL, follow the instructions in this ticket (in case link goes down: close MSYS2, run autorebase.bat from the install folder, start again - shazam.)

MSYS2 64-bit

MSYS2 is such that using their 64-bit install, you can produce 32-bit binaries as well. How it works is, they have two binary prefixes, /mingw32 and /mingw64 (in the file system root of the install).

While I wouldn't recommend using their 64-bit distro, you can still make it produce 32-bit binaries with rock. I haven't succeeded in building libgc for 64-bit, because the version bundled with rock has some weird #ifdef in gcconfig.h that makes the compilation fail. The fix is probably trivial, I just don't really have the time to look into it now.

The procedure is the same as above, except you'd install the 64-bit (x86_64) version, and add ARCH=32 before make rescue.

The ARCH environment variable is there to override rock's arch detection in its Makefile(s). Once c_rock.exe has been compiled as a 32-bit binary, it'll produce 32-bit binaries by default, and so will the rock.exe it generates.

@Ismoh
Copy link

Ismoh commented Dec 24, 2022

Thanks for sharing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment