Zig: Tier 3 OpenBSD Support for x86_64

Created on 27 Feb 2019  路  11Comments  路  Source: ziglang/zig

Here's the issue to track OpenBSD support. The current goal is Tier 3, since Zig can't even build on OpenBSD yet. Once Zig reaches Tier 3 this issue will get renamed to Tier 2, and so on. @Aversiste has started the effort in #1921.

arch-x86_64 contributor friendly enhancement os-openbsd stage1 standard library

Most helpful comment

FYI I started a port of zig for OpenBSD : https://github.com/semarie/zig/tree/openbsd
it is based on LLVM version from ports (full llvm-10), and I am able to build a stage2 zig compiler.

some work is still need:

  • linkage (to build zig compiler I had to explicitly pass c++ libraries)
  • proper selfExePath implementation (OpenBSD doesn't provide such facility at all)
  • linkage errors will running test-behavior
  • etc...

All 11 comments

Here is some partially finished code that one can use for inspiration: #1921

FWIW, OpenBSD recently imported LLVM 8.0.0 into base: https://marc.info/?l=openbsd-cvs&m=156132754603489&w=2

It's available now in the latest -current snapshots for anyone interested in this issue.

Edit: SourceHut seems to have the latest release, but doesn't support -current snapshots, so anyone working on OpenBSD compatibility can't readily solve the CI needs until the next OpenBSD release later this year.

I am willing to help out with OpenBSD support. I have looked through the previous PRs (particularly #5324), and would like to tackle it, getting Zig to even compile on OpenBSD and getting those changes merged into master.

Happy to hear that @justjosias . My suggestion is to make smaller PRs that can be merged independently, making incremental progress. I think you will meet with swift success if you do this.

@justjosias :wave: also keen to see Zig on OpenBSD; happy to work with you on testing/iterating on your changes.

OpenBSD-current just added llvm 10 to their (binary) packages. Maybe this could rejuvenile this effort?
You can do: pkg_add llvm and you'll get llvm 10 libraries.
However, when trying to build zig, it will then complain that llvm is missing the target AArch64 and that zig requires all default targets.

@gaultier You have to compile LLVM from source, which isn't so hard (the boostrap works very well, just need to add some linker and header include paths). At that point you have to patch and modify Zig to get it to build, which currently is the goal of this issue.

@justjosias Right, got it, I did just this and I realized OpenBSD is not in the list of supported OSes in the zig source code. Hopefully someone can continue the porting effort that was started in the linked PR 馃憤

FYI I started a port of zig for OpenBSD : https://github.com/semarie/zig/tree/openbsd
it is based on LLVM version from ports (full llvm-10), and I am able to build a stage2 zig compiler.

some work is still need:

  • linkage (to build zig compiler I had to explicitly pass c++ libraries)
  • proper selfExePath implementation (OpenBSD doesn't provide such facility at all)
  • linkage errors will running test-behavior
  • etc...

Awesome news, thank you @semarie!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

andersfr picture andersfr  路  3Comments

zimmi picture zimmi  路  3Comments

dobkeratops picture dobkeratops  路  3Comments

fengb picture fengb  路  3Comments

andrewrk picture andrewrk  路  3Comments