Skip to content
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

portable_pty doesn't compile on windows #1389

Closed
CyriacBr opened this issue Dec 11, 2021 · 8 comments
Closed

portable_pty doesn't compile on windows #1389

CyriacBr opened this issue Dec 11, 2021 · 8 comments
Labels
bug Something isn't working

Comments

@CyriacBr
Copy link

Build Environment:

Tried those targets: x86_64-pc-windows-msvc, i686-pc-windows-msvc and aarch64-pc-windows-msvc.

I have a very small rust project using portable_pty but when building for one of the above targets, it fails. I'm unsure if this is a legit bug or if there's something I did wrong - I'm quite new to Rust.

The build output

   Compiling portable-pty v0.6.0
error[E0308]: mismatched types
  --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/portable-pty-0.6.0/src/win/procthreadattr.rs:54:17
   |
54 |                 con,
   |                 ^^^ expected enum `winapi::ctypes::c_void`, found enum `std::ffi::c_void`
   |
   = note: expected raw pointer `*mut winapi::ctypes::c_void`
              found raw pointer `*mut std::ffi::c_void`

error[E0308]: mismatched types
  --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/portable-pty-0.6.0/src/win/psuedocon.rs:79:30
   |
79 |         let mut con: HPCON = INVALID_HANDLE_VALUE;
   |                      -----   ^^^^^^^^^^^^^^^^^^^^ expected enum `std::ffi::c_void`, found enum `winapi::ctypes::c_void`
   |                      |
   |                      expected due to this
   |
   = note: expected raw pointer `*mut std::ffi::c_void`
              found raw pointer `*mut winapi::ctypes::c_void`

error[E0308]: mismatched types
   --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/portable-pty-0.6.0/src/win/psuedocon.rs:154:66
    |
154 |         let _main_thread = unsafe { OwnedHandle::from_raw_handle(pi.hThread) };
    |                                                                  ^^^^^^^^^^ expected enum `std::ffi::c_void`, found enum `winapi::ctypes::c_void`
    |
    = note: expected raw pointer `*mut std::ffi::c_void`
               found raw pointer `*mut winapi::ctypes::c_void`

error[E0308]: mismatched types
   --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/portable-pty-0.6.0/src/win/psuedocon.rs:155:58
    |
155 |         let proc = unsafe { OwnedHandle::from_raw_handle(pi.hProcess) };
    |                                                          ^^^^^^^^^^^ expected enum `std::ffi::c_void`, found enum `winapi::ctypes::c_void`
    |
    = note: expected raw pointer `*mut std::ffi::c_void`
               found raw pointer `*mut winapi::ctypes::c_void`

error[E0308]: mismatched types
  --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/portable-pty-0.6.0/src/win/mod.rs:29:47
   |
29 |         let res = unsafe { GetExitCodeProcess(proc.as_raw_handle(), &mut status) };
   |                                               ^^^^^^^^^^^^^^^^^^^^ expected enum `winapi::ctypes::c_void`, found enum `std::ffi::c_void`
   |
   = note: expected raw pointer `*mut winapi::ctypes::c_void`
              found raw pointer `*mut std::ffi::c_void`

error[E0308]: mismatched types
  --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/portable-pty-0.6.0/src/win/mod.rs:43:45
   |
43 |         let res = unsafe { TerminateProcess(proc.as_raw_handle(), 1) };
   |                                             ^^^^^^^^^^^^^^^^^^^^ expected enum `winapi::ctypes::c_void`, found enum `std::ffi::c_void`
   |
   = note: expected raw pointer `*mut winapi::ctypes::c_void`
              found raw pointer `*mut std::ffi::c_void`

error[E0308]: mismatched types
  --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/portable-pty-0.6.0/src/win/mod.rs:70:33
   |
70 |             WaitForSingleObject(proc.as_raw_handle(), INFINITE);
   |                                 ^^^^^^^^^^^^^^^^^^^^ expected enum `winapi::ctypes::c_void`, found enum `std::ffi::c_void`
   |
   = note: expected raw pointer `*mut winapi::ctypes::c_void`
              found raw pointer `*mut std::ffi::c_void`

error[E0308]: mismatched types
  --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/portable-pty-0.6.0/src/win/mod.rs:73:47
   |
