Repository navigation
Closed
Labels
arch-x86_6464-bit x86enhancementSolving this issue will likely involve adding new logic or components to the codebase.os-openbsdOpenBSDtier systemIssues that track the support tier for a platform.
Description
Tier 1
- All non-experimental language features are known to work correctly.
- The compiler can generate machine code for this target without relying on LLVM.
- Given the linker issues on other BSDs, it seems likely that there will be some issues here too.
- The CI machines automatically run the module tests for this target on every push.
Tier 2
- The standard library's cross-platform abstractions have implementations for this target.
- This target has debug info capabilities and therefore produces stack traces on failed assertions and crashes.
- libc is available for this target even when cross-compiling.
- The CI machines automatically build the module tests for this target on every push.
Tier 3
- The compiler can generate machine code for this target by relying on an external backend such as LLVM.
- The linker can produce object files, libraries, and executables for this target.
Tier 4
- The compiler can generate assembly or C source code for this target.
Reacted by John, daurnimator, Theo Paris, LowByteFox, Eliphaz Bouye, Max Milton, Coleman McFarland, Russ and vazub
Reacted by Mario Campos, Dave Gauer, LowByteFox, Eduardo Cueto Mendoza, rwsalie, Eliphaz Bouye and Max Milton
Metadata
Metadata
Assignees
Labels
arch-x86_6464-bit x86enhancementSolving this issue will likely involve adding new logic or components to the codebase.os-openbsdOpenBSDtier systemIssues that track the support tier for a platform.
Activity
andrewrk commentedon Apr 29, 2019
Here is some partially finished code that one can use for inspiration: #1921
andrewrk commentedon May 13, 2019
SourceHut has OpenBSD images now: https://man.sr.ht/builds.sr.ht/compatibility.md#openbsd
voutilad commentedon Jun 25, 2019
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.
justjosias commentedon Jul 22, 2020
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.
18 remaining items
vazub commentedon Jan 3, 2023
Looks like the fixes for the blockers have been merged @semarie
andrewrk commentedon Jan 3, 2023
In case you missed it, #6485 is resolved now :-)
kuon commentedon Feb 8, 2023
I sadly do not have a lot of time to contribute code to this issue, but I'd like to let you know that we use OpenBSD quite a bit for servers and routers, and I'll be happy to help testing.
LowByteFox commentedon Aug 21, 2023
I am currently running OpenBSD 7.3-Current and I've tried to compile zig 0.11.0. It's not possible to compile
getFdPath. Before I tried to compile zig @oven-sh uses but the stage 3 compiler was segfault-ing.What got me confusing is that on release notes of zig 0.11.0 under Tier 2, OpenBSD has ✅ but should have 📖 because it doesn't compile. I don't know if it got there by accident or you just cross-compiled it without being on OpenBSD, I don't know how you got it.
If someone wants to compile it themselves, I provide llvm16 pre-built binary for amd64 OpenBSD 7.3-current in releases. I compiled it as zig's wiki tells me. + Don't forget to install it into /usr/local/llvm16
Before compiling zig, edit
/etc/login.confand forstaffincreasedatasize-curto6000Mjust so clang doesn't fail with Out of Memory error. Don't forget to log out and log in, the confirm it withuname -aunderdataMy configure command was
cmake .. -DZIG_STATIC_LLVM=ON -DZIG_STATIC_ZSTD=ON -DZIG_STATIC_ZLIB=ON -DZIG_USE_LLVM_CONFIG=OFF -DCMAKE_PREFIX_PATH="/usr/local/llvm16;/usr/local"Then run
make edit_cacheand enter advanced modeunder
CMAKE_EXE_LINKER_FLAGSadd-lexecinfoso when zig 2 will build it doesn't fail with missingbacktraceNow you are good to go, the compilation should fail with

If anything, I can learn zig and try to fix std myself
Update:


I made very nasty fix
Just so i would test how far it would get and it got to
LowByteFox commentedon Sep 4, 2023
I am back with more info, okay so I tried to cross compile simple hello world application. But it crashes with
SIGSEGVI ssh mounted a computer running OpenBSD (You don't need to have a computer with OpenBSD. Just make QEMU VM, forward ssh port and mount / using sshfs) and modified output of
zig libcjust so it matches ssh root mount. Then I simply executedzig build --libc openbsdlibc.txt -Dtarget=x86_64-openbsd -Doptimize=ReleaseSmallReason why
ReleaseSmallis because it doesn't require the missinggetcontextsymbol and compiles. Then I just copied the output executable to the computer and executed it. It just segfaulted.It could either be because of the "nasty fix" or who knows what.
I'll share my ktrace output here
I could theoretically fork their libc, add own implementation for storing FDs and call it from zig and try that out, if it would work without breaking anything on the system itself, I would make the patch available on custom repo so users could patch libc and recompile it themselves. I wouldn't make PR back to OpenBSD because this would be home made fix.
But then again, issue can be with something else
rwsalie commentedon Dec 29, 2023
Found a little issue when
std:Build.LibExeObjStep.linkSystemLibraryis used on OpenBSD with zig (master branch)idk for which reason that doesn't work well because every function used on Zig come from of a C Static/Dynamic library ( example SDL2/GL/X11...) are `undefined symbols
Actually works if i used
std:Build.LibExeObjStep.addObjectFilewhere i put the paths of the object (dynamic or not)PR : #18475
[-]Tier 3 OpenBSD Support for x86_64[/-][+]Tier 1 support for `x86_64-openbsd`[/+][-]Tier 1 support for `x86_64-openbsd`[/-][+]Tier System: `x86_64-openbsd`[/+]