rs-ipfs / rust-ipfs

The InterPlanetary File System (IPFS), implemented in Rust.
Apache License 2.0
1.26k stars 163 forks source link

Hacking on windows guidance #170

Open koivunej opened 4 years ago

koivunej commented 4 years ago

I've managed to install a compatible compilation environment for the root crate in Windows by:

  1. install rustup with stable-gnu (stable-msvc linker didn't work, not sure why)
  2. install msys2 by installer per https://github.com/rust-lang/rust#mingw
  3. install git, vim, and gcc with pacman -S
  4. cargo test works

At least clear_on_drop dependency requires the gcc, so installing just the toolchain with rustup is not enough. Following the https://github.com/rust-lang/rust#mingw way of installing gcc through mingw-w64-x86_64-gcc did not work for me.

We should have a guide for "hacking on windows".

Originally posted by @koivunej in https://github.com/rs-ipfs/rust-ipfs/pull/169#issuecomment-629189456

My above comment doesn't cover compiling the ipfs-http crate.

koivunej commented 4 years ago

Any help from people more familiar with rust on windows would be much appreciated! The best possible outcome would be to support running cargo test --workspace which with my original hints fails because openssl fails to find the libraries. On CI we use vcpkg which I have no idea how to install it myself or if it could be installed through msys2 pacman.

Tried to install openssl, pkg-config and openssl-devel through pacman but the cargo test --workspace fails to find the openssl libraries at link time.

The guide could become a file under docs/ and we could link to it from the root README for example.

akx commented 4 years ago

If the crux of the issue is xplat compilation of openssl, and seeing as openssl is only required for RSA generation according to https://github.com/rs-ipfs/rust-ipfs/blob/ad4601a37db61446a705b4399152963512ea2e0c/http/Cargo.toml#L21-L22 how about something like the ring crate instead? https://docs.rs/ring/0.16.13/ring/signature/struct.RsaKeyPair.html

koivunej commented 4 years ago

For the purposes of actually using the key rust-libp2p already uses ring but ring doesn't support keygen, similarly to rsa at least didn't used to support keygen and export into pkcs#1, if I remember correctly if that was needed here. It'd be easiest not to depend on openssl, but the keygen will become more important on /api/v0/key/gen for example even if the peer identity could be in ed25519.

aphelionz commented 4 years ago

Personally, openssl is a high-value target for jettison. @koivunej I know you did a pretty thorough search on this back in March. Maybe the situation has changed? :crossed_fingers:

It would obviate the need for this as well. I forget recently but there was a Rust talk where a team talked about openssl alternatives for either games or embedded work. I'll try and dig it up.

Scondo commented 3 years ago

Well... for now stable-x86_64-pc-windows-msvc (default) rustc 1.53.0 (53cb7b09b 2021-06-17) https://github.com/rs-ipfs/rust-ipfs/commit/4bce4679de6c4f206864de843f14e2c273560dcb

It is as simple as rustup-init; git clone; cargo test

So... what exactly should be in this guide? How to do same on msys?

Scondo commented 3 years ago

Ok. I found problems with OpenSSL when run complete workspace.

Write some doc about installation https://github.com/Scondo/rust-ipfs/blob/master/doc/windows.md Could also try way with vcpkg as alternative.

koivunej commented 3 years ago

My initial idea for this was: just getting the workspace up and running. The openssl dependency is a chore. I remember creating this issue back when there was some general trouble of installing rust on windows ... I guess with the msys. I'll try to remember to peek at your doc; thanks for your efforts on this front!

On a vcpkg related note: #469 bumped the versions on CI as the previous revision I had pinned had started to segfault or whatever is the windows code for that.