[llvm-dev] Building compiler-rt for RISC-V?

Thomas Goodfellow via llvm-dev llvm-dev at lists.llvm.org
Wed Oct 20 06:40:43 PDT 2021


A very belated thanks and follow-up to your helpful mail:

Building standalone worked, but it feels inelegant to need the GCC RISCV
toolchain present for building the LLVM equivalent (at least in shallow
experiments it seems that the --gcc-toolchain really needs to point at a
cross-target gcc). Is it planned that the build becomes self-sufficient?

Thanks,
Tom


On Wed, 28 Jul 2021 at 13:24, Luís Marques <luismarques at lowrisc.org> wrote:

> On Tue, Jul 27, 2021 at 11:51 AM Thomas Goodfellow via llvm-dev
> <llvm-dev at lists.llvm.org> wrote:
> > however although that yields the RISCV compiler target libraries
> (libLLVMRISCV*.a) it doesn't install any obvious RISCV runtime libraries
> (only x86 ones) and linking a test program with integer division fails
>
> When compiling compiler-rt standalone (instead of as part of the
> overall LLVM build) I have in the past used the following for the
> rv32i build:
>
> FLAGS="--target=riscv32-unknown-elf -march=rv32i -mabi=ilp32
> --gcc-toolchain=$GCC_TOOLCHAIN --sysroot=$SYSROOT"
> TEST_FLAGS="$FLAGS"
>
> cmake $LLVM/compiler-rt \
>   -G "Ninja" \
>   -DCOMPILER_RT_BUILD_BUILTINS=ON \
>   -DCOMPILER_RT_BUILD_SANITIZERS=OFF \
>   -DCOMPILER_RT_BUILD_XRAY=OFF \
>   -DCOMPILER_RT_BUILD_LIBFUZZER=OFF \
>   -DCOMPILER_RT_BUILD_PROFILE=OFF \
>   -DCMAKE_C_COMPILER=$LLVM_BUILD/bin/clang \
>   -DCMAKE_AR=$LLVM_BUILD/bin/llvm-ar \
>   -DCMAKE_NM=$LLVM_BUILD/bin/llvm-nm \
>   -DCMAKE_RANLIB=$LLVM_BUILD/bin/llvm-ranlib \
>   -DCMAKE_C_COMPILER_TARGET="riscv32-unknown-elf" \
>   -DCMAKE_ASM_COMPILER_TARGET="riscv32-unknown-elf" \
>   -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \
>   -DCMAKE_C_FLAGS="$FLAGS" \
>   -DCMAKE_ASM_FLAGS="$FLAGS" \
>   -DCOMPILER_RT_OS_DIR="baremetal" \
>   -DCOMPILER_RT_BAREMETAL_BUILD=ON \
>   -DCOMPILER_RT_INCLUDE_TESTS=ON \
>   -DCOMPILER_RT_EMULATOR="qemu-riscv32 -L $SYSROOT" \
>   -DCOMPILER_RT_TEST_COMPILER="$LLVM_BUILD/bin/clang" \
>   -DCOMPILER_RT_TEST_COMPILER_CFLAGS="$TEST_FLAGS" \
>   -DLLVM_CONFIG_PATH=$LLVM_CONFIG
>
> For compiling Compiler-RT as part of an integrated LLVM build, IIRC
> you want to add it to the runtimes list (LLVM_ENABLE_RUNTIMES) and not
> as a subproject. You can use cmake cache files to configure the
> runtimes, and LLVM/compiler-rt has a weird setup for parsing cmake
> settings of the form RUNTIMES_${target}_*. Check the existing cmake
> cache files.
>
> I hope that helps.
>
> Best,
> Luís
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20211020/a36a131e/attachment.html>


More information about the llvm-dev mailing list