Skip to content

Add speculative support for OpenBSD. #890

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 6, 2025
Merged

Add speculative support for OpenBSD. #890

merged 3 commits into from
Jan 6, 2025

Conversation

grynspan
Copy link
Contributor

@grynspan grynspan commented Jan 4, 2025

OpenBSD has partial support in the Swift toolchain. This PR adds speculative support for it based on the assumption that what works with FreeBSD will generally also work with OpenBSD. The big differences:

  1. We need to include <util.h> instead of <libutil.h>,
  2. /usr/bin/tar does not support writing PKZIP files (so we look for the optional /usr/bin/zip instead), and
  3. OpenBSD has no way to determine the path to the current executable, so we naïvely assume argv[0] is correct.

These changes are speculative and have not been tested.

Partially resolves #888.

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

OpenBSD has partial support in the Swift toolchain. This PR adds speculative
support for it based on the assumption that what works with FreeBSD will
generally also work with OpenBSD. The big differences:

1. We need to include `<util.h>` instead of `<libutil.h>`,
2. `/usr/bin/tar` does not support writing PKZIP files (so we look for the
   optional `/usr/bin/zip` instead), and
3. OpenBSD has no way to determine the path to the current executable, so we
   naïvely assume `argv[0]` is correct.

Partially resolves #888.
@grynspan grynspan added enhancement New feature or request help wanted Extra attention is needed openbsd 🐡 OpenBSD support labels Jan 4, 2025
@grynspan grynspan added this to the Swift 6.x milestone Jan 4, 2025
@grynspan grynspan self-assigned this Jan 4, 2025
@grynspan
Copy link
Contributor Author

grynspan commented Jan 4, 2025

@swift-ci test

@grynspan
Copy link
Contributor Author

grynspan commented Jan 5, 2025

@swift-ci test

@michael-yuji
Copy link
Member

michael-yuji commented Jan 5, 2025

For (2) I know at least for FreeBSD there’s no /usr/bin/zip, I’m not sure about OpenBSD

For (3) I think we get get it via sysctl
cc @3405691582 who have been working on OpenBSD support

Edit(3): found it https://github.com/swiftlang/swift-corelibs-foundation/blob/25d044f2c4ceb635d9f714f588673fd7a29790c1/Sources/CoreFoundation/CFPlatform.c#L224

@grynspan
Copy link
Contributor Author

grynspan commented Jan 5, 2025

Yeah that's just argv[0] again, unfortunately!

@grynspan
Copy link
Contributor Author

grynspan commented Jan 5, 2025

For (2) I know at least for FreeBSD there’s no /usr/bin/zip, I’m not sure about OpenBSD

Fortunately, for FreeBSD we can and do just use libarchive via /usr/bin/tar. On OpenBSD, from what I can gather /usr/bin/zip exists as an optional package, but is not installed by default.

@michael-yuji
Copy link
Member

re: zip, I think for installed packages, it should be in /usr/local prefix on OpenBSD?

@grynspan
Copy link
Contributor Author

grynspan commented Jan 5, 2025

If I could get a VM set up, I'd check!

@3405691582
Copy link
Member

Zip is in an optional package; these binaries go in /usr/local.

$ doas pkg_add zip
quirks-7.79 signed on 2025-01-02T10:42:16Z
zip-3.0p3: ok
$ which zip
/usr/local/bin/zip

@3405691582
Copy link
Member

Other than the zip path, the changes look reasonable; I haven't been able to locally test fully due to the fact that bootstrapping a fully-featured toolchain is incomplete (see swiftlang/swift#78437), but I can revisit once I have a proper toolchain.

@grynspan
Copy link
Contributor Author

grynspan commented Jan 6, 2025

If you want to give the PR a ✅, we can merge it (with the path fix, of course.) Or if you'd prefer to wait until you have an otherwise-functional toolchain, I can close this PR for now.

@grynspan
Copy link
Contributor Author

grynspan commented Jan 6, 2025

@swift-ci test

@3405691582
Copy link
Member

I'm happy if you merge sooner rather than later, and we take care of any missing pieces then.

@grynspan
Copy link
Contributor Author

grynspan commented Jan 6, 2025

Sounds good to me. Will chat with my colleagues today about it, should be able to merge before EOD.

@grynspan grynspan merged commit 33e4d1b into main Jan 6, 2025
3 checks passed
@grynspan grynspan deleted the jgrynspan/openbsd branch January 6, 2025 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed openbsd 🐡 OpenBSD support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for OpenBSD
5 participants