termios-rs
termios-rs copied to clipboard
Add Haiku support
This is #24 with some fixes:
- Redefined
tcflag_t
asu32
. It's typedef'd as__haiku_uint32
intermios.h
. I thinku32
matches the intended use of that type. - I provided an implementation for
cfsetspeed()
, because that seems to be missing in Haiku. Without it, anything that attempts to usecfsetspeed()
will fail to link.
I need help testing this, though. If anyone's interested in landing support for Haiku, please help me verify its correctness. What I'm really looking for is some instructions on how to setup a working Rust compiler on Haiku. pkgman install rust_bin
doesn't do it for me. cargo
crashes with a segfault inside OpenSSL when fetching dependencies.
I wrote shiny new contributing guidelines earlier today with details on what kind of testing guidance I'm looking for as well as how others might help test a patch like this.
/cc @sikmir
Here's what I tried:
- Downloaded
haiku-r1beta1-x86_64-anyboot.zip
from Haiku's downloads page. -
unzip haiku-r1beta1-x86_64-anyboot.zip
- Install:
virt-install --virt-type kvm --name haiku --cpu host,mode=host-passthrough --vcpus 2 --memory 16384 --cdrom ~/Downloads/haiku-release-anyboot.iso --disk size=40,sparse=yes,pool=default --network network=default
- Installed to
QEMU HARDDISK
. - Enabled SSH access (https://www.haiku-os.org/guides/daily-tasks/netservices):
- Open
Applications
>Terminal
. -
$ passwd
-
$ useradd sshd
-
$ nano /system/settings/ssh/sshd_config
- Add
PermitRootLogin yes
-
$ /boot/system/bin/sshd
-
$ ifconfig
to get IP address of VM
- Open
- Open SSH connection from host computer:
$ ssh user@<ip-address-of-vm>
- Clone
termios-rs
:$ git clone https://github.com/dcuddeback/termios-rs -b feature/haiku
- Install Rust:
$ pkgman install rust_bin
. Here's what was installed:The following changes will be made: in system: upgrade package ca_root_certificates-2018_06_20-1 to 2020_01_01-1 from repository HaikuPorts install package openssl1.0-1.0.2u-2 from repository HaikuPorts upgrade package curl-7.61.1-2 to 7.69.1-1 from repository HaikuPorts upgrade package haiku-r1~beta1_hrev52295_96-1 to r1~beta1_hrev52295_133-1 from repository Haiku install package openssl1.0_man-1.0.2u-2 from repository HaikuPorts upgrade package nghttp2-1.33.0-1 to 1.40.0-1 from repository HaikuPorts install package nghttp2_devel-1.40.0-1 from repository HaikuPorts upgrade package openssl-1.0.2p-1 to 1.1.1e-1 from repository HaikuPorts upgrade package openssl_devel-1.0.2p-1 to 1.1.1e-1 from repository HaikuPorts install package rust_bin-1.42.0-1 from repository HaikuPorts upgrade package curl_devel-7.61.1-2 to 7.69.1-1 from repository HaikuPorts upgrade package haiku_devel-r1~beta1_hrev52295_96-1 to r1~beta1_hrev52295_133-1 from repository Haiku
- Reboot (only way I could find to get
rustc
andcargo
to add toPATH
):$ shutdown -r
.
- Clone
- Reopen SSH connection from host computer:
$ ssh user@<ip-address-of-vm>
- Attempt to compile
termios-rs
:$ cd termios-rs $ cargo build Updating crates.io index Downloading crates ...
- Attempt to compile
At this point, cargo
crashes. In virt-viewer
, a crash notification pops up. If I click Debug
, I can see the following stacktrace:
Can anyone tell me where I went wrong? Does anyone have Rust and Cargo working on Haiku?
Hello @dcuddeback! What you were encountering was actually a bug in the Haiku networking layer that should be fixed in the upcoming Haiku release: https://review.haiku-os.org/c/haiku/+/2825
Keep your eyes out for the new Haiku R1/Beta 2 release in the upcoming month! :)
Hi, thanks for this PR!
There is just a single issue preventing termios from building on Haiku now, it is this #[link(name = "c")]
here, on Haiku there is no need to link against this library (and it will prevent the linker from producing a working shared object): https://github.com/dcuddeback/termios-rs/pull/26/files#diff-49a4b4d69f811d5619c481802227b86eR5
@linkmauve Thanks. I take it that means Haiku has worked out their bug in their networking layer so this is ready to test again. I think it should be pretty easy to work around the #[link(name="c")]
issue. As I mentioned in the other PR, I'm dealing with a family emergency these days, so it may be a while until I get to it.
hello,
on a more recent versions of haiku (r1beta3+) this branch (still) passes tests on haiku. however, it seems that it is out of sync with what is in master.
after trying to update to the latest on mainline and re-synced the patches to apply to mainline, looks like tests are able to work on haiku. below is a sample run:
> uname -a
Haiku shredder 1 hrev56098 May 13 2022 08:04:13 x86_64 x86_64 Haiku
> cargo clean && cargo test
Compiling libc v0.2.77
Compiling termios v0.3.3 (/boot/home/src/git/rust-libs/termios-rs)
warning: use of deprecated function `std::mem::uninitialized`: use `mem::MaybeUninit` instead
--> src/lib.rs:200:41
|
200 | let mut termios = unsafe { mem::uninitialized() };
| ^^^^^^^^^^^^^
|
= note: `#[warn(deprecated)]` on by default
warning: `termios` (lib) generated 1 warning
warning: `termios` (lib test) generated 1 warning (1 duplicate)
Finished test [unoptimized + debuginfo] target(s) in 1.77s
Running unittests (target/debug/deps/termios-a402e2cad25f44e4)
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Doc-tests termios
running 10 tests
test src/lib.rs - (line 19) - compile ... ok
test src/lib.rs - (line 28) - compile ... ok
test src/lib.rs - (line 44) - compile ... ok
test src/lib.rs - (line 78) - compile ... ok
test src/lib.rs - Termios (line 167) - compile ... ok
test src/lib.rs - cfgetispeed (line 236) ... ok
test src/lib.rs - cfgetospeed (line 251) ... ok
test src/lib.rs - cfsetispeed (line 293) ... ok
test src/lib.rs - cfsetospeed (line 336) ... ok
test src/lib.rs - cfsetspeed (line 376) ... ok
test result: ok. 10 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.74s
attached is a suggested patch that can be applied onto the mainline branch. if an updated pr with a resynced branch would be preferred, let me know and i can try to set that up.