-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(fix): improve cross-compile, add x86_64 target from aarch64 (#6352)
Description Move the cross-rs image setup into a shared script, should improve support for cross compiling to Linux Bump macos build host from 11 to 12 Remove macos install packages that are pre-install, keep a note Bump protobuf to 26.1 for Android ffis builds with cross-rs Add the default ```CFLAGS``` to build Android ffis with cross-rs Add a limited dual arch build for docker images with ```build-dockers-``` branches Motivation and Context Improve general build support, with focus on cross compiling from macos devices cross-rs pre-built image requires a single script to build from How Has This Been Tested? Build locally and in fork What process can a PR reviewer use to test or verify this change? --- <!-- Checklist --> <!-- 1. Is the title of your PR in the form that would make nice release notes? The title, excluding the conventional commit tag, will be included exactly as is in the CHANGELOG, so please think about it carefully. --> Breaking Changes --- - [x] None - [ ] Requires data directory on base node to be deleted - [ ] Requires hard fork - [ ] Other - Please specify <!-- Does this include a breaking change? If so, include this line as a footer --> <!-- BREAKING CHANGE: Description what the user should do, e.g. delete a database, resync the chain -->
- Loading branch information
Showing
8 changed files
with
200 additions
and
45 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
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
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 |
---|---|---|
@@ -1 +1 @@ | ||
./runtime/start_tari_miner.sh | ||
./runtime/start_minotari_miner.sh |
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 |
---|---|---|
@@ -1 +1 @@ | ||
./runtime/start_tari_miner.sh | ||
./runtime/start_minotari_miner.sh |
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,166 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Single script for Ubuntu 18.04 package setup, mostly used for cross-compiling | ||
# | ||
|
||
set -e | ||
|
||
USAGE="Usage: $0 target build ie: x86_64-unknown-linux-gnu or aarch64-unknown-linux-gnu" | ||
|
||
if [ "$#" == "0" ]; then | ||
echo "$USAGE" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "${CROSS_DEB_ARCH}" ]; then | ||
echo "Should be run from cross, which sets the env CROSS_DEB_ARCH" | ||
exit 1 | ||
fi | ||
|
||
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 | ||
|
||
crossArch=${CROSS_DEB_ARCH} | ||
apt-get update | ||
|
||
# Base install packages | ||
# scripts/install_ubuntu_dependencies.sh | ||
apt-get install --no-install-recommends --assume-yes \ | ||
apt-transport-https \ | ||
ca-certificates \ | ||
curl \ | ||
gpg \ | ||
bash \ | ||
less \ | ||
openssl \ | ||
libssl-dev \ | ||
pkg-config \ | ||
libsqlite3-dev \ | ||
libsqlite3-0 \ | ||
libreadline-dev \ | ||
git \ | ||
cmake \ | ||
dh-autoreconf \ | ||
clang \ | ||
g++ \ | ||
g++-7 \ | ||
libc++-dev \ | ||
libc++abi-dev \ | ||
libprotobuf-dev \ | ||
protobuf-compiler \ | ||
libncurses5-dev \ | ||
libncursesw5-dev \ | ||
libudev-dev \ | ||
zip | ||
|
||
echo "Installing rust ..." | ||
mkdir -p "$HOME/.cargo/bin/" | ||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | ||
export PATH="$HOME/.cargo/bin:$PATH" | ||
. "$HOME/.cargo/env" | ||
|
||
# Cross-CPU compile setup | ||
if [ "${CROSS_DEB_ARCH}" != "${nativeArch}" ]; then | ||
echo "Setup Cross CPU Compile ..." | ||
sed -i.save -e "s/^deb\ http/deb [arch="${nativeArch}"] http/g" /etc/apt/sources.list | ||
|
||
. /etc/lsb-release | ||
ubuntu_tag=${DISTRIB_CODENAME} | ||
|
||
if [ "${crossArch}" == "arm64" ]; 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 | ||
deb [arch=${crossArch}] http://ports.ubuntu.com/ubuntu-ports ${ubuntu_tag}-updates main restricted universe multiverse | ||
# deb-src [arch=${crossArch}] http://ports.ubuntu.com/ubuntu-ports ${ubuntu_tag}-updates main restricted universe multiverse | ||
deb [arch=${crossArch}] http://ports.ubuntu.com/ubuntu-ports ${ubuntu_tag}-backports main restricted universe multiverse | ||
# deb-src [arch=${crossArch}] http://ports.ubuntu.com/ubuntu-ports ${ubuntu_tag}-backports main restricted universe multiverse | ||
deb [arch=${crossArch}] http://ports.ubuntu.com/ubuntu-ports ${ubuntu_tag}-security main restricted universe multiverse | ||
# deb-src [arch=${crossArch}] http://ports.ubuntu.com/ubuntu-ports ${ubuntu_tag}-security main restricted universe multiverse | ||
deb [arch=${crossArch}] http://archive.canonical.com/ubuntu ${ubuntu_tag} partner | ||
# deb-src [arch=${crossArch}] http://archive.canonical.com/ubuntu ${ubuntu_tag} partner | ||
EoF | ||
fi | ||
|
||
if [ "${crossArch}" == "amd64" ]; then | ||
cat << EoF > /etc/apt/sources.list.d/${ubuntu_tag}-${crossArch}.list | ||
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ ${ubuntu_tag} main restricted | ||
# deb-src http://archive.ubuntu.com/ubuntu/ ${ubuntu_tag} main restricted | ||
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ ${ubuntu_tag}-updates main restricted | ||
# deb-src http://archive.ubuntu.com/ubuntu/ ${ubuntu_tag}-updates main restricted | ||
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ ${ubuntu_tag} universe | ||
# deb-src http://archive.ubuntu.com/ubuntu/ ${ubuntu_tag} universe | ||
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ ${ubuntu_tag}-updates universe | ||
# deb-src http://archive.ubuntu.com/ubuntu/ ${ubuntu_tag}-updates universe | ||
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ ${ubuntu_tag} multiverse | ||
# deb-src http://archive.ubuntu.com/ubuntu/ ${ubuntu_tag} multiverse | ||
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ ${ubuntu_tag}-updates multiverse | ||
# deb-src http://archive.ubuntu.com/ubuntu/ ${ubuntu_tag}-updates multiverse | ||
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ ${ubuntu_tag}-backports main restricted universe multiverse | ||
# deb-src http://archive.ubuntu.com/ubuntu/ ${ubuntu_tag}-backports main restricted universe multiverse | ||
# deb http://archive.canonical.com/ubuntu ${ubuntu_tag} partner | ||
# deb-src http://archive.canonical.com/ubuntu ${ubuntu_tag} partner | ||
deb [arch=amd64] http://security.ubuntu.com/ubuntu/ ${ubuntu_tag}-security main restricted | ||
# deb-src http://security.ubuntu.com/ubuntu/ ${ubuntu_tag}-security main restricted | ||
deb [arch=amd64] http://security.ubuntu.com/ubuntu/ ${ubuntu_tag}-security universe | ||
# deb-src http://security.ubuntu.com/ubuntu/ ${ubuntu_tag}-security universe | ||
deb [arch=amd64] http://security.ubuntu.com/ubuntu/ ${ubuntu_tag}-security multiverse | ||
# deb-src http://security.ubuntu.com/ubuntu/ ${ubuntu_tag}-security multiverse | ||
EoF | ||
fi | ||
|
||
dpkg --add-architecture ${CROSS_DEB_ARCH} | ||
apt-get update | ||
|
||
# scripts/install_ubuntu_dependencies-cross_compile.sh x86-64 | ||
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 \ | ||
libhidapi-dev:${CROSS_DEB_ARCH} \ | ||
libudev-dev:${CROSS_DEB_ARCH} | ||
|
||
fi | ||
|
||
rustup target add ${targetBuild} | ||
rustup toolchain install stable-${targetBuild} --force-non-host | ||
|
||
rustup target list | ||
rustup toolchain list |