Skip to content

Commit 71e478d

Browse files
pb8okalyazin
authored andcommitted
fix(release): ensure debuginfo file contains debugging info
Seems recently Cargo defaulted to use `strip=debuginfo`. This inadvertently made our debuginfo files much smaller Fix the issue by using `strip=none` and add a test so that it breaks if this somehow changes again. Signed-off-by: Pablo Barbáchano <[email protected]>
1 parent 69124fd commit 71e478d

File tree

4 files changed

+55
-22
lines changed

4 files changed

+55
-22
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ and this project adheres to
1717
from net device creation to device activation time, but it was not reflected
1818
in the restore path. This was leading to inability to connect to the restored
1919
VM if the offload features were used.
20+
- [#4829](https://github.com/firecracker-microvm/firecracker/pull/4829): v1.9.0
21+
was missing most of the debugging information in the debuginfo file, due to a
22+
change in the Cargo defaults. This has been corrected.
2023

2124
## \[1.9.0\]
2225

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,7 @@ panic = "abort"
2727
[profile.release]
2828
panic = "abort"
2929
lto = true
30+
strip = "none"
31+
32+
[profile.bench]
33+
strip = "debuginfo"
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
"""Tests to check several aspects of the binaries"""
5+
6+
import re
7+
import subprocess
8+
9+
import pytest
10+
11+
from framework import utils
12+
13+
14+
@pytest.mark.timeout(500)
15+
def test_firecracker_binary_static_linking(microvm_factory):
16+
"""
17+
Test to make sure the firecracker binary is statically linked.
18+
"""
19+
fc_binary_path = microvm_factory.fc_binary_path
20+
_, stdout, stderr = utils.check_output(f"file {fc_binary_path}")
21+
assert "" in stderr
22+
# expected "statically linked" for aarch64 and
23+
# "static-pie linked" for x86_64
24+
assert "statically linked" in stdout or "static-pie linked" in stdout
25+
26+
27+
def test_release_debuginfo(microvm_factory):
28+
"""Ensure the debuginfo file has the right ELF sections"""
29+
fc_binary = microvm_factory.fc_binary_path
30+
debuginfo = fc_binary.with_suffix(".debug")
31+
stdout = subprocess.check_output(
32+
["readelf", "-S", str(debuginfo)],
33+
encoding="ascii",
34+
)
35+
matches = {
36+
match[0] for match in re.findall(r"\[..] (\.(\w|\.)+)", stdout, re.MULTILINE)
37+
}
38+
needed_sections = {
39+
".debug_aranges",
40+
".debug_info",
41+
".debug_abbrev",
42+
".debug_line",
43+
".debug_frame",
44+
".debug_str",
45+
".debug_ranges",
46+
}
47+
missing_sections = needed_sections - matches
48+
assert missing_sections == set()

tests/integration_tests/functional/test_binary_static_linking.py

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)