Skip to content

Commit

Permalink
Merge pull request #15 from flashbots/musl-cross-static-linking
Browse files Browse the repository at this point in the history
Musl cross static linking
  • Loading branch information
ZanCorDX authored Nov 4, 2024
2 parents 8624925 + 8513ad0 commit dca2a6c
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 52 deletions.
13 changes: 3 additions & 10 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,24 @@ jobs:
matrix:
toolchain:
- stable
#- beta
#- nightly

steps:
- name: Checkout sources
uses: actions/checkout@v4

# https://github.com/dtolnay/rust-toolchain
- name: Setup rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.toolchain }}

- name: Install Protoc
uses: arduino/setup-protoc@v3

# https://github.com/WarpBuilds/rust-cache

- name: Run WarpBuilds/rust-cache
uses: WarpBuilds/rust-cache@v2
with:
cache-on-failure: true

# https://github.com/Mozilla-Actions/sccache-action
- name: Run sccache-action
uses: mozilla-actions/[email protected]

Expand All @@ -49,10 +45,7 @@ jobs:
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
- name: Install native dependencies
run: sudo apt-get install -y libsqlite3-dev

#######################################################
run: sudo apt-get update && sudo apt-get install -y libsqlite3-dev

# lint and test
- run: make lint
- run: make test
45 changes: 6 additions & 39 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ on:
default: false

jobs:
#
# extract-version extracts the version from the tag or the branch name,
# for reuse in later jobs
#
extract-version:
name: Extract version
runs-on: warp-ubuntu-latest-x64-16x
Expand Down Expand Up @@ -50,9 +46,6 @@ jobs:
echo "| \`GITHUB_SHA\` | \`${GITHUB_SHA}\` |" >> $GITHUB_STEP_SUMMARY
echo "| \`VERSION\` | \`${VERSION}\` |" >> $GITHUB_STEP_SUMMARY
#
# build-binary builds a release binary for a variety of platforms
#
build-binary:
name: Build binary
needs: extract-version
Expand All @@ -66,64 +59,40 @@ jobs:
strategy:
matrix:
configs:
- target: x86_64-unknown-linux-gnu
- target: x86_64-unknown-linux-musl
runner: warp-ubuntu-latest-x64-16x
- target: aarch64-apple-darwin
runner: warp-macos-14-arm64-6x

steps:
- name: Checkout sources
uses: actions/checkout@v4

# https://github.com/dtolnay/rust-toolchain
- name: Setup rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
target: ${{ matrix.configs.target }}

- name: Install Protoc
uses: arduino/setup-protoc@v3

# https://github.com/WarpBuilds/rust-cache
- name: Run WarpBuilds/rust-cache
uses: WarpBuilds/rust-cache@v2
with:
cache-on-failure: true

# https://github.com/Mozilla-Actions/sccache-action
- name: Setup sccache-action
uses: mozilla-actions/[email protected]

- name: Set env vars
run: |
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
- name: Prepare output filename
run: |
OUTPUT_FILENAME="rbuilder-${VERSION}-${{ matrix.configs.target }}.tar.gz"
echo "OUTPUT_FILENAME=$OUTPUT_FILENAME" >> $GITHUB_ENV
echo "Filename: ${OUTPUT_FILENAME}"
- name: Build rbuilder binary
run: cargo build --release
- uses: taiki-e/install-action@cross

- name: Build binary
run: cross build --release --target ${{ matrix.configs.target }}

- name: Prepare artifacts
run: |
mkdir -p artifacts
tar -czf "artifacts/${OUTPUT_FILENAME}" -C target/release rbuilder
tar -czf "artifacts/${OUTPUT_FILENAME}" -C target/${{ matrix.configs.target }}/release rbuilder
# https://github.com/actions/upload-artifact
- name: Upload artifacts
uses: actions/[email protected]
with:
name: ${{ env.OUTPUT_FILENAME }}
path: artifacts/${{ env.OUTPUT_FILENAME }}

#
# draft-release runs after building for various targets, collects artifacts and prepares a draft release
# (only when running against a tag!)
#
draft-release:
name: Draft release
if: ${{ github.event.inputs.draft-release == 'true' || github.event_name == 'push'}} # when manually triggered or version tagged
Expand All @@ -137,7 +106,6 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

# https://github.com/actions/download-artifact
- name: Download artifacts
uses: actions/download-artifact@v4
with:
Expand All @@ -151,7 +119,6 @@ jobs:
for file in *; do sha256sum "$file" >> sha256sums.txt; done;
cat sha256sums.txt
# https://github.com/softprops/action-gh-release
- name: Create release draft
uses: softprops/[email protected]
id: create-release-draft
Expand Down
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
openssl = { version = "0.10", features = ["vendored"], optional = false }
clap = { version = "4.4.3", features = ["derive", "env"] }
tokio = "1.32.0"
tokio-util = "0.7.10"
Expand Down Expand Up @@ -46,7 +47,6 @@ tower = "0.4"

metrics_macros = { git = "https://github.com/flashbots/rbuilder.git", rev = "d96e7215483bac0ab145459f4ddaa811d99459d6"}

#rbuilder = {path="./../rbuilder/crates/rbuilder"}
rbuilder = { git = "https://github.com/flashbots/rbuilder.git", rev = "d96e7215483bac0ab145459f4ddaa811d99459d6"}

[build-dependencies]
Expand Down
7 changes: 7 additions & 0 deletions Cross.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[target.x86_64-unknown-linux-musl]
pre-build = [
"apt-get update && apt-get install -y pkg-config libssl-dev curl unzip",
"curl -sSL https://github.com/protocolbuffers/protobuf/releases/download/v24.3/protoc-24.3-linux-x86_64.zip -o protoc.zip",
"unzip protoc.zip -d /usr/local",
"chmod +x /usr/local/bin/protoc"
]
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ clean: ## Clean up
cargo clean

.PHONY: build
build: ## Build (debug version)
cargo build
build: ## Build static binary for x86_64
cross build --release --target x86_64-unknown-linux-musl

.PHONY: docker-image
docker-image: ## Build a rbuilder Docker image
Expand Down

0 comments on commit dca2a6c

Please sign in to comment.