Issue 126229
Summary Building llvm libc for an arbitrary RISC-V architecture string
Labels libc
Assignees
Reporter christian-herber-nxp
    RISC-V has many optional extensions, and I currently have no clue how to specify these in a libc build.
I have an easy to reproduce setup. After cloning the llvm project, I run this script from the root directory:

```
#!/usr/bin/env bash

rm -rf build-standalone
mkdir build-standalone
pushd build-standalone

C_COMPILER=clang-19
C_FLAGS="--target=riscv32 -march=rv32ic -mabi=ilp32"
CXX_COMPILER=clang++-19
TARGET_TRIPLE=riscv32-unknown-elf
cmake ../runtimes \
   -G Ninja \
   -DCMAKE_INSTALL_PREFIX=$(pwd)/install \
 -DCMAKE_C_COMPILER=$C_COMPILER \
   "-DCMAKE_C_FLAGS=${C_FLAGS}" \
 "-DCMAKE_CXX_FLAGS=${C_FLAGS}" \
   -DCMAKE_CXX_COMPILER=$CXX_COMPILER \
   -DLLVM_ENABLE_RUNTIMES=libc \
   -DLLVM_LIBC_FULL_BUILD=ON \
 -DLIBC_TARGET_TRIPLE=$TARGET_TRIPLE \
   -DCMAKE_BUILD_TYPE=Release
ninja libc libm
popd
```
Clang was installed with the following command:

`wget -qO-  | bash -s -- 19https://apt.llvm.org/llvm.sh`
It fails with the following message:


```
    Run Build Command(s):/usr/bin/ninja cmTC_95cfc && [1/2] Building C object CMakeFiles/cmTC_95cfc.dir/testCCompiler.c.o
    [2/2] Linking C executable cmTC_95cfc
    FAILED: cmTC_95cfc 
    : && /usr/bin/clang-19 --target=riscv32 -march=rv32ic -mabi=ilp32 CMakeFiles/cmTC_95cfc.dir/testCCompiler.c.o -o cmTC_95cfc   && :
    ld.lld: error: unable to find library -lc
    ld.lld: error: unable to find library -lm
    ld.lld: error: unable to find library -lgcc
```
If you omit the CLAGS, it successfully builds for seemingly rv32ic.
Somebody knows how to do build for a user specified architecture string?
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to