LLVM C/C++ Helloworld

Project HelloWorld Linux example using LLVM C/C++ compiler

This chapter covers the basics of LLVM C/C++ embedded Linux projects, including create/build/run/debug embedded Linux applications. The project referred to by this chapter is called “Hello World.” This application prints “Hello World” text and runs a simple for-loop for simple demonstration. The application can also be built and run on QEMU emulator.

Components Prerequisites

To build, run and debug LLVM Embedded Linux applications, please make sure that all below components are installed. Please refer to Component management for more information about installing component.

  • xplor-studio-linux-debug-plugin: Kernel XploR Studio Plugin using for kernel debugging
  • rv-linux-rootfs: RISC-V RootFS can be booted by QEMU and can run/debug RISC-V Embedded Linux applications
  • rv-qemu-linux64/rv-qemu-win64: QEMU for running and debugging RISC-V applications (Baremetal, Embedded, Embedded Linux)

All above components are compulsory for debugging LLVM Embedded Linux applications. Depending on variation of toolchain, XploR Studio has 2 different Linux toolchain components:

  • rv32gc-xplor-linux-linux64/rv32gc-xplor-linux-win64: RISC-V Embedded Linux toolchain 32-bit (Double)
  • rv64gc-xplor-linux-linux64/rv64gc-xplor-linux-win64: RISC-V Embedded Linux toolchain 64-bit (Double)

Each toolchain can be downloaded separately.

Working flow

  1. To create a new project, select File > New > C Project choose RISC-V Embedded Linux Project > Hello World (with LLVM)

example image

  1. Other steps (building, running and debugging with QEMU emulator) are same as the quick-start project. Please refer to Quick start with FreeRTOS project for general working flow.

Notes

  • On Ubuntu, LLVM Embedded Linux toolchain is packaged inside the Embedded Linux toolchain that supports Double extension (riscv32-xplord-linux and riscv64-xplord-linux).
  • LLVM Embedded Linux toolchain has not been supported on Windows yet.