Skip to content

Fix pal_io.c on OpenBSD#124992

Open
sethjackson wants to merge 2 commits intodotnet:mainfrom
sethjackson:fix-pal-io
Open

Fix pal_io.c on OpenBSD#124992
sethjackson wants to merge 2 commits intodotnet:mainfrom
sethjackson:fix-pal-io

Conversation

@sethjackson
Copy link
Contributor

@sethjackson sethjackson commented Feb 27, 2026

Define TARGET_OPENBSD when CLR_CMAKE_TARGET_OPENBSD is defined to copy the other BSDs.

Skip DT_WHT on OpenBSD as it does not exist:
https://man.openbsd.org/dirent

Use: getpeereid on OpenBSD vs getsockopt in SystemNative_GetPeerID.

Also <sys/mount.h> and statfs.f_fstypename require <sys/types.h> on OpenBSD to work:
https://man.openbsd.org/statfs

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Feb 27, 2026
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @karelz, @dotnet/area-system-io-compression
See info in area-owners.md if you want to be subscribed.

@sethjackson
Copy link
Contributor Author

@dotnet-policy-service agree

@am11
Copy link
Member

am11 commented Feb 27, 2026

@sethjackson, could you share the branch which is building on OpenBSD? I'm not sure how you get this far in build without updating build infrastructure in order: eng/common/native/init-os-and-arch.sh, eng/native/configureplatforms.cmake etc. #124776 (comment).

@sethjackson
Copy link
Contributor Author

@am11 yeah this branch:
https://github.com/sethjackson/runtime/tree/feature/openbsd-port-full

Need at least heimdal installed and maybe some other libs:

doas pkg_add heimdal

To build:

export CLR_AR=/usr/local/bin/llvm-ar-19
export CLR_LINK=/usr/local/bin/llvm-link-19
export CLR_NM=/usr/local/bin/llvm-nm-19
export CLR_RANLIB=/usr/local/bin/llvm-ranlib-19
export CLR_STRINGS=/usr/local/bin/llvm-strings-19
export CMAKE_PREFIX_PATH=/usr/local/heimdal/lib
cd src/coreclr
./build-runtime.sh -cmakeargs "-DHeimdalGssApi=ON -DCMAKE_HAVE_HEIMDAL_HEADERS=true"

^^^ Haven't figured out how to get CMake to detect the local LLVM tools or the Heimdal headers properly yet. 😅

OpenBSD will always need to use the HeimdalGssApi option from what I can tell.

@sethjackson
Copy link
Contributor Author

export CLR_AR=/usr/local/bin/llvm-ar-19
export CLR_LINK=/usr/local/bin/llvm-link-19
export CLR_NM=/usr/local/bin/llvm-nm-19
export CLR_RANLIB=/usr/local/bin/llvm-ranlib-19
export CLR_STRINGS=/usr/local/bin/llvm-strings-19
export CMAKE_PREFIX_PATH=/usr/local/heimdal/lib
cd src/coreclr
./build-runtime.sh -cmakeargs "-DHeimdalGssApi=ON -DCMAKE_HAVE_HEIMDAL_HEADERS=true"

FYI I updated the tracking issue with a comment that includes these instructions and current status:
#124911 (comment)

I'll update that comment as things progress.

@sethjackson
Copy link
Contributor Author

@sethjackson, could you share the branch which is building on OpenBSD? I'm not sure how you get this far in build without updating build infrastructure in order: eng/common/native/init-os-and-arch.sh, eng/native/configureplatforms.cmake etc. #124776 (comment).

Also FYI openbsd was already defined here:
https://github.com/dotnet/runtime/blob/main/eng/common/native/init-os-and-arch.sh#L11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-System.IO.Compression community-contribution Indicates that the PR has been added by a community member os-openbsd OpenBSD OS, currently not officially supported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants