Link the differential tests with lld only when the toolchain has it.

tests/diff/common.py always passed -fuse-ld=lld, so on an MSYS2 install without the lld package simd.py, atomic.py
and the other Unicorn checks stopped at "invalid linker name" before testing anything. lld is used when it sits
beside the compiler, the default linker otherwise; atomic.py passes either way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-08 09:29:53 -05:00
parent f753dd0e33
commit 138b8c8c29

View File

@@ -223,7 +223,11 @@ def build_harness(work, bodies, jobs, cflags):
if any(p.wait() for p in procs):
raise SystemExit('compile failed')
exe = work / ('harness.exe' if os.name == 'nt' else 'harness')
subprocess.check_call([cc, '-fuse-ld=lld', '-o', str(exe)] + [str(o) for o in objs], env=env)
# lld when the toolchain has it beside the compiler; its default linker otherwise (an MSYS2 install without the lld
# package stopped every differential test at "invalid linker name")
cc_dir = os.path.dirname(shutil.which(cc, path=env.get('PATH')) or cc)
lld = ['-fuse-ld=lld'] if any(os.path.isfile(os.path.join(cc_dir, n)) for n in ('ld.lld', 'ld.lld.exe')) else []
subprocess.check_call([cc, *lld, '-o', str(exe)] + [str(o) for o in objs], env=env)
return exe