<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/59396>59396</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[libc][RISC-V] Building llvmlib for RISC-V
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
alyona-eryomina
</td>
</tr>
</table>
<pre>
Hello!
I try to build libc for RISC-V:
```
cmake ../llvm -G "Unix Makefiles" -DLLVM_ENABLE_PROJECTS="libc" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/opt/riscv/bin/clang -DCMAKE_CXX_COMPILER=/opt/riscv/bin/clang++ -DCMAKE_C_FLAGS="--target=riscv64 -march=rv64gc --sysroot=/opt/riscv/riscv64-unknown-elf --gcc-toolchain=/opt/riscv" -DCMAKE_CXX_FLAGS="--target=riscv64 -march=rv64gc --sysroot=/opt/riscv/riscv64-unknown-elf --gcc-toolchain=/opt/riscv"
```
But I get error
```
CMake Error at /home/user/llvm-project/libc/cmake/modules/LLVMLibCCheckCpuFeatures.cmake:83 (message):
Failed to compile: Change Dir:
/home/user/llvm-project/build/projects/libc/check_/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_21f05/fast &&
/usr/bin/gmake -f CMakeFiles/cmTC_21f05.dir/build.make
CMakeFiles/cmTC_21f05.dir/build
gmake[1]: Entering directory
'/home/user/llvm-project/build/projects/libc/check_/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_21f05.dir/check_cpu_features.cpp.o
/opt/riscv/bin/clang++ --target=riscv64 -march=rv64gc
--sysroot=/opt/riscv/riscv64-unknown-elf --gcc-toolchain=/opt/riscv -fPIC
-fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic
-Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion
-Wmisleading-indentation -Wctad-maybe-unsupported -ffunction-sections
-fdata-sections -O3 -DNDEBUG -march=native -std=c++17 -MD -MT
CMakeFiles/cmTC_21f05.dir/check_cpu_features.cpp.o -MF
CMakeFiles/cmTC_21f05.dir/check_cpu_features.cpp.o.d -o
CMakeFiles/cmTC_21f05.dir/check_cpu_features.cpp.o -c
/home/user/llvm-project/build/projects/libc/cpu_features/check_cpu_features.cpp
clang-16: error: invalid arch name 'native', string must begin with
rv32{i,e,g} or rv64{i,g}
gmake[1]: *** [CMakeFiles/cmTC_21f05.dir/build.make:79:
CMakeFiles/cmTC_21f05.dir/check_cpu_features.cpp.o] Error 1
gmake[1]: Leaving directory
'/home/user/llvm-project/build/projects/libc/check_/CMakeFiles/CMakeTmp'
gmake: *** [Makefile:127: cmTC_21f05/fast] Error 2
Call Stack (most recent call first):
/home/user/llvm-project/libc/CMakeLists.txt:136 (include)
```
It looks like libc doesn't support RISC-V and try to build this one for x86.
I saw other issues about this problem in your github, but I can't find anything
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEV0Fz27oR_jXQZQcaCbQk66CDRJqpW_kl4zhP6ckDEksKNQiwAChb_fUdgLQsvZc0nqadzNDWAFjsfrv4drHgzslaI67IbENm2Yh3fm_siquj0ZyiPZpGaj4qjDiu_oJKGcKmZJKRyfoWvD2CN1B0UglQsiihMhbubz-n9HeSrHsxMp8MXxyWDX9CGI8Jy5U6NEA_AGHsi5YvcMefsJIKHWEMaLbd_n73ePPberO9efx0__GvN-nDZ5JkhLFgqpdJ79Z_u3ncfLndZo8Pf_90Q5LsHhVyh6fF9DH9ePfpdntzHzfnpvWE5Va68kBYXkhNWF4qruu3HV-_vncPYRvCNme28u36w4CSUs9tjZ4kWdw5vwLacFv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