-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathbuild-lambda
executable file
·36 lines (28 loc) · 1.19 KB
/
build-lambda
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
set -euo pipefail
if [[ ! $(which x86_64-unknown-linux-musl-gcc) ]]; then
brew tap messense/macos-cross-toolchains
brew install x86_64-unknown-linux-musl
fi
if [[ ! $(which cross) ]]; then
cargo install cross
fi
export CC_x86_64_unknown_linux_musl="x86_64-unknown-linux-musl-gcc"
export CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER="x86_64-unknown-linux-musl-gcc"
if [[ -n "$PGO" ]]; then
# STEP 0: Make sure there is no left-over profiling data from previous runs
rm -rf /tmp/pgo-data
# STEP 1: Build the instrumented binaries
RUSTFLAGS="-Cprofile-generate=/tmp/pgo-data -Cllvm-args=-vp-counters-per-site=4" \
cargo build --release
# STEP 2: Run the instrumented binaries with some typical data
ls logs/* | xargs -L1 target/release/kirby
# STEP 3: Merge the `.profraw` files into a `.profdata` file
$(ls ~/.rustup/toolchains/*/lib/rustlib/*/bin/llvm-profdata) \
merge -o /tmp/pgo-data/merged.profdata /tmp/pgo-data
# STEP 4: Use the `.profdata` file for guiding optimizations
RUSTFLAGS="-Cprofile-use=/tmp/pgo-data/merged.profdata" \
cross build --release --target x86_64-unknown-linux-musl
else
cross build --release --target x86_64-unknown-linux-musl
fi