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

riscv64 is now upstream Debian architecture #96349

Closed
wants to merge 1 commit into from

Conversation

dkurt
Copy link
Contributor

@dkurt dkurt commented Dec 28, 2023

https://wiki.debian.org/RISC-V#Package_repository

sudo ./eng/common/cross/build-rootfs.sh riscv64 sid --rootfsdir ./riscv64-rootfs

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Dec 28, 2023
@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Dec 28, 2023
@dkurt
Copy link
Contributor Author

dkurt commented Dec 28, 2023

Is there a simple way to update it everywhere used in https://github.com/dotnet/dotnet/?

@dkurt
Copy link
Contributor Author

dkurt commented Dec 28, 2023

@dotnet-policy-service agree

@am11
Copy link
Member

am11 commented Dec 28, 2023

Thanks! Please update it in the upstream repo: https://github.com/dotnet/arcade/tree/main/eng/common/native. It will automatically sync here in a few days.

ps - these scripts are technically "unused" in this repo except for someone trying to build a custom environment; they are ultimately used in https://github.com/dotnet/dotnet-buildtools-prereqs-docker/ repo where we build the reusable docker images for CI as well as local dev environments.

@dkurt
Copy link
Contributor Author

dkurt commented Dec 29, 2023

@am11 can you please share the right entry point to build dotnet SDK for a foreign RID? I'm trying to build if for RISC-V by the following steps:

ROOTFS_DIR=/rootfs ./build.sh --arch riscv64 --os linux --cross

But it's probably not correct:

