Skip to content

Commit

Permalink
Add newlib to the bpf-tools distribution package
Browse files Browse the repository at this point in the history
  • Loading branch information
dmakarov committed Oct 14, 2021
1 parent 9e436b8 commit 4a349b5
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ set -ex

unameOut="$(uname -s)"
case "${unameOut}" in
Linux*)
EXE_SUFFIX=
HOST_TRIPLE=x86_64-unknown-linux-gnu
ARTIFACT=solana-bpf-tools-linux.tar.bz2;;
Darwin*)
EXE_SUFFIX=
HOST_TRIPLE=x86_64-apple-darwin
Expand All @@ -15,7 +11,7 @@ case "${unameOut}" in
EXE_SUFFIX=.exe
HOST_TRIPLE=x86_64-pc-windows-msvc
ARTIFACT=solana-bpf-tools-windows.tar.bz2;;
*)
Linux* | *)
EXE_SUFFIX=
HOST_TRIPLE=x86_64-unknown-linux-gnu
ARTIFACT=solana-bpf-tools-linux.tar.bz2
Expand All @@ -41,14 +37,28 @@ pushd cargo
OPENSSL_STATIC=1 cargo build --release
popd

if [[ "${HOST_TRIPLE}" != "x86_64-pc-windows-msvc" ]] ; then
git clone --single-branch --branch bpf-port https://github.com/solana-labs/newlib.git
echo "$( cd newlib && git rev-parse HEAD ) https://github.com/solana-labs/newlib.git" >> version.md
mkdir -p newlib_build
mkdir -p newlib_install
pushd newlib_build
CC="${GITHUB_WORKSPACE}/out/rust/build/${HOST_TRIPLE}/llvm/bin/clang" \
AR="${GITHUB_WORKSPACE}/out/rust/build/${HOST_TRIPLE}/llvm/bin/llvm-ar" \
RANLIB="${GITHUB_WORKSPACE}/out/rust/build/${HOST_TRIPLE}/llvm/bin/llvm-ranlib" \
../newlib/newlib/configure --target=sbf-solana-solana --host=sbf-solana --build="${HOST_TRIPLE}" --prefix="${GITHUB_WORKSPACE}/out/newlib_install"
make install
popd
fi

# Copy rust build products
mkdir -p deploy/rust
cp version.md deploy/
cp -R rust/build/${HOST_TRIPLE}/stage1/bin deploy/rust/
cp -R cargo/target/release/cargo"${EXE_SUFFIX}" deploy/rust/bin/
cp -R "rust/build/${HOST_TRIPLE}/stage1/bin" deploy/rust/
cp -R "cargo/target/release/cargo${EXE_SUFFIX}" deploy/rust/bin/
mkdir -p deploy/rust/lib/rustlib/
cp -R rust/build/${HOST_TRIPLE}/stage1/lib/rustlib/${HOST_TRIPLE} deploy/rust/lib/rustlib/
cp -R rust/build/${HOST_TRIPLE}/stage1/lib/rustlib/bpfel-unknown-unknown deploy/rust/lib/rustlib/
cp -R "rust/build/${HOST_TRIPLE}/stage1/lib/rustlib/${HOST_TRIPLE}" deploy/rust/lib/rustlib/
cp -R "rust/build/${HOST_TRIPLE}/stage1/lib/rustlib/bpfel-unknown-unknown" deploy/rust/lib/rustlib/
find . -maxdepth 6 -type f -path "./rust/build/${HOST_TRIPLE}/stage1/lib/*" -exec cp {} deploy/rust/lib \;

# Copy llvm build products
Expand Down Expand Up @@ -77,7 +87,11 @@ llvm-readelf
llvm-readobj
EOF
)
cp -R rust/build/${HOST_TRIPLE}/llvm/build/lib/clang deploy/llvm/lib/
cp -R "rust/build/${HOST_TRIPLE}/llvm/build/lib/clang" deploy/llvm/lib/
if [[ "${HOST_TRIPLE}" != "x86_64-pc-windows-msvc" ]] ; then
cp -R newlib_install/sbf-solana/lib/lib{c,m}.a deploy/llvm/lib/
cp -R newlib_install/sbf-solana/include deploy/llvm/
fi

# Check the Rust binaries
while IFS= read -r f
Expand Down

0 comments on commit 4a349b5

Please sign in to comment.