Skip to content

Commit 93f78df

Browse files
committed
fix: address gemini-code-assist nits on #4236
Two follow-ups from gemini's second review pass on #4236: * `setattr -unset src *` in `write_state_hash` only strips src attrs from objects in the *current* module. `write_state_hash` runs before `hierarchy -check -top` in synth_canonicalize.tcl, so the post-frontend design has many separate modules whose src attrs (= file:line metadata) survive the strip and end up in the hashed RTLIL, breaking path-independence between the bazel sandbox and the classic-make build. Use `*/*` which selects across all modules. * The genMetrics.py regex for the new hash was anchored to a bare `^`, while other extractors in the same file allow optional leading whitespace. Add `\s*` after `^` so the extraction is robust to any log wrapper that inserts indentation. Signed-off-by: Øyvind Harboe <oyvind@ascenium.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
1 parent fffb07a commit 93f78df

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

flow/scripts/synth_preamble.tcl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,14 @@ erase_non_stage_variables synth
1919
# the canonical-RTLIL write.
2020
proc write_state_hash { metric } {
2121
design -push
22-
setattr -unset src *
22+
# `*/*` strips src attrs across objects in *all* modules. Bare `*`
23+
# only targets the current module's objects, which is fine after
24+
# `hierarchy -check -top` collapses things to one design, but
25+
# `write_state_hash` is called before `hierarchy` here, so the
26+
# post-frontend state may have many separate modules whose src
27+
# attrs would otherwise survive into the hashed RTLIL and break
28+
# path-independence.
29+
setattr -unset src */*
2330
setattr -mod -unset src *
2431
set tmp $::env(OBJECTS_DIR)/.${metric}.tmp.rtlil
2532
write_rtlil $tmp

flow/util/genMetrics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ def extract_metrics(
280280
extractTagFromFile(
281281
"synth__post_read_sources__hash",
282282
metrics_dict,
283-
r"^synth__post_read_sources__hash:\s+([0-9a-f]{40})\s*$",
283+
r"^\s*synth__post_read_sources__hash:\s+([0-9a-f]{40})\s*$",
284284
logPath + "/1_1_yosys_canonicalize.log",
285285
t=str,
286286
required=False,

0 commit comments

Comments
 (0)