Skip to content

chore: Build for x86_64-unknown-linux-musl with all features and optimized binary size #689

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

Merged
merged 5 commits into from Aug 1, 2019
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ jobs:
name: Build archive
command: |
export VERSION=$(make version)
make build-archive FEATURES="jemallocator"
export RUST_LTO="lto"
make build-archive FEATURES="jemallocator leveldb rdkafka rdkafka/cmake_build"
- persist_to_workspace:
root: target/artifacts
paths:
Expand Down
20 changes: 20 additions & 0 deletions scripts/build-archive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
#
# $FEATURES - a list of Vector features to include when building, defaults to all
# $NATIVE_BUILD - whether to pass the --target flag when building via cargo
# $RUST_LTO - possible values are "lto", "lto=thin", ""
# $TARGET - a target triple. ex: x86_64-apple-darwin
# $VERSION - the version of Vector, can be obtained via `make version`

NATIVE_BUILD=${NATIVE_BUILD:-}
RUST_LTO=${RUST_LTO:-}

set -eu

Expand Down Expand Up @@ -46,8 +48,26 @@ if [ "$FEATURES" != "default" ]; then
build_flags="$build_flags --no-default-features --features $FEATURES"
fi

# Currently the only way to set Rust codegen LTO type (-C lto, as opposed to
# -C compiler-plugin-lto) at build time for a crate with library dependencies
# is to patch Cargo.toml before the build. See
# https://github.com/rust-lang/cargo/issues/4349 and
# https://bugzilla.mozilla.org/show_bug.cgi?id=1386371#c2.
if [ -n "$RUST_LTO" ]; then
cp Cargo.toml Cargo.toml.orig
trap "mv Cargo.toml.orig Cargo.toml" EXIT
case "$RUST_LTO" in
lto) lto_value="true";;
lto=thin) lto_value="\"thin\"";;
esac
printf "[profile.release]\nlto = $lto_value" >> Cargo.toml
fi

cargo build $build_flags

# Strip the output binary
strip $target_dir/release/vector

# Build the archive directory
rm -rf $archive_dir
mkdir -p $archive_dir
Expand Down
Loading