@@ -102,12 +102,46 @@ grep -q 'libnativeabi.so.1' "$report/dynamic.txt" || {
102102# Replay the engine's effective header compile as a preprocess trace. The trace
103103# must resolve libc headers through the payload, without an ambient /usr tree.
104104python3 - " $report " << 'PYTRACE '
105- import json, pathlib, re, shlex, subprocess, sys
105+ import json, os, pathlib, re, shlex, subprocess, sys
106106report = pathlib.Path(sys.argv[1])
107107cdb = next(pathlib.Path('target/aarch64-linux-gnu').rglob('compile_commands.json'))
108108entries = json.loads(cdb.read_text())
109109entry = next(e for e in entries if e['file'].endswith('/headers.cpp'))
110110args = entry.get('arguments') or shlex.split(entry['command'])
111+ # The driver named by the cold project's CDB must itself have a managed
112+ # ARM64 loader and dependency closure, independently of the program it emits.
113+ store = (pathlib.Path(os.environ['MCPP_HOME']) / 'registry/data/xpkgs').resolve()
114+ compiler = pathlib.Path(args[0]).resolve()
115+ relative = compiler.relative_to(store)
116+ assert relative.parts[:2] == ('xim-x-llvm', '23.1.3'), compiler
117+
118+ driver_env = dict(os.environ)
119+ driver_env.pop('LD_LIBRARY_PATH', None)
120+ driver_env.pop('LD_PRELOAD', None)
121+
122+ def capture(name, command):
123+ result = subprocess.run(command, text=True, capture_output=True, env=driver_env)
124+ text = result.stdout + result.stderr
125+ (report / name).write_text(text)
126+ assert result.returncode == 0, (command, text)
127+ return text
128+
129+ header = capture('compiler-elf-header.txt', ['readelf', '-hW', str(compiler)])
130+ assert re.search(r'Machine:\s+AArch64', header), header
131+ version = capture('compiler-version.txt', [str(compiler), '--version'])
132+ assert re.search(r'clang version 23\.1\.3(?:\s|$)', version), version
133+ program_headers = capture('compiler-program-headers.txt', ['readelf', '-lW', str(compiler)])
134+ match = re.search(r'Requesting program interpreter: ([^\]]+)', program_headers)
135+ assert match, program_headers
136+ loader = pathlib.Path(match.group(1)).resolve()
137+ loader_relative = loader.relative_to(store)
138+ assert loader_relative.parts[0] == 'xim-x-glibc', loader
139+ assert loader.name == 'ld-linux-aarch64.so.1', loader
140+ closure = capture('compiler-loader-resolution.txt', [str(loader), '--list', str(compiler)])
141+ assert not re.search(r'=> /(?:usr/lib|lib64?|usr/local/lib)/', closure), closure
142+ for path in re.findall(r'=> (/\S+)', closure):
143+ pathlib.Path(path).resolve().relative_to(store)
144+ print('PASS: cold LLVM frontend has native ARM64 managed loader and libraries')
111145clean = []
112146i = 0
113147while i < len(args):
@@ -130,7 +164,10 @@ assert any('xim-x-glibc' in path and path.endswith('/features.h') for path in he
130164assert not any(re.match(r'/usr/(include|lib/gcc|local/include)(/|$)', path) for path in headers), headers
131165print('PASS: libc include trace uses the managed payload')
132166PYTRACE
133- cat " $report /program-headers.txt" " $report /loader-resolution.txt" " $report /include-trace.txt"
167+ cat " $report /program-headers.txt" " $report /loader-resolution.txt" \
168+ " $report /compiler-version.txt" " $report /compiler-elf-header.txt" \
169+ " $report /compiler-program-headers.txt" " $report /compiler-loader-resolution.txt" \
170+ " $report /include-trace.txt"
134171" $MCPP " pack --mode self-contained --format dir --message-format json > " $report /pack.json"
135172bundle=" $( python3 - " $report /pack.json" << 'PYPACK '
136173import json, sys
0 commit comments