Skip to content

Commit cf26e1e

Browse files
committed
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 c86a562 commit cf26e1e

File tree

3 files changed

+53
-22
lines changed

3 files changed

+53
-22
lines changed

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: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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]
37+
for match in re.findall(r"\[..] (\.(\w|\.)+)", stdout, re.MULTILINE)
38+
}
39+
needed_sections = {
40+
".debug_aranges",
41+
".debug_info",
42+
".debug_abbrev",
43+
".debug_line",
44+
".debug_frame",
45+
".debug_str",
46+
".debug_ranges",
47+
}
48+
missing_sections = needed_sections - matches
49+
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)