Hare upstream expects to use ELF. You can work around this but YMMV.
The standard library expects a reasonably Unix-like environment. However, you can build your own standard library relatively easily and vendor or fork various portable bits of the stdlib. This can go a long ways, Mercury does this and provides a comfortable Hare environment with relatively little effort.
Configure Hare for your build host normally:
https://harelang.org/installation/
Then start porting the standard library. Start by porting rt, the runtime. The minimal port requires your target support code at rt/+target. Add the following:
This should be sufficient to build simple Hare programs that use syscall wrappers directly, such as this one for Linux:
use rt;
export fn main() void = {
const bytes = tobytes("Hello world!\n");
rt::write(0, &bytes[0], len(bytes))!;
};
fn tobytes(s: str) []u8 = *(&s: *[]u8);
You can cross-compile this for your target like so:
$ hare build -o example -X^ -T+target [-t $arch] main.ha
Then port other stdlib modules as you see fit. Many modules, such as bytes or ascii, are portable. Others, such as crypto and time, are mostly portable. Some are not portable and will need to be ported to your target, including notably:
Good luck!
You need:
The steps are: