diff options
author | Christoph Müllner <christoph.muellner@vrull.eu> | 2022-09-28 00:14:41 +0200 |
---|---|---|
committer | Kito Cheng <kito.cheng@sifive.com> | 2023-05-17 14:01:44 +0800 |
commit | ea26fd6cb82aaa8e7fc95adc704442dc466dac9e (patch) | |
tree | a9edf205efb85f89dbb0509a5ccfa9e3212adf65 /README.md | |
parent | ee1bb922707b53b479552b4aa8fb009b35ce8d22 (diff) | |
download | riscv-gnu-toolchain-ea26fd6cb82aaa8e7fc95adc704442dc466dac9e.zip riscv-gnu-toolchain-ea26fd6cb82aaa8e7fc95adc704442dc466dac9e.tar.gz riscv-gnu-toolchain-ea26fd6cb82aaa8e7fc95adc704442dc466dac9e.tar.bz2 |
Add support to build LLVM/clang with C and C++ support
We currently have a stale "llvm" branch, that does not build.
However, there is clear demand in the RISC-V toolchain community
for a working LLVM on top of a recent GNU toolchain.
In order to build such a toolchain, quite some LLVM and clang know-how is
required to avoid path issues at LLVM build time or later when using clang.
The main purpose of this commit is to demonstrate a way to combine
the RISC-V GNU toolchain repo with LLVM, with the intent to save
others hours of frustration, debugging time or support time.
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 42 |
1 files changed, 37 insertions, 5 deletions
@@ -245,6 +245,37 @@ The command below can be used to run the glibc tests: make check-glibc-linux +### LLVM / clang + +LLVM can be used in combination with the RISC-V GNU Compiler Toolchain +to build RISC-V applications. To build LLVM with C and C++ support the +configure flag `--enable-llvm` can be used. + +E.g. to build LLVM on top of a RV64 Linux toolchain the following commands +can be used: + + ./configure --prefix=$RISCV --enable-llvm --enable-linux + make + +Note, that a combination of `--enable-llvm` and multilib configuration flags +is not supported. +Also note, that building LLVM is only supported in combination with building +a Linux toolchain. + +Below is an example how to build a rv64gc Linux toolchain with LLVM support, +how to use it to build a C and a C++ application using clang, and how to +execute the generated binaries using QEMU: + + # Build rv64gc toolchain with LLVM + ./configure --prefix=$RISCV --enable-llvm --enable-linux --with-arch=rv64gc --with-abi=lp64d + make -j$(nproc) all build-sim SIM=qemu + # Build C application with clang + $RISCV/bin/clang -march=rv64imafdc -o hello_world hello_world.c + $RISCV/bin/qemu-riscv64 ./hello-world + # Build C++ application with clang + $RISCV/bin/clang++ -march=rv64imafdc -stdlib=libc++ -o hello_world_cpp hello_world_cpp.cxx + $RISCV/bin/qemu-riscv64 ./hello-world_cpp + ### Development This section is only for developer or advanced user, or you want to build @@ -295,13 +326,14 @@ For example you have a gcc in `$HOME/gcc`, use `--with-gcc-src` can specify that Here is the list of configure option for specify source tree: - --with-gcc-src --with-binutils-src - --with-newlib-src - --with-glibc-src - --with-musl-src + --with-gcc-src --with-gdb-src + --with-glibc-src --with-linux-headers-src + --with-llvm-src + --with-musl-src + --with-newlib-src + --with-pk-src --with-qemu-src --with-spike-src - --with-pk-src |