dcuddeback / termios-rs

Safe bindings for the termios library.
http://dcuddeback.github.io/termios-rs/termios/
MIT License
75 stars 26 forks source link

Add Haiku support #26

Open dcuddeback opened 4 years ago

dcuddeback commented 4 years ago

This is #24 with some fixes:

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

dcuddeback commented 4 years ago

Here's what I tried:

  1. Downloaded haiku-r1beta1-x86_64-anyboot.zip from Haiku's downloads page.
  2. unzip haiku-r1beta1-x86_64-anyboot.zip
  3. 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
  4. Installed to QEMU HARDDISK.
  5. Enabled SSH access (https://www.haiku-os.org/guides/daily-tasks/netservices):
    1. Open Applications > Terminal.
    2. $ passwd
    3. $ useradd sshd
    4. $ nano /system/settings/ssh/sshd_config
    5. Add PermitRootLogin yes
    6. $ /boot/system/bin/sshd
    7. $ ifconfig to get IP address of VM
  6. Open SSH connection from host computer: $ ssh user@<ip-address-of-vm>
    1. Clone termios-rs: $ git clone https://github.com/dcuddeback/termios-rs -b feature/haiku
    2. 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
    3. Reboot (only way I could find to get rustc and cargo to add to PATH): $ shutdown -r.
  7. Reopen SSH connection from host computer: $ ssh user@<ip-address-of-vm>
    1. Attempt to compile termios-rs:
      $ cd termios-rs
      $ cargo build
          Updating crates.io index
       Downloading crates ...

      At this point, cargo crashes. In virt-viewer, a crash notification pops up. If I click Debug, I can see the following stacktrace:

stacktrace

Can anyone tell me where I went wrong? Does anyone have Rust and Cargo working on Haiku?

CodeforEvolution commented 4 years ago

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! :)

linkmauve commented 4 years ago

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

dcuddeback commented 4 years ago

@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.

hoanga commented 2 years ago

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.

updated-master-haiku-diff.patch.zip