This repository was archived by the owner on Nov 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathinstall-rust-lld-ARM.sh
executable file
·95 lines (83 loc) · 2.78 KB
/
install-rust-lld-ARM.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
# Install all required dependencies for building Substrate based chains on ARM architectures.
# Copyright (C) Parity Technologies <admin@parity.io>
# License: Apache-2.0
# Set to the latest branch from: https://github.com/rust-lang/llvm-project
RUST_LLVM_BRANCH="rustc/10.0-2020-05-05"
if [[ "$OSTYPE" == "linux-gnu" ]] || [[ "$OSTYPE" == "linux-gnueabihf" ]]; then
set -e
if [[ $(whoami) == "root" ]]; then
MAKE_ME_ROOT=
else
MAKE_ME_ROOT=sudo
fi
ARCH=$(uname -m)
if [[ "$ARCH" == "aarch64" ]] || [[ "$ARCH" == "armv7l" ]]; then
if [ -f /etc/debian_version ]; then
echo "Ubuntu/Debian Linux detected."
$MAKE_ME_ROOT apt update
$MAKE_ME_ROOT apt-get install -y --no-install-recommends \
build-essential \
ninja-build \
ca-certificates \
cmake \
pkg-config \
libssl-dev \
gcc \
git \
clang \
libclang-dev \
protobuf-compiler
else
echo "This Linux distribution is not supported with this script at present. Sorry."
echo "Please refer to https://github.com/paritytech/substrate for setup information."
exit 1
fi
if ! which rustup >/dev/null 2>&1; then
curl https://sh.rustup.rs -sSf | sh -s -- -y
source ~/.cargo/env
rustup default stable
else
rustup update
rustup default stable
fi
rustup update nightly --force
rustup target add wasm32-unknown-unknown --toolchain nightly
echo "Building llvm-ld for: $ARCH"
tmp=$(mktemp -d)
git clone -b $RUST_LLVM_BRANCH --depth 1 https://github.com/rust-lang/llvm-project.git "$tmp"
pushd "$tmp"
mkdir -p llvm/tools/lld
cp -R lld/ llvm/tools/
mkdir -p "$tmp"/build/arm
cd "$tmp"/build/arm
if [ "$ARCH" == "aarch64" ]; then
cmake -G Ninja "$tmp"/llvm \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/opt/local/llvm \
-DLLVM_TARGETS_TO_BUILD="AArch64" \
-DLLVM_TARGET_ARCH="AArch64"
else
cmake -G Ninja "$tmp"/llvm \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/opt/local/llvm \
-DLLVM_TARGETS_TO_BUILD="ARM" \
-DLLVM_TARGET_ARCH="ARM"
fi
ninja lld
$MAKE_ME_ROOT ninja install-lld
popd
echo "Installing rust-lld for: $ARCH"
cp -f /opt/local/llvm/bin/ld.lld ~/.cargo/bin/rust-lld
source ~/.cargo/env
echo "Run source ~/.cargo/env now to update environment"
else
echo "This architecture is not supported with this script at present. Sorry."
echo "Please refer to https://github.com/paritytech/substrate for setup information."
exit 1
fi
else
echo "This OS is not supported with this script at present. Sorry."
echo "Please refer to https://github.com/paritytech/substrate for setup information."
exit 1
fi