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

Building for RISCV64? #102

Open
matsbror opened this issue May 6, 2024 · 10 comments
Open

Building for RISCV64? #102

matsbror opened this issue May 6, 2024 · 10 comments

Comments

@matsbror
Copy link

matsbror commented May 6, 2024

Did anyone try to build for RISCV64?

The regular Make (with TARGET set to riscv64gc-unknown-linux-gnu) doesn't work.

@radu-matei
Copy link
Member

Hey, @matsbror, thank you for reporting this.
Would you mind sharing the output of running the build command, please?

For context, we do know at least the Wasmtime / Spin dependency for the shim (the part executing Wasm) does compile and run correctly on RISC-V.
I don't have a lot of context for the containerd / youki dependencies, so paging @Mossaka for some help on it.

@matsbror
Copy link
Author

matsbror commented May 6, 2024

I am on v0.13.1. On my RISCV64-board, I try to build it directly like:

cargo build --release --target riscv64gc-unknown-linux-gnu --manifest-path=containerd-shim-spin/Cargo.toml                                                                                            

as I had issues with the Makefile

It fails trying to compile ring.

error: failed to run custom build command for `ring v0.16.20`

I have wasmtime cli running fine so I know that that part is working. I remember I had issues with the ring crate a long time ago when running the sightglass benchmarks in wasmtime. Then I believe I resolved by using a local copy of precision which used ring. Ring 0.17 has resolved the issue on RISCV, but these are the crates in Cargo.lock that refers to ring v0.16.20:

  • aws-config (I don't care about this)
  • rustls

aws-config in turns is used by trigger-sqs and rustls used by wasmtime-wasi-http, which I definitely want.

I will continue to investigate if there is a way to remove or upgrade these dependencies so that ring 0.17.8 is used instead.

EDIT: I should add that I get the same error when cross-compiling on an x86 machine.

@radu-matei
Copy link
Member

Adding @tschneidereit who had success running Spin on a RISCV64 board.

@matsbror
Copy link
Author

matsbror commented May 7, 2024

I managed to build runwasi by removing the Cargo.lock file so that cargo could rebuild the dependencies from scratch. That did not work for this repo. However, the issue lies in trigger-sqs. As far as I understand, this is related to AWS and I do not intend to use AWS for this project (now RISCV-instances there :-) so how can I remove that dependency?

@radu-matei
Copy link
Member

We should put the other triggers behind Cargo features, to make this kind of thing easier.

Specifically, to unblock your use case, you can:

@matsbror
Copy link
Author

matsbror commented May 7, 2024

Unfortunately I still do not have success. spin-trigger-http needs tokio-rustls which needs rustls which uses `ring 0.16.20.
I tried to force cargo to replace ring 0.16.20 with 0.17.8 using:

[replace]
"ring:0.16.20" = { git = "https://github.com/briansmith/ring" }

at the top-level Cargo.toml, but it failed as rustls required v0.16.20

@tschneidereit
Copy link

When I experimented with this last Fall, there was no version of Ring released that would've supported RISCV, so I hacked something up that Worked On My Machine.

By now this should all be much easier, luckily: there's a pretty recent release of tokio-rustls that depends on ring 0.17, which should be recent enough, I think. I don't know how involved updating tokio-rustls would be, but I'd hope that it's not too heavy a lift.

@matsbror
Copy link
Author

matsbror commented May 7, 2024

Thanks @tschneidereit , but how do I replace the dependency on ring or tokio-rustls as they are not top-level dependencies?

@tschneidereit
Copy link

it seems like tokio-rustls is the dependency to replace/update here. If we're really lucky, the version of that which (via its updated ring dependency) supports RISCV is API-compatible for our purposes. If that is the case, you should be able to get a build by adding this to your project's Cargo.toml file:

[patch.crates-io]
tokio-rustls = { git = 'https://github.com/rustls/tokio-rustls.git', tag = "v/0.26.0" }

If that doesn't work out of the box, it's possible that slight adjustments would fix it.

If that works, a PR to the spin repo updating the dependency would be fantastic!

@matsbror
Copy link
Author

I managed to resolve the issue for me.

I updated the dependency in spin/crates/trigger-http/Cargo.toml of tokio-rustls to version 0.24.1. That was enough to push ring to version 0.17.8 without breaking anything else.

This one resolved the issue for containerd-shim-spin also but I had to add a dependency to spin-ecpressions in the spin repo.

However, I cannot (now) make a PR for spin on this as I am not able to run tests (even on main branch) and I know too little to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants