-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(ci): add some build docs (#4884)
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
Showing
7 changed files
with
205 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.vagrant | ||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |