Files
.buildkite
.github
archiver
banking-bench
bench-exchange
bench-streamer
bench-tps
book
chacha-sys
ci
clap-utils
cli
client
core
crate-features
faucet
fixed-buf
genesis
genesis-programs
gossip
install
keygen
ledger
ledger-tool
local-cluster
log-analyzer
logger
measure
merkle-tree
metrics
multinode-demo
net
net-shaper
net-utils
perf
programs
rayon-threadlimit
runtime
scripts
sdk
benches
bpf
c
dependencies
rust
test
bpf.ld
build.sh
clean.sh
scripts
.gitignore
docker-solana
macro
src
.gitignore
Cargo.toml
sdk-c
sys-tuner
system-test
upload-perf
validator
vote-signer
watchtower
.appveyor.yml
.clippy.toml
.codecov.yml
.gitbook.yaml
.gitignore
.mergify.yml
.travis.yml
CONTRIBUTING.md
Cargo.lock
Cargo.toml
LICENSE
README.md
RELEASE.md
fetch-perf-libs.sh
run.sh
solana/sdk/bpf/rust/build.sh

46 lines
1.2 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
2019-05-21 11:22:33 -07:00
if [ "$#" -ne 1 ]; then
echo "Error: Must provide the full path to the project to build"
exit 1
fi
2019-05-22 15:09:59 -07:00
if [ ! -f "$1/Cargo.toml" ]; then
2019-05-21 11:22:33 -07:00
echo "Error: Cannot find project: $1"
exit 1
fi
2019-06-20 16:07:12 -07:00
echo "Building $1"
set -e
bpf_sdk=$(cd "$(dirname "$0")/.." && pwd)
2019-06-20 16:49:33 -07:00
# Ensure the sdk is installed
"$bpf_sdk"/scripts/install.sh
2019-06-07 14:38:49 -07:00
# Use the SDK's version of llvm to build the compiler-builtins for BPF
2019-06-17 11:04:38 -07:00
export CC="$bpf_sdk/dependencies/llvm-native/bin/clang"
export AR="$bpf_sdk/dependencies/llvm-native/bin/llvm-ar"
2019-06-20 16:49:33 -07:00
2019-06-07 14:38:49 -07:00
# Use the SDK's version of Rust to build for BPF
export RUSTUP_TOOLCHAIN=bpf
2019-05-21 11:22:33 -07:00
export RUSTFLAGS="
-C lto=no \
-C opt-level=2 \
-C link-arg=-z -C link-arg=notext \
2019-06-17 11:04:38 -07:00
-C link-arg=-T$bpf_sdk/rust/bpf.ld \
-C link-arg=--Bdynamic \
-C link-arg=-shared \
-C link-arg=--entry=entrypoint \
2019-09-25 07:44:33 -07:00
-C link-arg=-no-threads \
2019-06-17 11:04:38 -07:00
-C linker=$bpf_sdk/dependencies/llvm-native/bin/ld.lld"
2019-06-20 16:49:33 -07:00
# Setup xargo
export XARGO_HOME="$bpf_sdk/dependencies/xargo"
2019-06-17 11:04:38 -07:00
export XARGO_RUST_SRC="$bpf_sdk/dependencies/rust-bpf-sysroot/src"
2019-12-10 22:27:14 -08:00
export RUST_COMPILER_RT_ROOT="$bpf_sdk/dependencies/rust-bpf-sysroot/src/compiler-rt"
2019-06-20 16:49:33 -07:00
cd "$1"
2019-06-20 16:07:12 -07:00
xargo build --target bpfel-unknown-unknown --release
{ { set +x; } 2>/dev/null; echo Success; }