Skip to content

Commit

Permalink
add PGO to all non-windows targets
Browse files Browse the repository at this point in the history
  • Loading branch information
omerbenamram committed Apr 3, 2024
1 parent 02e7ad2 commit f9a6713
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 15 deletions.
43 changes: 32 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,6 @@ jobs:
with:
version: 0.11.0

- name: Install Cross toolchain (cargo-zigbuild)
if: matrix.build == 'macos-m1'
shell: bash
run: |
cargo install cargo-zigbuild
- name: Get release download URL
if: env.MANUAL != '1'
uses: actions/download-artifact@v1
Expand All @@ -143,17 +137,44 @@ jobs:
- name: Build PGO Binary (Linux)
if: matrix.build == 'linux'
run: |
export TOOLCHAIN=stable-x86_64-unknown-linux-gnu
export TARGET=x86_64-unknown-linux-gnu
./build_pgo.sh
env:
HOME: ${{ github.workspace }}

- name: Build release binary
if: matrix.build == 'macos' || matrix.build == 'windows' || matrix.build == 'linux-static'
run: cargo build --target ${{ matrix.target }} --release --features fast-alloc
- name: Build PGO Binary (Linux Static)
if: matrix.build == 'linux-static'
run: |
export TOOLCHAIN=stable-x86_64-unknown-linux-musl
export TARGET=x86_64-unknown-linux-musl
./build_pgo.sh
env:
HOME: ${{ github.workspace }}

- name: Build PGO Binary (macOS)
if: matrix.build == 'macos'
run: |
export TOOLCHAIN=stable-x86_64-apple-darwin
export TARGET=x86_64-apple-darwin
./build_pgo.sh
env:
HOME: ${{ github.workspace }}

- name: Build release binary (macos-m1)
- name: Build PGO Binary (macOS M1)
if: matrix.build == 'macos-m1'
run: cargo zigbuild --target ${{ matrix.target }} --release --features fast-alloc
run: |
export TOOLCHAIN=stable-aarch64-apple-darwin
export TARGET=aarch64-apple-darwin
export ZIG=1
cargo install cargo-zigbuild
./build_pgo.sh
env:
HOME: ${{ github.workspace }}

- name: Build release binary (Windows)
if: matrix.build == 'windows'
run: cargo build --target ${{ matrix.target }} --release --features fast-alloc

- name: Build archive
shell: bash
Expand Down
18 changes: 14 additions & 4 deletions build_pgo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ cargo clean
rm -rf /tmp/pgo-data

PATH=$HOME/.rustup/toolchains/$TOOLCHAIN/lib/rustlib/$TARGET/bin:$PATH
RUSTFLAGS="-Cprofile-generate=/tmp/pgo-data" \
cargo build --release --target $TARGET --features fast-alloc
if [ -n "$ZIG" ]; then
RUSTFLAGS="-Cprofile-generate=/tmp/pgo-data" \
cargo zigbuild --release --target $TARGET --features fast-alloc
else
RUSTFLAGS="-Cprofile-generate=/tmp/pgo-data" \
cargo build --release --target $TARGET --features fast-alloc
fi

echo "Running instrumented binary"
for i in $(find samples -name "*.evtx"); do
Expand All @@ -41,5 +46,10 @@ else
fi

echo "Building binary with profile data"
RUSTFLAGS="-Cprofile-use=/tmp/pgo-data/merged.profdata" \
cargo build --release --target $TARGET --features fast-alloc
if [ -n "$ZIG" ]; then
RUSTFLAGS="-Cprofile-use=/tmp/pgo-data/merged.profdata" \
cargo zigbuild --release --target $TARGET --features fast-alloc
else
RUSTFLAGS="-Cprofile-use=/tmp/pgo-data/merged.profdata" \
cargo build --release --target $TARGET --features fast-alloc
fi

0 comments on commit f9a6713

Please sign in to comment.