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

cannot be compiled on Windows #4919

Closed
2 tasks done
chuacw opened this issue Jul 1, 2024 · 9 comments
Closed
2 tasks done

cannot be compiled on Windows #4919

chuacw opened this issue Jul 1, 2024 · 9 comments
Labels
I2-bug The node fails to follow expected behavior. I10-unconfirmed Issue might be valid, but it's not yet known.

Comments

@chuacw
Copy link

chuacw commented Jul 1, 2024

Is there an existing issue?

  • I have searched the existing issues

Experiencing problems? Have you tried our Stack Exchange first?

  • This is not a support question.

Description of bug

Polkadot SDK cannot be compiled on Windows

Steps to reproduce

git clone https://github.com/paritytech/polkadot-sdk.git
cd polkadot-sdk
cargo build --release

error[E0433]: failed to resolve: could not find `sys` in `nix`
  --> polkadot\node\core\pvf\common\src\worker\mod.rs:27:25
   |
27 | use nix::{errno::Errno, sys::resource::Usage};
   |                         ^^^ could not find `sys` in `nix`
error[E0432]: unresolved import `nix::errno`
  --> polkadot\node\core\pvf\common\src\worker\mod.rs:27:11
   |
27 | use nix::{errno::Errno, sys::resource::Usage};
   |           ^^^^^ could not find `errno` in `nix`

error[E0433]: failed to resolve: could not find `unix` in `os`
  --> polkadot\node\core\pvf\common\src\worker\mod.rs:35:3
   |
35 |         unix::net::UnixStream,
   |         ^^^^ could not find `unix` in `os`
error[E0432]: unresolved import `std::os::fd`
   --> polkadot\node\core\pvf\common\src\worker\mod.rs:34:3
    |
34  |         fd::{AsRawFd, FromRawFd, RawFd},
    |         ^^ could not find `fd` in `os`
error[E0425]: cannot find function `pipe2` in crate `libc`
   --> polkadot\node\core\pvf\common\src\worker\mod.rs:200:27
    |
200 |     let res = unsafe { libc::pipe2(fds.as_mut_ptr(), libc::O_CLOEXEC) };
    |                              ^^^^^ help: a function with a similar name exists: `pipe`

error[E0425]: cannot find value `O_CLOEXEC` in crate `libc`
   --> polkadot\node\core\pvf\common\src\worker\mod.rs:200:57
    |
200 |     let res = unsafe { libc::pipe2(fds.as_mut_ptr(), libc::O_CLOEXEC) };
    |                                                            ^^^^^^^^^ not found in `libc`

error[E0425]: cannot find function `getppid` in crate `libc`
   --> polkadot\node\core\pvf\common\src\worker\mod.rs:533:20
    |
533 |         let ppid = libc::getppid();
    |                          ^^^^^^^ help: a function with a similar name exists: `getpid`
    |
491 |     pub fn getpid() -> ::c_int;
    |     -------------------------- similarly named function `getpid` defined here

error[E0425]: cannot find function `kill` in crate `libc`
   --> polkadot\node\core\pvf\common\src\worker\mod.rs:535:10
    |
535 |             libc::kill(ppid, libc::SIGTERM);
    |                   ^^^^ not found in `libc`
@chuacw chuacw added I10-unconfirmed Issue might be valid, but it's not yet known. I2-bug The node fails to follow expected behavior. labels Jul 1, 2024
@bkchr
Copy link
Member

bkchr commented Jul 1, 2024

We don't officially support Windows. I know that some people are using the Linux subsystem to run Substrate based chains.

@chuacw
Copy link
Author

chuacw commented Jul 2, 2024

"We don't officially support Windows."

Not supporting it doesn't mean it shouldn't compile.
AFAICT, the issue is functions which are not implemented in the used crate, libc.

@nazar-pc
Copy link
Contributor

nazar-pc commented Jul 2, 2024

Not supporting it doesn't mean it shouldn't compile.

I guess it was an invitation to contribute corresponding fix 🙂

Substrate (at least up to 1.13) does successfully compile and run on Windows (we also run CI on Windows), but we (at Subspace) do not use Polkadot-specific crates, so you might want to contribute corresponding changes if you need to run it on Windows natively for whatever reason.

@bkchr
Copy link
Member

bkchr commented Jul 2, 2024

I guess it was an invitation to contribute corresponding fix 🙂

Exactly ;) I don't have a Windows machine to compile and fix these issues. So, if you have one, I will happily approve any pr.

@chuacw
Copy link
Author

chuacw commented Jul 3, 2024

The issue is with the libc crate used. I'm closing this and have started investigating and contributing fixes to libc as a result.

@chuacw chuacw closed this as completed Jul 3, 2024
@bkchr
Copy link
Member

bkchr commented Jul 3, 2024

I don't think that the issue is in libc and more in our codebase that we don't feature gated the usage correctly.

@chuacw
Copy link
Author

chuacw commented Jul 3, 2024

"don't have a Windows machine to compile and fix these issues. "

You don't need a Windows machine to compile for the Windows target.

rustc is a cross-compiler.

@nazar-pc
Copy link
Contributor

nazar-pc commented Jul 3, 2024

rustc is a cross-compiler.

If you actually try it in practice you'll notice it is not as simple as having a compiler capable of cross-compilation. I wish it was though.

@chuacw
Copy link
Author

chuacw commented Jul 3, 2024

@bkchr
"don't think that the issue is in libc"

I found libc::kill doesn't exist on Windows, so I've created a PR for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I2-bug The node fails to follow expected behavior. I10-unconfirmed Issue might be valid, but it's not yet known.
Projects
None yet
Development

No branches or pull requests

3 participants