dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.93k stars 4.64k forks source link

RISC-V support #36748

Open mattgenious opened 4 years ago

mattgenious commented 4 years ago

Posting because I cannot find mention anywhere

I have seen that mono supports the RISC-V architecture but cannot find anything relating to .NET 5 support for RISC-V. Are there any plans to support said architecture on future releases of .NET like ARM64 has been added?

am11 commented 9 months ago

@dotnet/samsung team has done excellent work! They deserve that bounty and more. πŸ†

myungjoo commented 9 months ago

@dotnet/samsung team has done excellent work! They deserve that bounty and more. πŸ†

@vincent-kwon

Xinlong-Wu commented 8 months ago

Hi all, Thanks for the help from @dkurt,

He just build a installable riscv64 package dotnet-sdk-8.0.100-linux-riscv64.tar.gz(CoreCLR Backend by Default) at repo dkurt/dotnet_riscv.

if you may try it. please check your libstdc++ support GLIBCXX_3.4.32, run command strings path/to/your/libstdc++.so.6 | grep GLIBCXX_3.4.32. It will except output GLIBCXX_3.4.32.

use following command to install dotnet riscv64

wget https://github.com/dkurt/dotnet_riscv/releases/download/v8.0.100/dotnet-sdk-8.0.100-linux-riscv64.tar.gz
DOTNET_FILE=dotnet-sdk-8.0.100-linux-riscv64.tar.gz
export DOTNET_ROOT=$(pwd)/.dotnet

mkdir -p "$DOTNET_ROOT" && tar zxf "$DOTNET_FILE" -C "$DOTNET_ROOT"

export PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools

you can use dotnet at riscv64 normally.

# create project
dotnet new console -n HelloWorld

modify Program.cs as

using System;

namespace HelloWorld
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            bool isMono = typeof(object).Assembly.GetType("Mono.RuntimeStructs") != null;
            Console.WriteLine($"Hello World {(isMono ? "from Mono!" : "from CoreCLR!")}");
            Console.WriteLine(typeof(object).Assembly.FullName);
            Console.WriteLine(System.Reflection.Assembly.GetEntryAssembly ());
            Console.WriteLine(System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription);
        }
    }
}
# build and run 
dotnet build
dotnet run

it will output

image

Note: Although dotnet-sdk-8.0.100-linux-riscv64.tar.gz has been packaged, it sitll has lots of potential issues, both on CoreCLR and Mono backend.

0xStuart commented 7 months ago

I tried this on a $8 Milk-V 256M running ubuntu.

root@milkvduo-ubuntu:~# dotnet new console -n HelloWorld
Illegal instruction

Probably not surprising with such a low hardware spec. Maybe if we can do AOT compilation it might work.

dkurt commented 7 months ago

@0xStuart, might be related to fence.tso hardware bug. Please try GCC version: https://github.com/dkurt/dotnet_riscv/releases/download/v8.0.101/dotnet-sdk-8.0.101-linux-riscv64-gcc.tar.gz

0xStuart commented 7 months ago

@dkurt It worked, although I had to kill it as it was taking forever to complete. I had htop running in another terminal, and it was visible that all the RAM got used up. Maybe adding swap will help.

image

Anyway, this is fantastic. These new RISC-V SOC's are opening up new possibilities.

clamp03 commented 6 months ago

I don't know why it's not mentioned here but for those interested there is a $ 500,- bounty on this issue. https://gitpay.me/#/task/607/risc-v-support

@dotnet/samsung team has done excellent work! They deserve that bounty and more. πŸ†

@JaneX8 @archanox @am11 Thank you so much! And @Xinlong-Wu also did great work in Mono runtime. Actually, we are supported by @samsung. So I hope @Xinlong-Wu get the bounty.

@jkotas If you don't mind, could you add our developers to dotnet org (and/or to @dotnet/samsung team)? I know, even if they are added, nothing changed for them. However, when I was added and got a badge, I was so happy and proud. They worked hard for .net runtime and I think they deserve it.

Could you please add? + You can remove all existing members in @dotnet/samsung except these 17 members. @wscho77 @HJLeee @clamp03 @JongHeonChoi @t-mustafin @gbalykov @viewizard @ashaurtaev @brucehoult @denis-paranichev @o-lek @sirntar @yurai007 @Bajtazar @bartlomiejko @rzsc @tomeksowi

@gbalykov @bartlomiejko Could you check the members?

gbalykov commented 6 months ago

Could you check the members?

@clamp03 it is correct, thank you!

bartlomiejko commented 6 months ago

Could you check the members?

@clamp03 thanks, it is correct, some of us already joined.

clamp03 commented 6 months ago

@gbalykov @bartlomiejko Thank you.

BruceForstall commented 6 months ago

@clamp03 Based on the above, I updated the @dotnet/samsung group as follows:

