build: Strip the binaries before using/releasing them

Stripping the release build for glibc shrinks the size considerably:

$ du -h target/release/cloud-hypervisor
8.5M    target/release/cloud-hypervisor
$ strip target/release/cloud-hypervisor
$ du -h target/release/cloud-hypervisor
5.2M    target/release/cloud-hypervisor

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford 2020-05-07 10:35:57 +01:00
parent a4d23c3cf3
commit 6fde2d18a6
2 changed files with 10 additions and 0 deletions

View File

@ -23,6 +23,8 @@ jobs:
run: cargo build --release --target=x86_64-unknown-linux-gnu run: cargo build --release --target=x86_64-unknown-linux-gnu
- name: Static Build - name: Static Build
run: cargo build --release --target=x86_64-unknown-linux-musl run: cargo build --release --target=x86_64-unknown-linux-musl
- name: Strip cloud-hypervisor binaries
run: strip target/*/release/cloud-hypervisor
- name: Create Release - name: Create Release
id: create_release id: create_release
uses: actions/create-release@v1 uses: actions/create-release@v1

View File

@ -211,6 +211,10 @@ sudo ip tuntap add name vunet-tap0 mode tap
sudo ip tuntap add name vunet-tap1 mode tap multi_queue sudo ip tuntap add name vunet-tap1 mode tap multi_queue
cargo build --release --target $BUILD_TARGET cargo build --release --target $BUILD_TARGET
strip target/$BUILD_TARGET/release/cloud-hypervisor
strip target/$BUILD_TARGET/release/vhost_user_net
strip target/$BUILD_TARGET/release/ch-remote
sudo setcap cap_net_admin+ep target/$BUILD_TARGET/release/cloud-hypervisor sudo setcap cap_net_admin+ep target/$BUILD_TARGET/release/cloud-hypervisor
sudo setcap cap_net_admin+ep target/$BUILD_TARGET/release/vhost_user_net sudo setcap cap_net_admin+ep target/$BUILD_TARGET/release/vhost_user_net
@ -242,6 +246,10 @@ RES=$?
if [ $RES -eq 0 ]; then if [ $RES -eq 0 ]; then
# virtio-mmio based testing # virtio-mmio based testing
cargo build --release --target $BUILD_TARGET --no-default-features --features "mmio" cargo build --release --target $BUILD_TARGET --no-default-features --features "mmio"
strip target/$BUILD_TARGET/release/cloud-hypervisor
strip target/$BUILD_TARGET/release/vhost_user_net
strip target/$BUILD_TARGET/release/ch-remote
sudo setcap cap_net_admin+ep target/$BUILD_TARGET/release/cloud-hypervisor sudo setcap cap_net_admin+ep target/$BUILD_TARGET/release/cloud-hypervisor
# Ensure test binary has the same caps as the cloud-hypervisor one # Ensure test binary has the same caps as the cloud-hypervisor one