/usr/bin/clang-17 --target=riscv64-linux-gnu --gcc-toolchain=/home/dkurtaev/runtime/riscv64-rootfs//usr --sysroot=/home/dkurtaev/runtime/riscv64-rootfs/ -Wl,--rpath-link=/home/dkurtaev/runtime/riscv64-rootfs//lib/riscv64-linux-gnu -Wl,--rpath-link=/home/dkurtaev/runtime/riscv64-rootfs//usr/lib/riscv64-linux-gnu -Wl,--rpath-link=/home/dkurtaev/runtime/riscv64-rootfs//lib/riscv64-linux-gnu -Wl,--rpath-link=/home/dkurtaev/runtime/riscv64-rootfs//usr/lib/riscv64-linux-gnu -fuse-ld=lld  CMakeFiles/cmTC_dc4ea.dir/testCCompiler.c.o -o cmTC_dc4ea   -latomic 
ld.lld: error: /home/dkurtaev/runtime/riscv64-rootfs/lib/riscv64-linux-gnu/Scrt1.o:(.text+0x0): relocation R_RISCV_ALIGN requires unimplemented linker relaxation; recompile with -mno-relax
clang-17: error: linker command failed with exit code 1 (use -v to see invocation)
  Executing "/home/dkurtaev/runtime/src/coreclr/build-runtime.sh" -riscv64 -debug -cross -os linux -outputrid linux-riscv64
  Commencing CoreCLR Repo build
  __OutputRid: linux-riscv64
  Setting up directories for build
  Checking prerequisites...
  Commencing build of "install" target in "CoreCLR component" for linux.riscv64.Debug in /home/dkurtaev/runtime/artifacts/obj/coreclr/linux.riscv64.Debug
  Invoking "/home/dkurtaev/runtime/eng/native/gen-buildsys.sh" "/home/dkurtaev/runtime/src/coreclr" "/home/dkurtaev/runtime/artifacts/obj/coreclr/linux.riscv64.Debug" riscv64 linux clang Debug ""  -DCLR_CMAKE_PGO_INSTRUMENT=0 -DCLR_CMAKE_OPTDATA_PATH= -DCLR_CMAKE_PGO_OPTIMIZE=0 -DCLI_CMAKE_FALLBACK_OS="linux" -DFEATURE_DISTRO_AGNOSTIC_SSL=1 
  Not searching for unused variables given on the command line.
  loading initial cache file /home/dkurtaev/runtime/eng/native/tryrun.cmake
  -- The C compiler identification is Clang 17.0.6
  -- The CXX compiler identification is Clang 17.0.6
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - failed
  -- Check for working C compiler: /usr/bin/clang-17
  -- Check for working C compiler: /usr/bin/clang-17 - broken
  CMake Error at /usr/share/cmake-3.22/Modules/CMakeTestCCompiler.cmake:69 (message):
    The C compiler
  
      "/usr/bin/clang-17"
  
    is not able to compile a simple test program.
  
    It fails with the following output:
  
      Change Dir: /home/dkurtaev/runtime/artifacts/obj/coreclr/linux.riscv64.Debug/CMakeFiles/CMakeTmp
      
      Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_dc4ea/fast && /usr/bin/gmake  -f CMakeFiles/cmTC_dc4ea.dir/build.make CMakeFiles/cmTC_dc4ea.dir/build
      gmake[1]: Entering directory '/home/dkurtaev/runtime/artifacts/obj/coreclr/linux.riscv64.Debug/CMakeFiles/CMakeTmp'
      Building C object CMakeFiles/cmTC_dc4ea.dir/testCCompiler.c.o
      /usr/bin/clang-17 --target=riscv64-linux-gnu --gcc-toolchain=/home/dkurtaev/runtime/riscv64-rootfs//usr --sysroot=/home/dkurtaev/runtime/riscv64-rootfs/    -MD -MT CMakeFiles/cmTC_dc4ea.dir/testCCompiler.c.o -MF CMakeFiles/cmTC_dc4ea.dir/testCCompiler.c.o.d -o CMakeFiles/cmTC_dc4ea.dir/testCCompiler.c.o -c /home/dkurtaev/runtime/artifacts/obj/coreclr/linux.riscv64.Debug/CMakeFiles/CMakeTmp/testCCompiler.c
      Linking C executable cmTC_dc4ea
      /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_dc4ea.dir/link.txt --verbose=1
      /usr/bin/clang-17 --target=riscv64-linux-gnu --gcc-toolchain=/home/dkurtaev/runtime/riscv64-rootfs//usr --sysroot=/home/dkurtaev/runtime/riscv64-rootfs/ -Wl,--rpath-link=/home/dkurtaev/runtime/riscv64-rootfs//lib/riscv64-linux-gnu -Wl,--rpath-link=/home/dkurtaev/runtime/riscv64-rootfs//usr/lib/riscv64-linux-gnu -Wl,--rpath-link=/home/dkurtaev/runtime/riscv64-rootfs//lib/riscv64-linux-gnu -Wl,--rpath-link=/home/dkurtaev/runtime/riscv64-rootfs//usr/lib/riscv64-linux-gnu -fuse-ld=lld  CMakeFiles/cmTC_dc4ea.dir/testCCompiler.c.o -o cmTC_dc4ea   -latomic 
      ld.lld: error: /home/dkurtaev/runtime/riscv64-rootfs/lib/riscv64-linux-gnu/Scrt1.o:(.text+0x0): relocation R_RISCV_ALIGN requires unimplemented linker relaxation; recompile with -mno-relax
      clang-17: error: linker command failed with exit code 1 (use -v to see invocation)
      gmake[1]: *** [CMakeFiles/cmTC_dc4ea.dir/build.make:100: cmTC_dc4ea] Error 1
      gmake[1]: Leaving directory '/home/dkurtaev/runtime/artifacts/obj/coreclr/linux.riscv64.Debug/CMakeFiles/CMakeTmp'
      gmake: *** [Makefile:127: cmTC_dc4ea/fast] Error 2
      
      
  
    
  
    CMake will not be able to correctly generate this project.
  Call Stack (most recent call first):
    CMakeLists.txt:4 (project)
  
  
  -- Configuring incomplete, errors occurred!
  See also "/home/dkurtaev/runtime/artifacts/obj/coreclr/linux.riscv64.Debug/CMakeFiles/CMakeOutput.log".
  See also "/home/dkurtaev/runtime/artifacts/obj/coreclr/linux.riscv64.Debug/CMakeFiles/CMakeError.log".
  Failed to generate "CoreCLR component" build project!
