Skip to content

Commit

Permalink
[antlir2][debuginfo] attempt to add debugging information when objcop…
Browse files Browse the repository at this point in the history
…y fails

Summary:
This seems to sometimes fail on very large binaries and we don't really have
any details to go on since a retry almost always works.

Test Plan:
```
❯ buck2 test fbcode//mode/opt fbcode//antlir/antlir2/features/install/...
Buck UI: https://www.internalfb.com/buck2/6f13a5c7-ce51-4516-bfe6-911bb224aa3f
Test UI: https://www.internalfb.com/intern/testinfra/testrun/11258999107872474
Network: Up: 0B  Down: 0B  (reSessionID-5f98e59a-6be6-489b-a71f-37c9e63cbc2b)
Jobs completed: 431. Time elapsed: 5.2s.
Cache hits: 0%. Commands: 3 (cached: 0, remote: 0, local: 3)
Tests finished: Pass 37. Fail 0. Fatal 0. Skip 0. Build failure 0
```

Reviewed By: naveedgol

Differential Revision: D59062594

fbshipit-source-id: c7644f7adea129449d79649ada46a0477bc82b40
  • Loading branch information
vmagro authored and facebook-github-bot committed Jun 26, 2024
1 parent 36de052 commit 827664c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions antlir/antlir2/bzl/debuginfo.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ subprocess.run(
# Find the BuildID of the binary. This determines where it should go for gdb to
# look it up under /usr/lib/debug
# https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html
buildid = subprocess.run(
buildid_proc = subprocess.run(
[
args.objcopy,
"--dump-section",
Expand All @@ -112,9 +112,14 @@ buildid = subprocess.run(
args.objcopy_tmp,
],
capture_output=True,
check=True,
).stdout
)
if buildid_proc.returncode != 0:
raise RuntimeError("Failed to get build-id for {}:\\n{}\\n{}".format(
args.binary,
buildid_proc.stdout.decode("utf-8", errors = "surrogateescape"),
buildid_proc.stderr.decode("utf-8", errors = "surrogateescape"),
))
buildid = buildid_proc.stdout
# Prefer to install the debug info by BuildID since it does not require another
# objcopy invocation and is more standard
Expand Down

0 comments on commit 827664c

Please sign in to comment.