Skip to content
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

platform-tools-solana: Add action for building Solana Platform toolchain #1

Closed
wants to merge 1 commit into from
Closed
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
142 changes: 142 additions & 0 deletions .github/workflows/platform-tools-solana.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
name: Solana Platform tools

on:
push:
tags:
- "platform-tools-solana*"
# todo remove
pull_request:
branches:
- main

permissions:
contents: write

env:
LLVM_VERSION: 16

jobs:
release:
name: release
strategy:
matrix:
include:
- target: aarch64-apple-darwin
os: macos-latest
- target: aarch64-unknown-linux-gnu
os: ubuntu-20.04
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: x86_64-unknown-linux-gnu
os: ubuntu-20.04
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
runs-on: ${{ matrix.os }}
outputs:
version: ${{ steps.extract_version.outputs.version }}
steps:
- name: Extract version from tag
id: extract_version
run: |
echo "version=$(echo ${GITHUB_REF#refs/tags/platform-tools-solana-})" >> $GITHUB_OUTPUT

- name: Install dependencies
if: startsWith(matrix.os, 'ubuntu')
run: |
set -euxo pipefail
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
echo -e deb http://apt.llvm.org/focal/ llvm-toolchain-focal-${{ env.LLVM_VERSION }} main | sudo tee /etc/apt/sources.list.d/llvm.list
sudo apt update
sudo apt -y install clang-${{ env.LLVM_VERSION }} cmake lld-${{ env.LLVM_VERSION }} ninja-build
echo /usr/lib/llvm-${{ env.LLVM_VERSION }}/bin >> $GITHUB_PATH

- name: Checkout Rust code
uses: actions/checkout@v2
with:
repository: solana-labs/rust
ref: solana-tools-${{ steps.extract_version.outputs.version }}

- name: Build Rust
run: |
./x.py build --stage 1 --target ${{ matrix.target }},sbf-solana-solana

- name: Checkout Cargo code
uses: actions/checkout@v2
with:
repository: solana-labs/caego
ref: solana-tools-${{ steps.extract_version.outputs.version }}

- name: Build Cargo
env:
OPENSSL_STATIC: 1
run: |
cargo build --release

- name: Copy Rust build products
run: |
set -euxo pipefail
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/
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/sbf-solana-solana" deploy/rust/lib/rustlib/
find . -maxdepth 6 -type f -path "./rust/build/${HOST_TRIPLE}/stage1/lib/*" -exec cp {} deploy/rust/lib \;
mkdir -p deploy/rust/lib/rustlib/src/rust
cp "rust/build/${HOST_TRIPLE}/stage1/lib/rustlib/src/rust/Cargo.lock" deploy/rust/lib/rustlib/src/rust
cp -R "rust/build/${HOST_TRIPLE}/stage1/lib/rustlib/src/rust/library" deploy/rust/lib/rustlib/src/rust

- name: Copy LLVM build products
run: |
set -euxo pipefail
mkdir -p deploy/llvm/{bin,lib}
while IFS= read -r f
do
bin_file="rust/build/${HOST_TRIPLE}/llvm/build/bin/${f}${EXE_SUFFIX}"
if [[ -f "$bin_file" ]] ; then
cp -R "$bin_file" deploy/llvm/bin/
fi
done < <(cat <<EOF
clang
clang++
clang-cl
clang-cpp
clang-16
ld.lld
ld64.lld
llc
lld
lld-link
lldb
lldb-vscode
llvm-ar
llvm-objcopy
llvm-objdump
llvm-readelf
llvm-readobj
EOF
)
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/
cp -R rust/src/llvm-project/lldb/scripts/solana/* deploy/llvm/bin/
cp -R rust/build/${HOST_TRIPLE}/llvm/lib/liblldb.* deploy/llvm/lib/
cp -R rust/build/${HOST_TRIPLE}/llvm/lib/python* deploy/llvm/lib/
fi

- name: Archive artifacts
run: |
tar -C deploy -jcf solana-platform-tools-${{ matrix.target }}.tar.bz2 .
rm -rf deploy

- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: |
solana-platform-tools-${{ matrix.target }}.tar.bz2
Loading