hn.today

I ported the new Hare compiler to OpenBSD

briancallahan.net7 points0 comments
Screenshot of I ported the new Hare compiler to OpenBSD

This describes porting the Hare compiler to OpenBSD by cloning the compiler repository, copying rt/+freebsd into a new rt/+openbsd directory, and making platform-specific edits to files like rt/+openbsd/errno.ha, rt/+openbsd/syscallno.ha, and rt/configure. The build used QBE as the backend. Initial compile problems included a mktemp usage that did not match mktemp(3), which was resolved by renaming occurrences (emktemp), and multiple printf format-string warnings that failed the build because -Werror was enabled; clang’s diagnostics guided the fixes for format specifiers that differ between OpenBSD and other Unixes.

All tests initially failed until platform-specific ELF and linking issues were addressed: OpenBSD requires a .note.openbsd.ident section in binaries, so the assembly for _start was modified and the linker script was taught to preserve that section. Tests still failed until GDB (starti) revealed that the program was being built PIE, so adding -nopie stabilized the first-instruction address. After those fixes the test suite passed. A patch with these changes was submitted to the mailing list (some format-string changes may need upstream adjustment). Next steps include porting the runtime/standard library and adding riscv64 and arm64 support.

Read on briancallahan.net0 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Programming

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.