build: isolate build-info defines into utils/buildinfo.c (ccache-friendly)

MAGIC_VERSION / MAGIC_REVISION / MAGIC_COMMIT / MAGIC_BUILDDATE were on the
global DFLAGS, so every object's compile command line carried them.  Because
the command line is part of ccache/sccache's hash key and MAGIC_BUILDDATE
changes every second, that meant a cache miss on every unit on every build;
it also smeared the baked-in date/commit across "whenever each file last
recompiled".

Move the four values into a single translation unit:
  * utils/magic_buildinfo.h -- extern MagicVersion/MagicRevision/MagicCommit/
    MagicCompileTime (MagicCommit is new; the other three moved here from
    utils/magic.h, which now includes this header).
  * utils/buildinfo.c -- the ONLY unit compiled with the version defines
    (target-specific `buildinfo.o: DFLAGS += ${DFLAGS_MAGICVERSION}` in
    utils/Makefile.in); it defines the four globals.  ${DFLAGS_MAGICVERSION}
    is removed from the global DFLAGS/DFLAGS_NOSTUB.

Consumers updated to read the runtime symbol instead of the compile-time
macro:
  * magicTop.c / tclmagic.c no longer define the globals (the MAGIC_WRAPPER
    duplicate-symbol guard is gone -- buildinfo.o owns them for every variant,
    including WASM, which links both mains).
  * Tcl_PkgProvide/PkgRequire in router/ext2spice/lef/ext2sim/plot/tclmagic
    now pass MagicVersion.
  * extflat: EFVersion (a static-initialized copy of MAGIC_VERSION) is dropped;
    EFread.c compares the .ext version against MagicVersion directly -- the same
    value ExtCell.c already *writes* into .ext files, so read and write are now
    consistent.

Verified: only buildinfo.o carries -DMAGIC_* (hash/DBio/windCmdSZ carry none);
Tcl (375 files) and --without-tcl builds rc=0, version/commit/date embedded in
tclmagic.so, magicTop.o no longer defines MagicVersion; in-tree source clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This commit is contained in:
Darryl L. Miles
2026-07-26 14:54:11 -04:00
committed by R. Timothy Edwards
co-authored by Claude Opus 4.8
parent 465e946f2e
commit b3d6540f13
15 changed files with 89 additions and 40 deletions
-1
View File
@@ -52,7 +52,6 @@ char *EFArgTech = NULL; /* -T: Tech specified on command line */
/* Misc globals */
float EFScale = 0.0; /* Uninitialized scale factor */
char *EFVersion = MAGIC_VERSION;/* Version number of .ext format we read */
char *EFLibPath = NULL; /* Library search path for .ext files */
char *EFTech = NULL;
char *EFStyle = NULL; /* Start with no extraction style */
+1 -1
View File
@@ -575,7 +575,7 @@ resistChanged:
/* version version-number */
case VERSION:
if (strcmp(argv[1], EFVersion) != 0)
if (strcmp(argv[1], MagicVersion) != 0)
{
efReadError(
"Cell was extracted using version %s of the extractor.\n", argv[1]);
-1
View File
@@ -32,7 +32,6 @@ extern char *EFTech; /* Technology of extracted circuit */
extern char *EFStyle; /* Extraction style of extracted circuit */
extern char *EFSearchPath; /* Path to search for .ext files */
extern char *EFLibPath; /* Library search path */
extern char *EFVersion; /* Version of extractor we work with */
extern char *EFArgTech; /* Tech file given as command line argument */
extern bool EFCompat; /* Subtrate backwards-compatibility mode */