llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[libc][RISC-V] Building llvmlib for RISC-V

Open alyona-eryomina opened this issue 3 years ago • 5 comments

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

alyona-eryomina avatar Dec 08 '22 12:12 alyona-eryomina

Also, I had stydied to build clang for building RISC-V

alyona-eryomina avatar Dec 08 '22 12:12 alyona-eryomina

@llvm/issue-subscribers-backend-risc-v

llvmbot avatar Dec 08 '22 16:12 llvmbot

@llvm/issue-subscribers-libc

llvmbot avatar Dec 08 '22 16:12 llvmbot

Yes, the libc doesn't yet support RISC-V.

sivachandra avatar Dec 08 '22 17:12 sivachandra

This seems to be a duplicate of #57581.

jobnoorman avatar Feb 10 '23 10:02 jobnoorman