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

Initial RISC-V support #1718

Merged
merged 17 commits into from
Mar 28, 2023
Merged

Initial RISC-V support #1718

merged 17 commits into from
Mar 28, 2023

Conversation

athei
Copy link
Contributor

@athei athei commented Mar 17, 2023

This makes ink! compile on RISC-V. There are two things which are just filled with interim values:

  • Location and size of the heap
  • Function ids and ABI of the host functions

Both of these things are not final and will be replaced once we have written the specification of our VM. Nonetheless we should still merge the code once this PR is in a good state: This allows us to iterate with the new RISC-V VM and prevent RISC-V from breaking in the future.

I will also need to make changes to cargo contract. As of right now I am compiling manually. Once a new cargo contract version is released I can add the CI jobs to this PR. Those will replace our no-std stop gap CI jobs.

Notable changes required for support:

  • RISC-V does not support cdylib. Instead, we build contracts as bin target (to be added by cargo contract). We need to use a single entry point in case of RISC-V. This is also why every contract needs to add no_main in addition to no_std when building for RISC-V (wasm doesn't care). Wasm can have multiple entry points even when build as bin. So we can do that unconditionally.
  • Panic handler needs support for RISC-V
  • Memory allocator needs support for RISC-V
  • oom handler needs support for RISC-V. I opted for removing the handler and raising the Rust version. A default handler is supplied starting with version 1.68. Hence we no longer need the unstable feature.

@athei
Copy link
Contributor Author

athei commented Mar 19, 2023

Apparently doc tests are not run if a library doesn't include the rlibtarget. By adding it to all integration tests (by falling back to default) the multisig doc tests were suddenly run. I fixed them up.

Also needed to update the dyling toolchain as we no require 1.68.

@codecov-commenter
Copy link

codecov-commenter commented Mar 19, 2023

Codecov Report

Merging #1718 (412bffa) into master (3f11e0e) will decrease coverage by 0.02%.
The diff coverage is 66.66%.

@@            Coverage Diff             @@
##           master    #1718      +/-   ##
==========================================
- Coverage   70.74%   70.73%   -0.02%     
==========================================
  Files         205      205              
  Lines        6478     6479       +1     
==========================================
  Hits         4583     4583              
- Misses       1895     1896       +1     
Impacted Files Coverage Δ
crates/ink/codegen/src/generator/dispatch.rs 92.95% <ø> (ø)
crates/allocator/src/bump.rs 86.61% <66.66%> (-3.47%) ⬇️

... and 3 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@athei athei marked this pull request as ready for review March 28, 2023 09:59
@athei athei requested review from a team, cmichi, ascjones, HCastano and SkymanOne as code owners March 28, 2023 09:59
@athei
Copy link
Contributor Author

athei commented Mar 28, 2023

Ready for review. Let's get this in as-is because it touches a lot of files and I expect merge conflicts. I will do a follow up PR where I will use cargo contract in the CI.

.gitlab-ci.yml Outdated Show resolved Hide resolved
crates/env/src/engine/on_chain/ext/riscv32.rs Outdated Show resolved Hide resolved
integration-tests/basic_contract_caller/lib.rs Outdated Show resolved Hide resolved
athei and others added 2 commits March 28, 2023 15:47
Co-authored-by: Andrew Jones <ascjones@gmail.com>
@athei
Copy link
Contributor Author

athei commented Mar 28, 2023

The code for riscv uses allocation to provide a buffer to encode the arguments for the host into. This will be changed to a static buffer in a follow up. It requires a bigger refactor.

@athei athei merged commit 6fb975d into master Mar 28, 2023
@athei athei deleted the at/riscv branch March 28, 2023 15:37
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

Successfully merging this pull request may close these issues.

3 participants