Skip to content

Commit

Permalink
i#3544 RV64: Add docs on cross-compiling for RISCV64 on Linux (Dynamo…
Browse files Browse the repository at this point in the history
…RIO#6813)

1. Add docs on cross-compiling building commands for RISCV64 on Linux.
2. Fix some typos.

Issue: DynamoRIO#3544
  • Loading branch information
chenhy0106 authored May 17, 2024
1 parent 47ae98b commit aea7bc0
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci-riscv64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ jobs:
# Install cross-compiler for cross-compiling Linux build.
# Unfortunately there are no libunwind or compression cross-compile
# packages so we unpack the native versions and copy their files.
# Unfortunately, only kinetic (ubuntu 22.10) has linunwind-riscv64 packages.
# I prefer debian-ports here, it is more close to upstream.
# Unfortunately, only kinetic (ubuntu 22.10) has libunwind-riscv64 packages.
# I prefer debian-ports here, it is closer to upstream.
- name: Create Build Environment
run: |
sudo apt-get update
Expand Down
38 changes: 37 additions & 1 deletion api/docs/building.dox
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ If you wish to run the test suite, you should enable BUILD_TESTS.

## Cross-Compiling for 64-bit ARM (AArch64) on Linux

Install the cross compiler for the `gnueabihf` target:
Install the cross compiler for the `gnu` target:

```
$ sudo apt-get install g++-aarch64-linux-gnu
Expand Down Expand Up @@ -247,6 +247,42 @@ To build a client, again use the toolchain file, as well as pointing at a Dynamo

----------------

## Cross-Compiling for 64-bit RISC-V (RISCV64) on Linux

Prepare cross-compiling environment for RISCV64:

```
$ sudo apt-get -y install doxygen vera++ cmake crossbuild-essential-riscv64 git
```

Some packages may need to be manually installed for cross-compiling environment. You can also refer to our [CI workflow file](https://github.com/DynamoRIO/dynamorio/blob/master/.github/workflows/ci-riscv64.yml) for creating a RISCV64 build environment.

```
$ sudo add-apt-repository 'deb [trusted=yes arch=riscv64] http://deb.debian.org/debian sid main'
$ apt download libunwind8:riscv64 libunwind-dev:riscv64 liblzma5:riscv64 zlib1g:riscv64 zlib1g-dev:riscv64 libsnappy1v5:riscv64 libsnappy-dev:riscv64 liblz4-1:riscv64 liblz4-dev:riscv64
$ mkdir ../extract
$ for i in *.deb; do dpkg-deb -x $i ../extract; done
$ for i in include lib; do sudo rsync -av ../extract/usr/${i}/riscv64-linux-gnu/ /usr/riscv64-linux-gnu/${i}/; done
$ sudo rsync -av ../extract/usr/include/ /usr/riscv64-linux-gnu/include/
$ if test -e "../extract/lib/riscv64-linux-gnu/"; then \
sudo rsync -av ../extract/lib/riscv64-linux-gnu/ /usr/riscv64-linux-gnu/lib/; \
fi
```

Check out the sources as normal, and point at our toolchain CMake file:

```
$ git clone --recurse-submodules -j4 https://github.com/DynamoRIO/dynamorio.git
$ mkdir build_riscv64
$ cd build_riscv64
$ cmake -DCMAKE_TOOLCHAIN_FILE=../dynamorio/make/toolchain-riscv64.cmake ../dynamorio
$ make -j
```

To build a client, again use the toolchain file, as well as pointing at a DynamoRIO installation using `-DDynamoRIO_DIR=<path>` as described in the package documentation.

----------------

## Cross-Compiling for ARM Android

Install the Android NDK (Note: currently only version r10e can be used to build DynamoRIO, later versions do not work, see #1927, #2556)and configure it for the androideabi standalone toolchain. Something like this:
Expand Down

0 comments on commit aea7bc0

Please sign in to comment.