How to build ChezScheme on OpenBSD
July 28, 2022 // Last edited on July 29, 2022
Hi! It's me again.
Recently, I've been messing around with Scheme a lot, and I really like it so far. It's a relatively small but elegant, functional and pure Lisp dialect (you know, Lots of Irritating Superfluous Parentheses) that aims to only provide the tools to make complex functions, but not the latter. I'll probably write some articles on Scheme, but for now, see shido.info for a quick tour or TSPL4 for a complete book.
Since Scheme is a specification, there's a lot of different implementations. Among them, I tested several, such as Chicken, Guile, or Chez Scheme. The latter, being the most powerful, stable, and complete, naturally became my favorite, and the one I use in most cases for my projects (on Linux).
However, there was a problem. Chez didn't « officially » support OpenBSD.
And since my laptop has been running it, I couldn't use my favourite Scheme when I wasn't home.
So, I looked for solutions on how to build Chez on OpenBSD.
Here's how I did it.
|It should probably work on other BSDs as well. Adjust according to your system.|
In order to run properly, ChezScheme needs some files called boot files. They're responsible for the interpretation and compilation of your programs, and are specific to each OS. In order to build them for OpenBSD, you'll need a working Linux-based PC being on the same platform (x86, x86_64..).
If you don't have any Linux computer at hand to build the boot files, don't worry!
There's already a mirror of ChezScheme that includes OpenBSD boot files on our Git. You can already skip to The actual build.
Once you've booted your favorite Linux distro, you first need to clone the repo. Assuming you're in your home folder, do:
tux@linux ~ $ git clone https://github.com/cisco/ChezScheme --depth 1 tux@linux ~ $ cd ChezScheme
As soon as you're into the right folder, you just have to configure the Makefile and build it using
tux@linux ~/ChezScheme $ ./configure --threads tux@linux ~/ChezScheme $ make -j4
Finally, when ChezScheme has finished building itself, you can cross-compile the boot files.
To do this, simply create the right folder and build the boot files using
tux@linux ~/ChezScheme $ mkdir boot/ta6ob/ tux@linux ~/ChezScheme $ cd ta6le tux@linux ~/C/ta6le $ make -f Mf-boot ta6ob.boot -j4 tux@linux ~/C/ta6le $ cd ../boot/ tux@linux ~/C/boot $ ls ... ta6le ta6ob ...
If you built ChezScheme without thread support, remove every
The hard part is done. You can now put
boot/ta6ob/ on a USB stick (or upload it somewhere) and go to the next part.
Before building ChezScheme, you need to know a few things.
On OpenBSD (and on some other OSes), there's a security feature called W^X. It prevents a program from writing and executing data in memory at the same time, thus stopping some buffer overflow attacks, among other things. The thing is: ChezScheme needs to do that in order to work. Fortunately, on OpenBSD,
/usr/local is mounted with the option
wxallowed, which allows exactly that. Therefore, we will use this folder to build Chez.
If you modified your fstab or if your OpenBSD installation differs from the « official » one, please check
Also, OpenBSD only ships BSDmake, but Chez needs GNUmake (since its Makefile is using gmake-specific syntax). You'll need to install it by running:
puffy@openbsd ~ $ doas pkg_add gmake
Everything's ready. We can finally start building Chez.
First, we'll clone the repository in
/usr/local/share as root, and we'll copy our boot files into Chez's folder (assuming you built them with the
--threads flag and they're in
puffy@openbsd ~ $ doas -s doas (puffy@openbsd) password: root@openbsd /h/puffy # cd /usr/local/share/ root@openbsd /u/l/share # git clone https://github.com/cisco/ChezScheme --depth 1 root@openbsd /u/l/share # cd ChezScheme/ root@openbsd /u/l/s/ChezScheme # cp -r /root/ta6ob/ boot/
Or, if you want to use chez-openbsd, our mirror of ChezScheme that includes OpenBSD boot files, you just have to clone the repo (or download the zipfile from the releases).
root@openbsd /u/l/share # git clone https://basedwa.re/tmtt/chez-openbsd --depth 1 ChezScheme root@openbsd /u/l/share # cd ChezScheme
Now that you downloaded the repo and that the boot files are here, we can configure the Makefile and build everything.
root@openbsd /u/l/s/ChezScheme # ./configure --threads root@openbsd /u/l/s/ChezScheme # gmake -j4
For some reasons,
This time, adjust
Once the build finished, we can, after all these adventures, install it on our system.
root@openbsd /u/l/s/ChezScheme # gmake install
You did it!
Hope it was helpful.
Go ahead, fool around with your brand new Scheme implementation on your OpenBSD machine. Have fun!
I hope one day someone will make a port out of this. Maybe I'll have to do it myself..?
I guess that's all.
See you soon, and, as always, take care of yourselves.