💾 Archived View for space.matthewphillips.info › posts › installing-hare-freebsd captured on 2024-08-18 at 17:32:27. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2024-02-05)

-=-=-=-=-=-=-

Installing Hare on FreeBSD

I recently heard about a new systems programming language, Hare, so I decided to give it a spin. I haven't used it enough to give a full review, or to really even speak to strengths, I might do that later.

Hare

Instead I wanted to share how I got it set up on FreeBSD. Hare is not available on OSX and I happened to have set up a FreeBSD box recently so I decided to use that for testing. The installation instructions are straight forward, but there were a couple of small extra steps on FreeBSD. So consider this a full tutorial.

Installation documentation

There are 4 total things you need to install to get Hare working on FreeBSD, 2 pre-requisites and 2 Hare packages. It's possible that you already have the pre-requisites setup, in which case you can skip the step, but they are uncommon enough that I'm including them here.

I did the installation in a fresh jail for isolation, but of course you can install where ever you like, the steps are the same.

Initial setup

First you'll need git:

pkg install git

Since we're installing from source, we need somewhere to put the source, so I created /usr/local/src

mkdir -p /usr/local/src
cd /usr/local/src

Now we can start building packages.

Pre-requisites

QBE

QBE is a compiler backend used by Hare.

QBE

First clone the repository:

git clone git://c9x.me/qbe.git
cd qbe

Then build and install:

make
make install
cd ..

scdoc

scdoc is a man page generator, first clone:

git clone https://git.sr.ht/~sircmpwn/scdoc
cd scdoc

scdoc uses syntax in its Makefile not supported by BSD make so you'll need `gmake`:

pkg install gmake

Then use gmake to build and install:

gmake
gmake install
cd ..

Hare

Now with the prereqs you can install Hare itself, first the bootstrap compiler:

git clone https://git.sr.ht/~sircmpwn/harec
cd harec

Copy the FreeBSD config from the configs folder:

cp configs/freebsd.mk config.mk

Then build and install:

make
make install
cd ..

Last up is the main package:

git clone https://git.sr.ht/~sircmpwn/hare
cd hare

Like last time, copy over the FreeBSD build config:

cp configs/freebsd.mk config.mk

Before building, Hare depends on `as`, an assembler, which you can get from binutils:

pkg install binutils

And with that you should be able to build and install:

make
make install
cd ..

Hello world

Hare's docs has a really nice tutorial I'd recommend checking out:

An introduction to the Hare programming language

First, let's do a simple Hello world.

echo 'use fmt;

export fn main() void = {
	fmt::println("Hello world!")!;
};' > main.ha

Which you can now run with the `hare run` command:

hare run main.ha

It will take a second the first time, but you should then see the print out. To build to an executable use the build command instead:

hare build -o helloworld main.ha
./helloworld

And that's it, I hope this is helpful for FreeBSD users out there.