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

Upstream riscv64 #25

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Upstream riscv64 #25

wants to merge 2 commits into from

Conversation

realqhc
Copy link
Collaborator

@realqhc realqhc commented Aug 21, 2022

Please check! packed up for upstream

Add support for compiling gollvm for other arch by specifying GOLLVM_DRIVER_DIR to a prebuilt gollvm with two targets, and folders of crosscompiler by -L, -I in GOLLVM_EXTRA_GOCFLAGS.

Example usage:
cmake -Wno-dev -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CROSSCOMPILING=True -DLLVM_DEFAULT_TARGET_TRIPLE=riscv64-unknown-linux-gnu -DGOLLVM_USE_SPLIT_STACK=OFF -DLLVM_TARGET_ARCH=RISCV64 -DLLVM_TARGETS_TO_BUILD=RISCV -DCMAKE_C_COMPILER=/opt/riscv/bin/riscv64-unknown-linux-gnu-gcc -DCMAKE_CXX_COMPILER=/opt/riscv/bin/riscv64-unknown-linux-gnu-g++ -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=-latomic -DCMAKE_CXX_FLAGS=-latomic -DCMAKE_INSTALL_PREFIX=/tmp/gollvm-install -DLLVM_USE_LINKER=bfd -DGOLLVM_DEFAULT_LINKER=bfd -DLLVM_TABLEGEN=../build-x86/bin/llvm-tblgen -DCLANG_TABLEGEN=../build-x86/clang-tblgen -DGOLLVM_DRIVER_DIR=../build-x86/bin -DGOLLVM_EXTRA_GOCFLAGS="--target=riscv64-unknown-linux-gnu --gcc-toolchain=/opt/riscv/bin --sysroot=/opt/riscv/sysroot -I /opt/riscv/sysroot/usr/lib64/lp64d -I /opt/riscv/riscv64-unknown-linux-gnu/bin -I /opt/riscv/lib/gcc/riscv64-unknown-linux-gnu/11.1.0 -L/opt/riscv/bin" -G Ninja

Change-Id: I557df1ea8e69d4dadaa6c64b7ebc076393d4c530
co-authored with Funan Zeng, Xufan Lu
This CL adds linux riscv64 support for Gollvm, with this patch we can build and
run Go programs with Gollvm on linux riscv64.

The main changes include:
1, RISC-V C ABI implementation.
2, port existing unit test cases on amd64 to risc-v.

It should be emphasized that since ld.gold does not support risc-v, we must specify force cmake to use ld.bfd, and add cmake parameter -DGOLLVM_USE_SPLIT_STACK=OFF
when building.

Change-Id: Iad7779cdd0c3c62611d992d3e2fc8b50a536cc95
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant