Files
leleka/scripts/check-static-cuda-elf.py
Pavlo Ratushnyi 4013e0c9bd
Desktop foundation / core (ubuntu-latest) (push) Failing after 28s
Desktop foundation / core (macos-latest) (push) Canceled after 0s
Desktop foundation / core (windows-latest) (push) Canceled after 0s
Linux / verify (push) Canceled after 0s
Linux / keyless-cuda (push) Canceled after 0s
Linux / static-cuda-package (push) Canceled after 0s
Linux / hosted-cuda-package (push) Canceled after 0s
Linux / linux-static-cli (push) Canceled after 0s
Linux / linux-cli-container (push) Canceled after 0s
Linux / release-cli (push) Canceled after 0s
Import tracked Strata Next source snapshot
2026-10-05 18:15:08 +02:00

38 lines
1.9 KiB
Python

#!/usr/bin/env python3
"""Read-only ELF packaging gate; does not execute the engine or initialize CUDA."""
import json
from pathlib import Path
import re
import subprocess
import sys
def inspect(binary):
output = subprocess.check_output(['readelf', '-dW', str(binary)], text=True)
needed = re.findall(r'\(NEEDED\).*?\[(.*?)\]', output)
allowed = {'libc.so.6', 'libm.so.6', 'libdl.so.2', 'libpthread.so.0', 'librt.so.1',
'ld-linux-x86-64.so.2', 'ld-linux-aarch64.so.1'}
unexpected = sorted(set(needed) - allowed)
if unexpected:
raise RuntimeError('Unexpected shared libraries in static CUDA profile: ' + ', '.join(unexpected))
if '(RPATH)' in output or '(RUNPATH)' in output:
raise RuntimeError('Static CUDA engine must not retain a build-host library path')
if 'libc.so.6' not in needed:
raise RuntimeError('Expected a glibc-linked Linux engine; inspect this artifact manually')
headers = subprocess.check_output(['readelf', '-lW', str(binary)], text=True)
if 'INTERP' not in headers:
raise RuntimeError('Expected a host dynamic loader for the glibc-linked engine')
symbols = subprocess.check_output(['readelf', '--version-info', str(binary)], text=True)
versions = {tuple(int(part) for part in value.split('.'))
for value in re.findall(r'\bGLIBC_([0-9]+(?:\.[0-9]+)+)', symbols)}
if not versions:
raise RuntimeError('Unable to identify the minimum symbol-versioned glibc requirement')
return {'bytes': binary.stat().st_size, 'needed': needed, 'toolkit_shared_libraries': False,
'host_glibc_required': True, 'minimum_glibc': '.'.join(map(str, max(versions))),
'nvidia_driver_required': True, 'gpu_tested': False,
'scope': 'ELF direct dependencies; runtime dlopen requirements need GPU qualification'}
if __name__ == '__main__':
print(json.dumps(inspect(Path(sys.argv[1]).resolve())))