<div dir="ltr"><div dir="ltr"><div>A very belated thanks and follow-up to your helpful mail:<br></div><div><br></div><div></div><div>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?<br></div><div><br></div><div>Thanks,</div><div>Tom</div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 28 Jul 2021 at 13:24, Luís Marques <<a href="mailto:luismarques@lowrisc.org" target="_blank">luismarques@lowrisc.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Tue, Jul 27, 2021 at 11:51 AM Thomas Goodfellow via llvm-dev<br>
<<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
> 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<br>
<br>
When compiling compiler-rt standalone (instead of as part of the<br>
overall LLVM build) I have in the past used the following for the<br>
rv32i build:<br>
<br>
FLAGS="--target=riscv32-unknown-elf -march=rv32i -mabi=ilp32<br>
--gcc-toolchain=$GCC_TOOLCHAIN --sysroot=$SYSROOT"<br>
TEST_FLAGS="$FLAGS"<br>
<br>
cmake $LLVM/compiler-rt \<br>
  -G "Ninja" \<br>
  -DCOMPILER_RT_BUILD_BUILTINS=ON \<br>
  -DCOMPILER_RT_BUILD_SANITIZERS=OFF \<br>
  -DCOMPILER_RT_BUILD_XRAY=OFF \<br>
  -DCOMPILER_RT_BUILD_LIBFUZZER=OFF \<br>
  -DCOMPILER_RT_BUILD_PROFILE=OFF \<br>
  -DCMAKE_C_COMPILER=$LLVM_BUILD/bin/clang \<br>
  -DCMAKE_AR=$LLVM_BUILD/bin/llvm-ar \<br>
  -DCMAKE_NM=$LLVM_BUILD/bin/llvm-nm \<br>
  -DCMAKE_RANLIB=$LLVM_BUILD/bin/llvm-ranlib \<br>
  -DCMAKE_C_COMPILER_TARGET="riscv32-unknown-elf" \<br>
  -DCMAKE_ASM_COMPILER_TARGET="riscv32-unknown-elf" \<br>
  -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \<br>
  -DCMAKE_C_FLAGS="$FLAGS" \<br>
  -DCMAKE_ASM_FLAGS="$FLAGS" \<br>
  -DCOMPILER_RT_OS_DIR="baremetal" \<br>
  -DCOMPILER_RT_BAREMETAL_BUILD=ON \<br>
  -DCOMPILER_RT_INCLUDE_TESTS=ON \<br>
  -DCOMPILER_RT_EMULATOR="qemu-riscv32 -L $SYSROOT" \<br>
  -DCOMPILER_RT_TEST_COMPILER="$LLVM_BUILD/bin/clang" \<br>
  -DCOMPILER_RT_TEST_COMPILER_CFLAGS="$TEST_FLAGS" \<br>
  -DLLVM_CONFIG_PATH=$LLVM_CONFIG<br>
<br>
For compiling Compiler-RT as part of an integrated LLVM build, IIRC<br>
you want to add it to the runtimes list (LLVM_ENABLE_RUNTIMES) and not<br>
as a subproject. You can use cmake cache files to configure the<br>
runtimes, and LLVM/compiler-rt has a weird setup for parsing cmake<br>
settings of the form RUNTIMES_${target}_*. Check the existing cmake<br>
cache files.<br>
<br>
I hope that helps.<br>
<br>
Best,<br>
Luís<br>
</blockquote></div>
</div>