Removed @leemgs @idkiller @myungjoo @jyoungyun @sjsinju Added @JongHeonChoi @denis-paranichev @o-lek

I could not add @rzsc because they are not a member of the dotnet org. I believe @jkotas has sent them an invite.

Note that @denis-paranichev @o-lek @rzsc GitHub profiles do not indicate they are affiliated with Samsung.

Xinlong-Wu commented 6 months ago

If you don't mind, could you add our developers to dotnet org

hi @BruceForstall, same thing, I would be greatful if you can add me to dotnet org.

jkotas commented 6 months ago

@Xinlong-Wu We have added the folks above so that we can include them in dotnet samsung team that we have been working with closely for a long time and the team alias is convenient for github workflows. We do not add folks to the dotnet org without a demonstrated need.

vargaz commented 6 months ago

@Xinlong-Wu has been contributing riscv support for mono.

jkotas commented 6 months ago

I appreciate @Xinlong-Wu contributions. dotnet org membership is not required for contributing. It is only needed for membership in a dotnet org team alias or to grant additional permissions.

clamp03 commented 6 months ago

@clamp03 Based on the above, I updated the @dotnet/samsung group as follows:

Removed @leemgs @idkiller @myungjoo @jyoungyun @sjsinju Added @JongHeonChoi @denis-paranichev @o-lek

I could not add @rzsc because they are not a member of the dotnet org. I believe @jkotas has sent them an invite.

Note that @denis-paranichev @o-lek @rzsc GitHub profiles do not indicate they are affiliated with Samsung.

Thank you so much!!!!! @rzsc Please check your email inbox. (@bartlomiejko Could you please let him know?)

rzsc commented 6 months ago

I have turned on two-factor authentication and accepted invitation to the @dotnet organization. Is anything more I need to do, please?

BruceForstall commented 6 months ago

@rzsc I have added you to the https://github.com/orgs/dotnet/teams/samsung team.

ivanjx commented 5 months ago

is native aot for risc-v also covered here?

raffaeler commented 5 months ago

is native aot for risc-v also covered here?

AOT on risc-v would open a huge possibilities even on small microcontrollers having a decent amount of DRAM (I have some of them)

tomeksowi commented 5 months ago

@BruceForstall @jkotas Could you add @SzpejnaDawid to @dotnet/samsung (and @dotnet if necessary)? He joined our team in April and will be contributing to .NET RISC-V. Thank you.

am11 commented 1 month ago

IMG_5357

MuseBook risc-v! πŸŽ‰ (it’s RVA22 + V ext) will unpack, then try out dotnet and run runtime tests! 🀞

archanox commented 1 month ago

MuseBook risc-v! πŸŽ‰ (it’s RVA22 + V ext) will unpack, then try out dotnet and run runtime tests! 🀞

I've got the DC ROMA2 version. Do you have instructions on how to get dotnet running in its prerelease form?

am11 commented 1 month ago

@archanox, I will polish up https://github.com/am11/CrossRepoCITesting/blob/master/.github/workflows/linux-riscv64-runtime-build.yml to upload artifacts, then we will get the runtime package in its releases. Later I will switch it to build source build (runtime+aspnetcore+sdk+everything-else). For now, having runtime will be enough to run .NET assemblies.

filipnavara commented 3 weeks ago

I uploaded somewhat recent .NET SDK build for Risc-V here: https://github.com/filipnavara/dotnet-riscv/releases/tag/v9.0.0-preview.7.24405.7 (should be .NET 9 Preview 7). It has the same baseline requirements as the build from @am11, which means that the official Debian images for StarFive VisionFive 2 don't work (too old glibc). I checked that it runs on Ubuntu 24.04 which has some prebuilt images for common boards/machines.

ww898 commented 3 weeks ago

@filipnavara I got error on Ubuntu 24.04 riscv64 on StarFive VisionFive 2:

$ dotnet restore
/usr/local/dotnet/sdk/9.0.100-preview.7.24407.1/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.TargetFrameworkInference.targets(187,5): warning NETSDK1215: Targeting .NET Standard prior to 2.0 is no longer recommended. See https://aka.ms/dotnet/dotnet-standard-guidance for more details.
    /usr/local/dotnet/sdk/9.0.100-preview.7.24407.1/NuGet.targets(180,5): error : Root element is missing.

Restore failed with 1 error(s) and 1 warning(s) in 22.2s

Update Β§1: Started working after remove ~/.dotnet and ~/.nuget directories...

Update §2: All tests in my OSS projects are 🟒 green for now!!! Thanks a lot!!!

pvelesko commented 6 days ago

@filipnavara

https://github.com/pvelesko/dotnet_riscv/releases/tag/v8.0.101

built dotnet with statically linked libstc++ the binary above works on the starfive visionfive 2 Debian image (old glibc)