Skip to content

Use custom bpf-tools #319

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ RUN pip3 install solana
# Build off-chain binaries.
RUN cd pyth-client && ./scripts/build.sh


RUN ./pyth-client/scripts/get-bpf-tools.sh
# Copy solana sdk and apply patch.
RUN mkdir solana
RUN cp -a /usr/bin/sdk solana
Expand Down
23 changes: 23 additions & 0 deletions scripts/get-bpf-tools.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
#
# The goal of this script is downloading our own version of bpf/sbf tools. When cargo-build-bpf/sbf gets called
# https://github.com/solana-labs/sbf-tools/releases/download/v1.29/solana-bpf-tools-linux.tar.bz2 gets downloaded, extracted and linked as a toolchain.
# This script is meant to override that behavior and use another version of bpf/sbf-tools.
# Using a custom version of bpf/sbf-tools allows our use of -Z build-std=std,panic_abort flags that make the binary smaller. These flags compile the std library from scratch.
# If solana fixes bpf/sbf-tools, we can revert back to the default behavior (once this PR https://github.com/solana-labs/cargo/pull/1 gets merged and released)
set -eux

curl https://github.com/guibescos/sbf-tools/releases/download/v1.29.1/solana-bpf-tools-linux.tar.bz2 --output solana-bpf-tools-linux.tar.bz2 -L
mkdir -p ~/.cache/solana/v1.29/bpf-tools/
tar -xf solana-bpf-tools-linux.tar.bz2 -C ~/.cache/solana/v1.29/bpf-tools/
rm solana-bpf-tools-linux.tar.bz2

# Source cargo
if ! which cargo 2> /dev/null
then
# shellcheck disable=SC1090
source "${CARGO_HOME:-$HOME/.cargo}/env"
fi

# Link the toolchain for future use
rustup toolchain link bpf ~/.cache/solana/v1.29/bpf-tools/rust