Roadmap for a Native Development Toolchain

Roadmap for a Native Development Toolchain on a High-Performance RISC-V SBC (Milk-V MEGREZ with 32GB+ RAM)

Update: I discovered that this doesn’t build lldb (llvm debugger) and I modified the cmake flags to build it. It failed in the linker phase. I am subsequently building the latest stable release of llvm with the debugger. The only reason that I chose this version was to install llvm-lite and numba which required this version. I managed to get them to install but numba failed its tests and I decided to move on to implementing the most useful tools (numba would have been nice, but not essential)

Overview:

This document provides a proven, step-by-step guide for establishing a core native development toolchain on a high-performance RISC-V single-board computer. The process has been successfully executed on a Milk-V board with 32GB of RAM, resulting in a native LLVM/Clang toolchain and Node.js runtime.

This roadmap covers the fully validated steps. Future work to integrate a cloud IDE is noted as a work in progress, providing a clear and honest assessment for the community.

Phase 0: Foundation and System Preparation

Goal: Prepare the base system with all necessary dependencies.

Actions:

- Install a standard Ubuntu Server or Debian image for the board.

- Update the system: sudo apt update && sudo apt upgrade -y

- Install core tools: sudo apt install git ninja-build

Test:

- Write a simple “Hello, World” program in C (hello.c).

- Compile it: gcc hello.c -o hello

- Run it: ./hello

- The test is successful if the program compiles and runs.

Phase 1: Building the LLVM/Clang Toolchain (VALIDATED)

Goal: Build an optimized LLVM/Clang toolchain from source.

The following commands have been proven to work:

git clone GitHub - llvm/llvm-project: The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.

cd llvm-project

git fetch origin

git checkout release/15.x

mkdir build && cd build

cmake ../llvm \

-DCMAKE_BUILD_TYPE=Release \

-DLLVM_TARGETS_TO_BUILD=“RISCV” \

-DLLVM_ENABLE_PROJECTS=“clang;lld” \

-DLLVM_TARGET_ARCH=“riscv64” \

-DLLVM_DEFAULT_TARGET_TRIPLE=“riscv64-unknown-linux-gnu” \

-DCMAKE_CXX_FLAGS=“-Wno-attributes -march=rv64gc -mabi=lp64d -mcmodel=medany -fPIC” \

-DCMAKE_C_FLAGS=“-march=rv64gc -mabi=lp64d -mcmodel=medany -fPIC” \

-DLLVM_ENABLE_RTTI=ON \

-DLLVM_ENABLE_ZSTD=ON \

-DLLVM_INCLUDE_TESTS=OFF \

-DLLVM_ENABLE_PIC=ON \

-DLLVM_ENABLE_TERMINFO=OFF \

-DLLVM_BUILD_LLVM_DYLIB=ON \

-DLLVM_LINK_LLVM_DYLIB=ON

make -j$(nproc)

(8.5 hours compile time on megrez)

sudo make install

Test:

./bin/llvm-config --version

./bin/clang --version | grep “riscv64”

./bin/ld.lld --version

- The test is successful if all version commands execute correctly.

Phase 2: Building Node.js from Source (VALIDATED)

Goal: Build a Node.js runtime to support JavaScript tools.

The following commands have been proven to work:

sudo apt update

sudo apt install -y git python3 make gcc g++ libssl-dev

git clone GitHub - nodejs/node: Node.js JavaScript runtime ✨🐢🚀✨

cd node

./configure

make -j$(nproc)

sudo make install

node --version

npm --version

- The test is successful if both node and npm report their versions.

Phase 3: Future Work - Integration and IDE (WORK IN PROGRESS)

Goal: To complete the development environment with a cloud-based IDE.

The natural progression from Phases 1 and 2 is to install code-server, a version of VS Code that runs in a browser. This would provide a full-featured graphical IDE accessible from any machine on the network.

Current Status:

While the prerequisite Node.js is built and installed, the code-server installation and integration have encountered obstacles. These are likely related to additional native dependencies, post-install build steps within the npm package, or networking configuration.

This phase remains an active area of investigation. Success in this area would represent the final milestone for a completely self-hosted development experience.

Community Call to Action:

The successful builds of LLVM 15.x and Node.js are significant achievements that provide a critical foundation for the RISC-V community. They demonstrate that native compilation of major toolchains is not only possible but practical on capable hardware.

We encourage the community to build upon this work:

1. Reproduce the Builds: Confirm these steps work on other high-performance RISC-V boards and report any variations needed.

2. Expand the Toolchain: Experiment with building more LLVM projects (e.g., lldb, libcxx) using the established configuration as a template.

3. Investigate code-server: Collaborate to solve the integration challenges with code-server. Identifying the missing dependencies or necessary build flags will be a valuable contribution.

By sharing these precise, working instructions and collaboratively tackling the next challenges, we can significantly accelerate the maturity of the RISC-V software ecosystem. Your provided build sequences are the confirmed blueprint for the core toolchain.

1 Like