Issue 92714
Summary RISC-V compiler-rt with no dependency on GCC ?
Labels new issue
Assignees
Reporter ihiasi
    Hi - I am trying to build compiler-rt for RISC-V with no dependency on the GCC toolchain. Ideally, for bare metal development, but I'll take Linux as well if bare metal is not possible yet :). 
I am on an Apple Silicon M1 MacMini, latest LLVM checkout (as of sometimes around May10th 2024) and my cmake config is : 
```
export CMAKE_APPLE_SILICON_PROCESSOR=arm64 && cmake -GXcode -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_INSTALL_PREFIX=~/install \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_STANDARD=17 \
-DCMAKE_OSX_ARCHITECTURES=arm64 \
-DLLVM_ENABLE_PROJECTS="clang;lld;lldb;lldb;pstl;libc" \
-DLLVM_ENABLE_RUNTIMES="libcxx;libc;libunwind;compiler-rt" \
-DLLVM_BUILD_EXTERNAL_COMPILER_RT=ON \
-DCOMPILER_RT_DEFAULT_TARGET_TRIPLE="riscv64-unknown-elf" \
-DLLVM_DEFAULT_TARGET_TRIPLE="riscv64-unknown-elf" \
-DLLVM_TARGETS_TO_BUILD="RISCV" \
-DCOMPILER_RT_BAREMETAL_BUILD=ON \
-DLLVM_LINK_LLVM_DYLIB=ON \
-DBUILTINS_CMAKE_ARGS=-DLLVM_CMAKE_DIR=~/work/llvm-project/build/ \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_ENABLE_RTTI=OFF \
-DLLVM_ENABLE_EH=OFF  \
-DLLVM_LIT_ARGS=-v \
-DLLDB_USE_SYSTEM_DEBUGSERVER=ON \
-DLLVM_PARALLEL_LINK_JOBS=1 \
../llvm
```
I used BUILTINS_CMAKE_ARGS to point to the newly built clang (after I read various LLVM Discord articles and StackOverflow and Github issues here) but it seems like Xcode still tries to use the system toolchain (in /Applications/Xcode) instead : 
```
...
Showing All Messages
-- The C compiler identification is AppleClang 15.0.0.15000309
-- The CXX compiler identification is AppleClang 15.0.0.15000309
-- The ASM compiler identification is Clang with GNU-like command-line
...
```
I am using `musl` instead of `libc` : 
```
./Debug/bin/clang --target=riscv64 -march=rv64g -I~/work/musl/build/include -L~/work/musl/build/lib -o ../test ../test.c
ld.lld: error: cannot open ~/work/llvm-project/build/Debug/bin/../lib/clang-runtimes/riscv64/lib/libclang_rt.builtins.a: No such file or directory
clang: error: ld.lld command failed with exit code 1 (use -v to see invocation)
```
Two questions : 
1. is it possible to build compiler-rt with no dependency on the GCC toolchain ?
2. if the answer to 1 is YES, what is the cmake configuration I should use ? 

Thank you. 
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to