There is a port hare-lang, but as Drew DeVault answered my question “Just want to know - is this port official hare distribution and is it updated?”:
“We do not maintain downstream packages. It’s official if that’s an official source for your distro.”
So I found a good manual on how to do this from repos:
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.
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
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.