Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RISC-V compiler-rt with no dependency on GCC ? #92714

Open
ihiasi opened this issue May 20, 2024 · 1 comment
Open

RISC-V compiler-rt with no dependency on GCC ? #92714

ihiasi opened this issue May 20, 2024 · 1 comment

Comments

@ihiasi
Copy link

ihiasi commented May 20, 2024

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.

@llvmbot
Copy link
Collaborator

llvmbot commented May 20, 2024

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

Author: Ionut Hristodorescu (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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants