Skip to content

Comments

Prepare to commit to gollvm#30

Draft
melonedo wants to merge 5 commits intoplctlab:gollvm-build-riscvfrom
melonedo:upstream-final
Draft

Prepare to commit to gollvm#30
melonedo wants to merge 5 commits intoplctlab:gollvm-build-riscvfrom
melonedo:upstream-final

Conversation

@melonedo
Copy link
Contributor

@melonedo melonedo commented Sep 2, 2022

The first two commits are already merged into gollvm master. The last commit is likely to be changed so will be committed individually.The other two commits are to be committed.

realqhc and others added 2 commits August 26, 2022 12:56
Add support for compiling gollvm for other arch by specifying GOLLVM_DRIVER_DIR to a prebuilt gollvm with two targets, and specify target, toolchain and sysroot in GOLLVM_EXTRA_GOCFLAGS.

Example usage:
RISCV=$HOME/toolchain
SOURCE=$HOME/llvm-project/llvm
TRIPLE=riscv64-unknown-linux-gnu

# host
cmake -G Ninja -S $SOURCE -B build-x86 \
    -DCMAKE_INSTALL_PREFIX=install-x86 \
    -DCMAKE_BUILD_TYPE=Debug \
    -DLLVM_USE_LINKER=bfd \
    -DGOLLVM_DEFAULT_LINKER=bfd \
    -DLLVM_TARGET_ARCH="X86-64,RISCV64" \
    -DLLVM_TARGETS_TO_BUILD="X86;RISCV"

# crosscompile
cmake -G Ninja -S $SOURCE -B build-riscv \
    -DCMAKE_INSTALL_PREFIX=$INSTALL \
    -DCMAKE_BUILD_TYPE=Debug \
    -DLLVM_USE_LINKER=bfd \
    -DGOLLVM_DEFAULT_LINKER=bfd \
    -DCMAKE_CROSSCOMPILING=True \
    -DLLVM_TARGET_ARCH=RISCV64 \
    -DLLVM_DEFAULT_TARGET_TRIPLE=$TRIPLE \
    -DLLVM_TARGETS_TO_BUILD=RISCV \
    -DCMAKE_C_COMPILER=$RISCV/bin/$TRIPLE-gcc \
    -DCMAKE_CXX_COMPILER=$RISCV/bin/$TRIPLE-g++ \
    -DLLVM_TABLEGEN=$PWD/build-x86/bin/llvm-tblgen \
    -DGOLLVM_DRIVER_DIR=$PWD/build-x86/bin \
    -DGOLLVM_EXTRA_GOCFLAGS="--target=$TRIPLE \
                             --gcc-toolchain=$RISCV/ \
                             --sysroot=$RISCV/sysroot" \
    -DGOLLVM_USE_SPLIT_STACK=OFF \
    -DCMAKE_C_FLAGS=-latomic \
    -DCMAKE_CXX_FLAGS=-latomic

 # build gollvm crosscompiler
 ninja -C build-x86 llvm-goc llvm-goc-token llvm-godumpspec

 # cross compile gollvm, go tools and install
 ninja -C build-riscv install-gollvm

Change-Id: Ie4997771fd21437f65d857b7aaae267b7a394f23
Reviewed-on: https://go-review.googlesource.com/c/gollvm/+/425199
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Currently, architecture information is passed to the compiler but not
the integrated assembler, causing discrepancies in the ABI chosen by
the two tools, especially on the RISC-V platform.

This patch makes sure both share the same architecture information.

Change-Id: I29f441e86e06f1f0b46c3ea62576a7d1291c2ce4
Reviewed-on: https://go-review.googlesource.com/c/gollvm/+/425854
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
@melonedo melonedo force-pushed the upstream-final branch 2 times, most recently from c1aec5f to 773e89c Compare September 2, 2022 14:21
This patch adds relevant flags for builoding on RISC-V linux platform, its C-ABI setup is on another patch.

Change-Id: Ibfe22aabb7a6718ccf3e55c6cc35f70953d972d4
This patch sets up the C-ABI oracle for the RISC-V linux platform.

The main changes are:

1. The C calling convention is used to identify this platform.
2. C-ABI oracle and compile options are set for RISC-V linux.
3. The ABI is hardcoded as lp64d on RISC-V linux.

Change-Id: I640cd7dbaf7d7efb6abdba93a04e9b9a37244eca
The check_xxx_tool tests fail immediately because go.mod is not present in the test directory.
This patch copies these files to enable them but relies on the existence of go.sum, is there a better way?

Change-Id: Ibb67d5bd687da3ca6e3ee63f4d787c1fc468e6ab
@melonedo
Copy link
Contributor Author

melonedo commented Sep 3, 2022

Commit titles and descriptions are updated.

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.

2 participants