/home/dkurtaev/runtime/src/coreclr/runtime.proj(95,5): error MSB3073: The command ""/home/dkurtaev/runtime/src/coreclr/build-runtime.sh" -riscv64 -debug -cross -os linux -outputrid linux-riscv64" exited with code 1.

Build FAILED.

/home/dkurtaev/runtime/src/coreclr/runtime.proj(95,5): error MSB3073: The command ""/home/dkurtaev/runtime/src/coreclr/build-runtime.sh" -riscv64 -debug -cross -os linux -outputrid linux-riscv64" exited with code 1.
    0 Warning(s)
    1 Error(s)

/cc @Xinlong-Wu

@Xinlong-Wu
Copy link
Contributor

Could you provided the log /home/dkurtaev/runtime/artifacts/obj/coreclr/linux.riscv64.Debug/CMakeFiles/CMakeError.log ?

Besides, if you want to compile runtime for riscv64,
following may helps

# Creating rootfs
sudo  ./eng/common/cross/build-rootfs.sh riscv64 sid
export ROOTFS_DIR=<path to project>/.tools/rootfs/riscv64

# build runtime with mono
./build.sh mono+libs+host -c Debug --cross --arch riscv64

# of build runtime with CoreLR
./build.sh clr+libs+host -c Debug --cross --arch riscv64

But if you want to crate installable package like dotnet-v8.0.0-riscv.tar.gz may please reference to repo dotnet/dotnet

@dkurt
Copy link
Contributor Author

dkurt commented Dec 29, 2023

@Xinlong-Wu, seems like #96349 (comment) is a future problem or I misconfigured somethind. The latest published Docker image works fine:

docker run --rm -it mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-22.04-cross-riscv64
export ROOTFS_DIR=/crossrootfs/riscv64/
./build.sh --arch riscv64 --os linux --cross

There is a different problem but I will try https://github.com/dotnet/dotnet, thanks!

/runtime/src/tools/illink/src/ILLink.Tasks/build/Microsoft.NET.ILLink.targets(138,5): error MSB6006: "dotnet" exited with code 134. [/runtime/src/coreclr/tools/aot/crossgen2/crossgen2_publish.csproj]
/runtime/src/tools/illink/src/ILLink.Tasks/build/Microsoft.NET.ILLink.targets(91,5): error NETSDK1144: Optimizing assemblies for size failed. Optimization can be disabled by setting the PublishTrimmed property to false. [/runtime/src/coreclr/tools/aot/crossgen2/crossgen2_publish.csproj]

@dkurt dkurt closed this Dec 29, 2023
@Xinlong-Wu
Copy link
Contributor

ld.lld: error: /home/dkurtaev/runtime/riscv64-rootfs/lib/riscv64-linux-gnu/Scrt1.o:(.text+0x0): relocation R_RISCV_ALIGN requires unimplemented linker relaxation; recompile with -mno-relax

I found the problem, I am contributing the llvm too. your ld.lld might be outdate already. please update it and try it again if you want. ld.lld has implement linker relaxation at about 1 years ago.

but at least image source should be update, please do that if you want.

@dkurt
Copy link
Contributor Author

dkurt commented Dec 29, 2023

@Xinlong-Wu, sorry for bothering again. Can you please share your approach of cross compilation of dotnet? I managed to build runtime, but not a RISC-V RID with dotnet/dotnet. packs option during runtime build gives a number of nuget but none of them contains a dotnet binary so I can run at least dotnet -version

@dkurt dkurt deleted the dkurt/update_riscv64_rootfs branch January 12, 2024 12:26
@github-actions github-actions bot locked and limited conversation to collaborators Feb 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
community-contribution Indicates that the PR has been added by a community member needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants