I would absolutely love it if rustup had OpenBSD support. We're still pretty similar to NetBSD and rust is available on OpenBSD so it shouldn't be too difficult to port.
So - start by building rustup yourself - if that works, and that channel
metadata for rust distributions has everything you need, then this ticket
becomes 'please make rustup binaries available for download'. If it doesn't
build / run properly, we can help you with that, and if the channel
metadata or the rust distributions are missing things we can steer you in
the right direction.
Hmm tried running cargo run --release and got
error: Pre-checks for host and toolchain failed: Provided host 'x86_64-unknown-openbsd' couldn't be converted to partial triple
If you are unsure of suitable values, the 'stable' toolchain is the default.
Valid host triples look something like: x86_64-unknown-openbsd
Ok, so thats the starting point - you'll need to teach the host triple
detection about openbsd. I don't have the source handy just now, but as you
said NetBSD was similar I suggest grepping for NetBSD in the source.
OpenBSD is all tier 3 at this time, which means the required dockers for rustup to build will not be available since they are not produced for tier 3 platforms as I understand it. If I'm wrong then in theory we could add support to our CI to test these platforms at least, even if we're not ready to release yet.
@kinnison I use DragonFly, which is not supported as well. You should still be able to install rustup locally!
Clone rustup source and run (if it fails to build, see my branch):
cargo run -- --default-host x86_64-unknown-freebsd -y
This will download and install the FreeBSD binaries. We don't need them, but rustup can't just install itself without downloading anything. IMHO, would be great if this would be fixed in rustup.
If you would now run $HOME/.cargo/bin/rustc, you would run the FreeBSD binaries... not good. That's why we have to tell rustup about the rust toolchain from ports (I assume this is in /usr/local on OpenBSD):
$HOME/.cargo/bin/rustup toolchain link ports-toolchain /usr/local
$HOME/.cargo/bin/rustup default ports-toolchain
If you now run $HOME/.cargo/bin/rustc, you run the OpenBSD rustc.
If you can, don't install rustc etc. into /usr/local. Install it into some directory which is not in your PATH.
Hope this helps! Good luck!
@kinnison If you want to use rustup for cross-compilation: "rustup target add ..." does not work when the ports-toolchain is activated. The workaround is to switch to the freebsd toolchain, install the target, and switch back.
Using @mneumann's guidance, I was able to get rustup to build and install on OpenBSD. Thanks!
Unfortunately, the binary fails immediately due to rust-lang/rust#60560. I am going to reach out to the OpenBSD port maintainer to try and find a solution here. In the meantime, one can work around by setting a shell alias to rustup's absolute path:
$ alias rustup=$HOME/.cargo/bin/rustup
@kinnison regarding OpenBSD being tier-3, are you aware of any ongoing conversations to change that? I would love to get involved here :)
OpenBSD is a 3-tier platform for several reasons:
Be aware. Rust bootstrap requires SSE2, most Pentium3 (i686) and earlier CPU's do not have SSE2 CPU register, resulting in segmentation faults. Can workaround this by building the rust bootstrap yourself, while most distributions now rely upon rust prebuilts SSE2 bootstraps. I've yet to see any explanation within the past year as to this requirement.
I'm interested in potentially working on this, can someone help me put together a TODO list of what it will take to get OpenBSD support added?
@shaneutt the first steps would be:
next, there are unsupported things like @reynoldsbd mentioned (env::current_exe for example).
Thanks @semarie 馃憤
I'll do some digging in the codebase.
@rustbot label: +O-bsd
I did end up digging into this, but I've had to drop it due to other life priorities. The patches to llvm/libc are the bigger painpoints there in terms of the amount of time that needs to be dedicated to this.
Most helpful comment
I'm interested in potentially working on this, can someone help me put together a TODO list of what it will take to get OpenBSD support added?