Skip to content

Commit

Permalink
fix(tests): strip debug information before a testrun
Browse files Browse the repository at this point in the history
Before df112e3 the tests compiled Firecracked and stripped the
debuginfo. When we moved to running release.sh the behavior changed
since we only strip when making a release.

Solve it by always stripping symbols when building Firecracker in
--release profile.

Some care was taken so it is safe to re-run, so we don't lose the debug
symbols if the original binary has not changed.

Fixes: df112e3

Signed-off-by: Pablo Barbáchano <[email protected]>
  • Loading branch information
pb8o authored and zulinx86 committed Mar 26, 2024
1 parent 9bfe98a commit c9cc8d1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tools/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,13 @@ function check_bin_artifact {

function strip-and-split-debuginfo {
local bin=$1
if [ $bin -ot $bin.debug ]; then
return
fi
echo "STRIP $bin"
objcopy --only-keep-debug $bin $bin.debug
chmod a-x $bin.debug
objcopy --strip-debug --add-gnu-debuglink=$bin.debug $bin
objcopy --preserve-dates --strip-debug --add-gnu-debuglink=$bin.debug $bin
}

function get-firecracker-version {
Expand Down Expand Up @@ -129,6 +132,10 @@ say "Building version=$VERSION, profile=$PROFILE, target=$CARGO_TARGET, Rust too
# shellcheck disable=SC2086
cargo build --target "$CARGO_TARGET" $CARGO_OPTS --workspace --bins --examples

for file in "${ARTIFACTS[@]}"; do
strip-and-split-debuginfo "$CARGO_TARGET_DIR/$file"
done

say "Binaries placed under $CARGO_TARGET_DIR"

# Check static linking:
Expand Down Expand Up @@ -156,7 +163,7 @@ mkdir "$RELEASE_DIR"
for file in "${ARTIFACTS[@]}"; do
check_bin_artifact "$CARGO_TARGET_DIR/$file" "$VERSION"
cp -v "$CARGO_TARGET_DIR/$file" "$RELEASE_DIR/$file-$SUFFIX"
strip-and-split-debuginfo "$RELEASE_DIR/$file-$SUFFIX"
cp -v "$CARGO_TARGET_DIR/$file.debug" "$RELEASE_DIR/$file-$SUFFIX.debug"
done
cp -v "resources/seccomp/$CARGO_TARGET.json" "$RELEASE_DIR/seccomp-filter-$SUFFIX.json"
# Copy over arch independent assets
Expand Down

0 comments on commit c9cc8d1

Please sign in to comment.