Skip to content

Commit

Permalink
chore(ci): add riscv64 builds and misc script fixes (#6611)
Browse files Browse the repository at this point in the history
Description
Bump rcgen crate (removes ring v0.16)
Extend cross-compile scripts to support riscv64
Add make to build system, ubuntu 20.04 and above don't include by
default.

Motivation and Context
Add working riscv64 builds - enabled by default

How Has This Been Tested?
Builds locally, both emulated and cross-compile for riscv64
  • Loading branch information
leet4tari authored Oct 8, 2024
1 parent 283d184 commit 4ee8ae8
Show file tree
Hide file tree
Showing 10 changed files with 154 additions and 66 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/build_binaries.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"rust": "stable",
"target": "aarch64-unknown-linux-gnu",
"cross": true,
"flags": "--workspace --exclude minotari_mining_helper_ffi --exclude tari_integration_tests",
"flags": "--features libtor --workspace --exclude minotari_mining_helper_ffi --exclude tari_integration_tests",
"build_metric": true
},
{
Expand All @@ -22,13 +22,15 @@
"rust": "stable",
"target": "riscv64gc-unknown-linux-gnu",
"cross": true,
"flags": "--workspace --exclude minotari_mining_helper_ffi --exclude tari_integration_tests",
"features": "safe",
"flags": "--features libtor --workspace --exclude minotari_mining_helper_ffi --exclude tari_integration_tests",
"build_metric": true,
"build_enabled": true,
"best_effort": true
},
{
"name": "macos-x86_64",
"runs-on": "macos-12",
"runs-on": "macos-13",
"rust": "stable",
"target": "x86_64-apple-darwin",
"cross": false
Expand Down Expand Up @@ -58,6 +60,7 @@
"features": "safe",
"target_bins": "minotari_node, minotari_console_wallet, minotari_merge_mining_proxy, minotari_miner",
"flags": "--workspace --exclude tari_libtor",
"build_enabled": false
"build_enabled": true,
"best_effort": true
}
]
1 change: 1 addition & 0 deletions .github/workflows/build_binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ jobs:
# Should already be installed
# choco upgrade strawberryperl -y
choco upgrade protoc -y
rustup target add ${{ matrix.builds.target }}
- name: Set environment variables - Nix
if: ${{ ! startsWith(runner.os,'Windows') }}
Expand Down
41 changes: 10 additions & 31 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions Cross.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ passthrough = [
"CARGO_BUILD_TARGET",
"TARGET_CFLAGS",
"CC_aarch64_unknown_linux_gnu",
"CC_riscv64_unknown_linux_gnu",
"PKG_CONFIG_SYSROOT_DIR",
"PKG_CONFIG_ALLOW_CROSS",
"RUSTFLAGS",
Expand Down Expand Up @@ -72,3 +73,20 @@ passthrough = [
[target.x86_64-unknown-linux-gnu]
image = "ubuntu:18.04"
pre-build = "./scripts/cross_compile_ubuntu_18-pre-build.sh"

[target.x86_64-unknown-linux-gnu.env]
passthrough = [
"PKG_CONFIG_ALLOW_CROSS=true",
]

[target.riscv64gc-unknown-linux-gnu]
#image.name = "riscv64/ubuntu:22.04"
#image.toolchain = ["linux/riscv64=riscv64-unknown-linux-gnu", "linux/arm64=aarch64-unknown-linux-gnu", "linux/amd64=x86_64-unknown-linux-gnu"]
image.name = "ubuntu:22.04"
image.toolchain = ["linux/arm64=aarch64-unknown-linux-gnu", "linux/amd64=x86_64-unknown-linux-gnu", "linux/riscv64=riscv64gc-unknown-linux-gnu"]
pre-build = "./scripts/cross_compile_ubuntu_18-pre-build.sh"

[target.riscv64gc-unknown-linux-gnu.env]
passthrough = [
"PKG_CONFIG_ALLOW_CROSS=true",
]
2 changes: 1 addition & 1 deletion applications/minotari_app_grpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ log = "0.4"
prost = "0.13.3"
prost-types = "0.13.3"
rand = "0.8"
rcgen = "0.11.3"
rcgen = "0.12.1"
subtle = "2.5.0"
thiserror = "1"
tokio = { version = "1.36", features = ["fs"] }
Expand Down
4 changes: 1 addition & 3 deletions applications/minotari_app_grpc/src/tls/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@

use std::io;

use rcgen::RcgenError;

#[derive(Debug, thiserror::Error)]
pub enum GrpcTlsError {
#[error("Couldn't read file: {0}")]
FileReadError(String),
#[error("Error generating the certificate: {0}")]
CertGenerationError(#[from] RcgenError),
CertGenerationError(#[from] rcgen::Error),
#[error("Error opening or writing the file: {0}")]
IoError(#[from] io::Error),
}
1 change: 0 additions & 1 deletion applications/minotari_app_utilities/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ thiserror = "^1.0.26"
dialoguer = { version = "0.10" }
tonic = "0.12.3"


[build-dependencies]
tari_common = { path = "../../common", features = [
"build",
Expand Down
73 changes: 55 additions & 18 deletions scripts/cross_compile_ubuntu_18-pre-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,69 @@

set -e

USAGE="Usage: $0 target build ie: x86_64-unknown-linux-gnu or aarch64-unknown-linux-gnu"
# APT Proxy for quicker testing
#export HTTP_PROXY_APT=http://apt-proxy.local:3142
if [ ! -z "${HTTP_PROXY_APT}" ] && [ -d "/etc/apt/apt.conf.d/" ]; then
echo "Setup apt proxy - ${HTTP_PROXY_APT}"
cat << APT-EoF > /etc/apt/apt.conf.d/proxy.conf
Acquire {
HTTP::proxy "${HTTP_PROXY_APT}";
#HTTPS::proxy "http://127.0.0.1:8080";
}
APT-EoF
fi

USAGE="Usage: $0 {target build}
where target build is one of the following:
x86_64-unknown-linux-gnu or
aarch64-unknown-linux-gnu or
riscv64gc-unknown-linux-gnu
"

if [ "$#" == "0" ]; then
echo "$USAGE"
echo -e "${USAGE}"
exit 1
fi

if [ -z "${CROSS_DEB_ARCH}" ]; then
echo "Should be run from cross, which sets the env CROSS_DEB_ARCH"
echo -e "Should be run from cross, which sets the env 'CROSS_DEB_ARCH'
amd64
arm64
riscv64
"
exit 1
fi

DEBIAN_FRONTEND=${DEBIAN_FRONTEND:-noninteractive}
# Hack of Note!
TimeZone=${TimeZone:-"Etc/GMT"}
ln -snf /usr/share/zoneinfo/${TimeZone} /etc/localtime
echo ${TimeZone} > /etc/timezone

targetBuild="${1}"
nativeRunTime=$(uname -m)
echo "Native RunTime is ${nativeRunTime}"

if [ "${nativeRunTime}" == "x86_64" ]; then
nativeArch=amd64
if [ "${targetBuild}" == "aarch64-unknown-linux-gnu" ]; then
targetArch=arm64
targetPlatform=aarch64
else
targetArch=amd64
targetPlatform=x86-64
fi
elif [ "${nativeRunTime}" == "aarch64" ]; then
nativeArch=arm64
if [ "${targetBuild}" == "x86_64-unknown-linux-gnu" ]; then
targetArch=amd64
targetPlatform=x86-64
fi
elif [ "${nativeRunTime}" == "riscv64" ]; then
nativeArch=riscv64
echo "ToDo!"
else
echo "!!Unsupport platform!!"
exit 1
fi

if [ "${targetBuild}" == "aarch64-unknown-linux-gnu" ]; then
targetArch=arm64
targetPlatform=aarch64
elif [ "${targetBuild}" == "x86_64-unknown-linux-gnu" ]; then
targetArch=amd64
targetPlatform=x86-64
elif [ "${targetBuild}" == "riscv64gc-unknown-linux-gnu" ]; then
targetArch=riscv64
targetPlatform=riscv64
else
echo "!!Unsupport platform!!"
exit 1
Expand All @@ -63,6 +92,7 @@ apt-get install --no-install-recommends --assume-yes \
libsqlite3-0 \
libreadline-dev \
git \
make \
cmake \
dh-autoreconf \
clang \
Expand Down Expand Up @@ -91,7 +121,7 @@ if [ "${CROSS_DEB_ARCH}" != "${nativeArch}" ]; then
. /etc/lsb-release
ubuntu_tag=${DISTRIB_CODENAME}

if [ "${crossArch}" == "arm64" ]; then
if [[ "${crossArch}" =~ ^(arm|riscv)64$ ]]; then
cat << EoF > /etc/apt/sources.list.d/${ubuntu_tag}-${crossArch}.list
deb [arch=${crossArch}] http://ports.ubuntu.com/ubuntu-ports ${ubuntu_tag} main restricted universe multiverse
# deb-src [arch=${crossArch}] http://ports.ubuntu.com/ubuntu-ports ${ubuntu_tag} main restricted universe multiverse
Expand Down Expand Up @@ -143,24 +173,31 @@ deb [arch=amd64] http://security.ubuntu.com/ubuntu/ ${ubuntu_tag}-security multi
EoF
fi

dpkg --print-architecture
dpkg --add-architecture ${CROSS_DEB_ARCH}
dpkg --print-architecture
apt-get update

# scripts/install_ubuntu_dependencies-cross_compile.sh x86-64
# pkg-config-${targetPlatform}-linux-gnu \
apt-get --assume-yes install \
pkg-config-${targetPlatform}-linux-gnu \
gcc-${targetPlatform}-linux-gnu \
g++-${targetPlatform}-linux-gnu

# packages needed for Ledger and hidapi
apt-get --assume-yes install \
libudev-dev:${CROSS_DEB_ARCH} \
libhidapi-dev:${CROSS_DEB_ARCH}
libhidapi-dev:${CROSS_DEB_ARCH} \
libssl-dev:${CROSS_DEB_ARCH}

fi

rustup show

rustup target add ${targetBuild}
rustup toolchain install stable-${targetBuild} --force-non-host

rustup target list --installed
rustup toolchain list

rustup show
Loading

0 comments on commit 4ee8ae8

Please sign in to comment.