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

Add riscv32 support #1880

Conversation

blue-freedom-technologies
Copy link

@blue-freedom-technologies blue-freedom-technologies commented Jan 4, 2024

I am happy to accept a PR that adds riscv32 support. I suggest we start with riscv32gc-unknown-linux-gnu since we can just copy-paste-edit the changes from PR #1627, at least for for target.h, mk/cargo.sh, mk/install-build-tools.sh.

@blue-freedom-technologies
Copy link
Author

Hi @briansmith,

There are two points here that we need your advise:
-OPENSSL_32_BIT
-newliblinux-multilib

Thank you for your time.

Cheers,

Copy link

codecov bot commented Jan 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (7f8fb38) 96.03% compared to head (49c9f56) 96.02%.
Report is 1 commits behind head on main.

❗ Current head 49c9f56 differs from pull request most recent head 41d6076. Consider uploading reports for the commit 41d6076 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1880      +/-   ##
==========================================
- Coverage   96.03%   96.02%   -0.02%     
==========================================
  Files         136      136              
  Lines       20761    20776      +15     
  Branches      226      226              
==========================================
+ Hits        19938    19950      +12     
- Misses        789      792       +3     
  Partials       34       34              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

include/ring-core/target.h Outdated Show resolved Hide resolved
--target=riscv32gc-unknown-linux-gnu)
use_clang=1
install_packages \
#https://github.com/riscv-collab/riscv-gnu-toolchain#installation-newliblinux-multilib
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that this target is quite difficult to support. I read "If you need riscv32-linux, then yes you will need to build it." from riscv-collab/riscv-gnu-toolchain#808.

It seems like my niave and underinformed guess that riscv32gc-unknown-linux-gnu would be the easiest riscv32 target to support was wrong.

Is riscv32gc-unknown-linux-gnu the actual target you are trying to support, or were you just trying to follow my suggestion? If you don't need riscv32gc-unknown-linux-gnu but instead need a different target, I think we should focus on the one that's actually useful.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for taking the time for this analysis.

Ok, don't forget you ask for it not me.... don't kill the messenger.

Now the bad news:
our target riscv32imac-esp-espidf is a Tier 3. Meaning target is supported but not built, distributed, or guaranteed to work.

So, for our target to work we need to have the ESP-IDF Toolchain and then have a config.toml similar to this :

[build]
target = "riscv32imac-esp-espidf"

[target.riscv32imac-esp-espidf]
linker = "/tools/riscv32-esp-elf/esp-12.2.0_20230208/riscv32-esp-elf/riscv32-esp-elf/bin/ld"

[unstable]
build-std = ["std", "panic_abort"]

[env]
MCU="esp32c6"
ESP_IDF_VERSION = "v5.1.1"
TARGET_CC = "/tools/riscv32-esp-elf/esp-12.2.0_20230208/riscv32-esp-elf/bin/riscv32-esp-elf-cc"

For the ring crate build.

As example let's run the test case ed25519_tests:

cargo build --test ed25519_tests

Result...

image

So ☹️, I am open to suggestions on your side....when you have the time of course.

@blue-freedom-technologies
Copy link
Author

On a more happy note I have added the target_os = "espidf".

Thank you for your time addressing all of these troubles.

Cheers,

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.

2 participants