[llvm-dev] Building compiler-rt for RISC-V?
Luís Marques via llvm-dev
llvm-dev at lists.llvm.org
Wed Jul 28 04:24:13 PDT 2021
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
More information about the llvm-dev
mailing list