Skip to content

Commit

Permalink
docs(ci): add some build docs (#4884)
Browse files Browse the repository at this point in the history
Description
Document some of the build process

Motivation and Context
For builds other than native, some info recorded to build others get a jump start.
  • Loading branch information
leet4tari authored Nov 30, 2022
1 parent b2370b1 commit 8455ce8
Show file tree
Hide file tree
Showing 7 changed files with 205 additions and 0 deletions.
1 change: 1 addition & 0 deletions .license.ignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
./base_layer/wallet/src/schema.rs
./base_layer/p2p/src/dns/roots/tls.rs
./buildtools/docker/torrc
./buildtools/vagrant/Vagrantfile
./docs/src/theme/book.js
./docs/src/theme/highlight.js
./integration_tests/Makefile
Expand Down
140 changes: 140 additions & 0 deletions buildtools/build-notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
## Build Notes we don't want to lose?

Build options:
- Native
- Docker
- Virtualised
- Emulated

# Building Linux x86_64 & ARM64

Using Vagrant and VirtualBox has a baseline for building needs, including tools, libs and testing

Linux ARM64 can be built using Vagrant and VirtualBox or Docker and cross

# Prep Ubuntu for development
# From - https://github.com/tari-project/tari/blob/development/scripts/install_ubuntu_dependencies.sh
```bash
sudo apt-get update
sudo apt-get install \
openssl \
libssl-dev \
pkg-config \
libsqlite3-dev \
clang-10 \
git \
cmake \
dh-autoreconf \
libc++-dev \
libc++abi-dev \
libprotobuf-dev \
protobuf-compiler \
libncurses5-dev \
libncursesw5-dev \
zip
```

# Prep Ubuntu for cross-compile aarch64/arm64 on x86_64
```bash
sudo apt-get install \
pkg-config-aarch64-linux-gnu \
gcc-aarch64-linux-gnu \
g++-aarch64-linux-gnu
```

# Install rust
```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```
# or unattended rust install
```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
```

```bash
source "$HOME/.cargo/env"
```

# Prep rust for cross-compile aarch64/arm64 on x86_64
```bash
rustup target add aarch64-unknown-linux-gnu
rustup toolchain install stable-aarch64-unknown-linux-gnu
```

# Check was tools chains rust has in place
```bash
rustup target list --installed
rustup toolchain list
```

# get/git the code base
```bash
mkdir -p ~/src
cd ~/src
git clone [email protected]:tari-project/tari.git
cd tari
```

# Needed for RandomX
```bash
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
export BINDGEN_EXTRA_CLANG_ARGS='--sysroot /usr/aarch64-linux-gnu/include/'
```
Sample of the errors seen, if the above envs are not set
```
Compiling randomx-rs v1.1.13 (https://github.com/tari-project/randomx-rs?tag=v1.1.13#c33f8679)
error: linking with `cc` failed: exit status: 1
|
= note: "cc" "-Wl,--version-script=/tmp/rustcsAUjg7/list" "/tmp/rustcsAUjg7/symbols.o" "/home/vagrant/src/tari/target/aarch64-unknown-linux-gnu/debug/deps/randomx_rs-aa21b69d885376e9.randomx_rs.a9fc037b-cgu.0.rcgu.o"
```
...
```
/usr/bin/ld: /home/vagrant/src/tari/target/aarch64-unknown-linux-gnu/debug/deps/randomx_rs-aa21b69d885376e9.randomx_rs.a9fc037b-cgu.0.rcgu.o: Relocations in generic ELF (EM: 183)
/home/vagrant/src/tari/target/aarch64-unknown-linux-gnu/debug/deps/randomx_rs-aa21b69d885376e9.randomx_rs.a9fc037b-cgu.0.rcgu.o: error adding symbols: File in wrong format
collect2: error: ld returned 1 exit status
error: could not compile `randomx-rs` due to previous error
warning: build failed, waiting for other jobs to finish...
```
Might not need these older envs
```
export AR_aarch64_unknown_linux_gnu=aarch64-linux-gnu-ar
export CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc
export CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++
```

# Needed in the past for croaring-sys
```bash
export ARCH=generic
export ROARING_ARCH=generic
export RUSTFLAGS='-C target_cpu=generic'
export CROSS_COMPILE=true
```

# Build Testing
```bash
cargo build \
--target aarch64-unknown-linux-gnu \
--bin tari_miner
```

# Build target Release
```bash
cargo build --locked \
--release --features safe \
--target aarch64-unknown-linux-gnu
```

# Using a single command line build using Docker
```bash
cross build --locked \
--release --features safe \
--target aarch64-unknown-linux-gnu
```
```bash
cross build --locked \
--release --features safe \
--target aarch64-unknown-linux-gnu \
--bin tari_base_node --bin tari_console_wallet \
--bin tari_merge_mining_proxy --bin tari_miner
```
2 changes: 2 additions & 0 deletions buildtools/vagrant/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.vagrant
*.log
41 changes: 41 additions & 0 deletions buildtools/vagrant/Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/bionic64"

# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false
config.vm.box_check_update = false

# https://subscription.packtpub.com/book/virtualization_and_cloud/9781786464910/1/ch01lvl1sec12/enabling-virtualbox-guest-additions-in-vagrant
# vagrant vbguest --status
# vagrant vbguest --do install
if Vagrant.has_plugin?("vagrant-vbguest") then
config.vbguest.auto_update = false
end

# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "../data", "/vagrant_data"

# virtualbox settings
config.vm.provider :virtualbox do |vb|
vb.cpus = 2
vb.memory = 5*1024
vb.gui = false
vb.linked_clone = true
end

# Enable provisioning with a shell script. Additional provisioners such as
# Ansible, Chef, Docker, Puppet and Salt are also available. Please see the
# documentation for more information about their specific syntax and use.
# config.vm.provision "shell", inline: <<-SHELL
# apt-get update
# apt-get install -y apache2
# SHELL
end
8 changes: 8 additions & 0 deletions scripts/install_ubuntu_dependencies-arm64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env sh
#
# Install Ubuntu aarch64/arm64 deb dev/tool packages on x86_64
#
apt-get -y install $* \
pkg-config-aarch64-linux-gnu \
gcc-aarch64-linux-gnu \
g++-aarch64-linux-gnu
7 changes: 7 additions & 0 deletions scripts/install_ubuntu_dependencies-rust-arm64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env sh
#
# Install rust target/toolchain for aarch64/arm64
#
export PATH="$HOME/.cargo/bin:$PATH"
rustup target add aarch64-unknown-linux-gnu
rustup toolchain install stable-aarch64-unknown-linux-gnu
6 changes: 6 additions & 0 deletions scripts/install_ubuntu_dependencies-rust.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env sh
#
# Install rust unattended - https://www.rust-lang.org/tools/install
#
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
export PATH="$HOME/.cargo/bin:$PATH"

0 comments on commit 8455ce8

Please sign in to comment.