73 |         let res = unsafe { GetExitCodeProcess(proc.as_raw_handle(), &mut status) };
   |                                               ^^^^^^^^^^^^^^^^^^^^ expected enum `winapi::ctypes::c_void`, found enum `std::ffi::c_void`
   |
   = note: expected raw pointer `*mut winapi::ctypes::c_void`
              found raw pointer `*mut std::ffi::c_void`

error[E0308]: mismatched types
  --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/portable-pty-0.6.0/src/win/mod.rs:82:41
   |
82 |         let res = unsafe { GetProcessId(self.proc.lock().unwrap().as_raw_handle()) };
   |                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected enum `winapi::ctypes::c_void`, found enum `std::ffi::c_void`
   |
   = note: expected raw pointer `*mut winapi::ctypes::c_void`
              found raw pointer `*mut std::ffi::c_void`

error[E0308]: mismatched types
   --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/portable-pty-0.6.0/src/win/mod.rs:113:45
    |
113 |                         WaitForSingleObject(handle.0, INFINITE);
    |                                             ^^^^^^^^ expected enum `winapi::ctypes::c_void`, found enum `std::ffi::c_void`
    |
    = note: expected raw pointer `*mut winapi::ctypes::c_void`
               found raw pointer `*mut std::ffi::c_void
@CyriacBr CyriacBr added the bug Something isn't working label Dec 11, 2021
@wez
Copy link
Owner

wez commented Dec 12, 2021

Are you cross compiling for windows? The .cargo paths in the error messages you pasted don't look like windows paths.
x86_64-pc-windows-msvc is the target we build for on win32 for wezterm so we know that works.

What version of rust are you building with?

@wez wez added the waiting-on-op Waiting for more information from the original poster label Dec 12, 2021
@CyriacBr
Copy link
Author

Yeah these logs come from a cross compilation, on linux with --target x86_64-pc-windows-msvc.
Unfortunately the same thing happens during CI on a Windows virtual machine:

   Compiling portable-pty v0.6.0
error[E0308]: mismatched types
Error:   --> C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\portable-pty-0.6.0\src\win\procthreadattr.rs:54:17
   |
54 |                 con,
   |                 ^^^ expected enum `winapi::ctypes::c_void`, found enum `std::ffi::c_void`
   |
   = note: expected raw pointer `*mut winapi::ctypes::c_void`
              found raw pointer `*mut std::ffi::c_void`

error[E0308]: mismatched types
Error:   --> C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\portable-pty-0.6.0\src\win\psuedocon.rs:79:30
   |
79 |         let mut con: HPCON = INVALID_HANDLE_VALUE;
   |                      -----   ^^^^^^^^^^^^^^^^^^^^ expected enum `std::ffi::c_void`, found enum `winapi::ctypes::c_void`
   |                      |
   |                      expected due to this
   |
   = note: expected raw pointer `*mut std::ffi::c_void`
              found raw pointer `*mut winapi::ctypes::c_void`

error[E0308]: mismatched types
Error:    --> C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\portable-pty-0.6.0\src\win\psuedocon.rs:154:66
    |
154 |         let _main_thread = unsafe { OwnedHandle::from_raw_handle(pi.hThread) };
    |                                                                  ^^^^^^^^^^ expected enum `std::ffi::c_void`, found enum `winapi::ctypes::c_void`
    |
    = note: expected raw pointer `*mut std::ffi::c_void`
               found raw pointer `*mut winapi::ctypes::c_void`

error[E0308]: mismatched types
Error:    --> C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\portable-pty-0.6.0\src\win\psuedocon.rs:155:58
    |
155 |         let proc = unsafe { OwnedHandle::from_raw_handle(pi.hProcess) };
    |                                                          ^^^^^^^^^^^ expected enum `std::ffi::c_void`, found enum `winapi::ctypes::c_void`
    |
    = note: expected raw pointer `*mut std::ffi::c_void`
               found raw pointer `*mut winapi::ctypes::c_void`

error[E0308]: mismatched types
Error:   --> C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\portable-pty-0.6.0\src\win\mod.rs:29:47
   |
29 |         let res = unsafe { GetExitCodeProcess(proc.as_raw_handle(), &mut status) };
   |                                               ^^^^^^^^^^^^^^^^^^^^ expected enum `winapi::ctypes::c_void`, found enum `std::ffi::c_void`
   |
   = note: expected raw pointer `*mut winapi::ctypes::c_void`
              found raw pointer `*mut std::ffi::c_void`

error[E0308]: mismatched types
Error:   --> C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\portable-pty-0.6.0\src\win\mod.rs:43:45
   |
43 |         let res = unsafe { TerminateProcess(proc.as_raw_handle(), 1) };
   |                                             ^^^^^^^^^^^^^^^^^^^^ expected enum `winapi::ctypes::c_void`, found enum `std::ffi::c_void`
   |
   = note: expected raw pointer `*mut winapi::ctypes::c_void`
              found raw pointer `*mut std::ffi::c_void`

error[E0308]: mismatched types
Error:   --> C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\portable-pty-0.6.0\src\win\mod.rs:70:33
   |
70 |             WaitForSingleObject(proc.as_raw_handle(), INFINITE);
   |                                 ^^^^^^^^^^^^^^^^^^^^ expected enum `winapi::ctypes::c_void`, found enum `std::ffi::c_void`
   |
   = note: expected raw pointer `*mut winapi::ctypes::c_void`
              found raw pointer `*mut std::ffi::c_void`

error[E0308]: mismatched types
Error:   --> C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\portable-pty-0.6.0\src\win\mod.rs:73:47
   |
73 |         let res = unsafe { GetExitCodeProcess(proc.as_raw_handle(), &mut status) };
   |                                               ^^^^^^^^^^^^^^^^^^^^ expected enum `winapi::ctypes::c_void`, found enum `std::ffi::c_void`
   |
   = note: expected raw pointer `*mut winapi::ctypes::c_void`
              found raw pointer `*mut std::ffi::c_void`

error[E0308]: mismatched types
Error:   --> C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\portable-pty-0.6.0\src\win\mod.rs:82:41
   |
82 |         let res = unsafe { GetProcessId(self.proc.lock().unwrap().as_raw_handle()) };
   |                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected enum `winapi::ctypes::c_void`, found enum `std::ffi::c_void`
   |
   = note: expected raw pointer `*mut winapi::ctypes::c_void`
              found raw pointer `*mut std::ffi::c_void`

error[E0308]: mismatched types
Error:    --> C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\portable-pty-0.6.0\src\win\mod.rs:113:45
    |
113 |                         WaitForSingleObject(handle.0, INFINITE);
    |                                             ^^^^^^^^ expected enum `winapi::ctypes::c_void`, found enum `std::ffi::c_void`
    |
    = note: expected raw pointer `*mut winapi::ctypes::c_void`
               found raw pointer `*mut std::ffi::c_void`

For more information about this error, try `rustc --explain E0308`.
error: could not compile `portable-pty` due to 10 previous errors
Error: warning: build failed, waiting for other jobs to finish...

@no-response no-response bot removed the waiting-on-op Waiting for more information from the original poster label Dec 12, 2021
@CyriacBr
Copy link
Author

Has for the rust version:
rustc 1.57.0 (f1edd0429 2021-11-29)

@wez
Copy link
Owner

wez commented Dec 12, 2021

Can you check out the wezterm github repo and try compiling the pty crate directly with that version of Rust?
It lives in the pty subdirectory; just cd into it and run cargo build --examples.

I cannot reproduce this on my Windows system, or in our Windows CI, so I'm wondering if there is something about the project you are building that is influencing this!

@CyriacBr
Copy link
Author

I couldn't build from wezterm directly, there was errors related to winsock2.h, but I am on a linux, maybe that's why, I can't test this on the CI server.

Instead I created a very small reproduction: a rust project with just portable_pty as dep.
Running cargo build --release --target x86_64-pc-windows-msvc yields the error messages I pasted earlier.
This happens on my linux but that's what's happening on my CI windows server as well.

wez added a commit that referenced this issue Dec 12, 2021
For some reason, winapi's HANDLE type isn't compatible with the core
rust ffi HANDLE type when cross compiling.

This commit adds some casts.

```
cd pty
cargo build --release --target x86_64-pc-windows-msvc
```

refs: #1389
@wez
Copy link
Owner

wez commented Dec 12, 2021

I was able to reproduce this on linux; I've published version 0.7.0 of the crate!

@CyriacBr
Copy link
Author

It builds now. Thanks for taking action so quickly. portable_pty is a life saver!

@github-actions
Copy link

github-actions bot commented Feb 4, 2023

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants