Skip to content

Commit fff0a7e

Browse files
fix(profiling): also stash heap-gotter .so.debug across auditwheel
The .so alone was removed, but merge_heap_gotter_debug_symbols leaves a .libdd_heap_gotter*.so.debug ELF in the wheel RECORD; auditwheel still hits iter_versions on that file. Stash/remove both; reinsert only .so.
1 parent d15421d commit fff0a7e

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

.gitlab/scripts/build-wheel-helpers.sh

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,27 +171,34 @@ import sys
171171
wheel = Path(os.environ["BUILT_WHEEL_FILE"])
172172
stash = Path(os.environ["GOTTER_STASH_DIR"])
173173
marker = "libdd_heap_gotter"
174+
# Stash both the cdylib and any .so.debug sidecars merged into the wheel —
175+
# auditwheel parses every ELF in RECORD, and the debug file trips
176+
# iter_versions the same way as the .so (pipeline 130079400).
174177
with zipfile.ZipFile(wheel, "r") as zf:
175-
gotter = [n for n in zf.namelist() if marker in Path(n).name and n.endswith(".so")]
178+
gotter = [
179+
n
180+
for n in zf.namelist()
181+
if marker in Path(n).name and (n.endswith(".so") or n.endswith(".so.debug"))
182+
]
176183
for name in gotter:
177184
dest = stash / name
178185
dest.parent.mkdir(parents=True, exist_ok=True)
179186
dest.write_bytes(zf.read(name))
180-
print(f"Stashed heap-gotter cdylib: {name}")
187+
print(f"Stashed heap-gotter artifact: {name}")
181188
if gotter:
182189
# Remove via zip_filter so RECORD stays consistent.
183-
patterns = [f"*{marker}*.so", f"*/{marker}*.so"]
190+
patterns = [f"*{marker}*.so", f"*{marker}*.so.debug", f"*/{marker}*"]
184191
subprocess.check_call([sys.executable, "scripts/zip_filter.py", str(wheel), *patterns])
185192
with zipfile.ZipFile(wheel, "r") as zf:
186-
leftover = [n for n in zf.namelist() if marker in Path(n).name and n.endswith(".so")]
193+
leftover = [n for n in zf.namelist() if marker in Path(n).name]
187194
if leftover:
188195
raise SystemExit(f"heap-gotter still in wheel before auditwheel: {leftover}")
189196
print(f"heap-gotter stash count before auditwheel: {len(gotter)}")
190197
PY
191198

192199
auditwheel repair -w "${TMP_WHEEL_DIR}" "${BUILT_WHEEL_FILE}"
193200

194-
if find "${GOTTER_STASH_DIR}" -name 'libdd_heap_gotter*.so' 2>/dev/null | grep -q .; then
201+
if find "${GOTTER_STASH_DIR}" \( -name 'libdd_heap_gotter*.so' -o -name 'libdd_heap_gotter*.so.debug' \) 2>/dev/null | grep -q .; then
195202
REPAIRED_WHEEL_FILE=$(ls "${TMP_WHEEL_DIR}"/*.whl | head -n 1)
196203
GOTTER_STASH_DIR="${GOTTER_STASH_DIR}" REPAIRED_WHEEL_FILE="${REPAIRED_WHEEL_FILE}" \
197204
uv run --no-project python - <<'PY'
@@ -206,7 +213,13 @@ from pathlib import Path
206213
wheel = Path(os.environ["REPAIRED_WHEEL_FILE"])
207214
stash = Path(os.environ["GOTTER_STASH_DIR"])
208215
209-
additions = {str(p.relative_to(stash)): p for p in sorted(stash.rglob("*")) if p.is_file()}
216+
# Reinsert only the runtime .so into the repaired wheel; keep .so.debug out
217+
# of the manylinux artifact (debug symbols already live in debugwheelhouse).
218+
additions = {
219+
str(p.relative_to(stash)): p
220+
for p in sorted(stash.rglob("*"))
221+
if p.is_file() and p.name.endswith(".so") and not p.name.endswith(".so.debug")
222+
}
210223
if not additions:
211224
print("No stashed heap-gotter cdylib to reinsert")
212225
raise SystemExit(0)

0 commit comments

Comments
 (0)