Skip to content

flow: optional argument lists default to "" and are read without a guard - #4915

Open
oharboe wants to merge 1 commit into
The-OpenROAD-Project:masterfrom
oharboe:tcl-defaults-args
Open

oharboe wants to merge 1 commit into
The-OpenROAD-Project:masterfrom
oharboe:tcl-defaults-args

Conversation

@oharboe

@oharboe oharboe commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

The *_ARGS variables have no default in variables.yaml, so every script that reads one guards it with env_var_or_empty or env_var_exists_and_non_empty. This gives each one default: "" and reads it plainly. An argument list appended to a command is spliced with {*}$::env(X): an empty list splices to nothing, so no guard is needed at all.

variable script was now
BUFFER_PORTS_ARGS global_place.tcl env_var_or_empty {*}$::env(X)
GLOBAL_PLACEMENT_ARGS global_place.tcl, global_place_skip_io.tcl env_var_or_empty {*}$::env(X)
DETAIL_PLACEMENT_ARGS util.tcl (detailed_placement_helper) env_var_or_empty {*}$::env(X)
PLACE_PINS_ARGS io_placement.tcl, util.tcl env_var_or_empty $::env(X)
SYNTH_ARGS synth.tcl env_var_or_empty $::env(X)
SYNTH_VERILOG_SURGERY_ARGS util.tcl env_var_or_empty {*}$::env(X)
CTS_ARGS cts.tcl env_var_exists_and_non_empty $::env(X) ne ""
RTLMP_ARGS macro_place_util.tcl env_var_exists_and_non_empty $::env(X) ne ""
DETAILED_ROUTE_ARGS detail_route.tcl env_var_exists_and_non_empty $::env(X) ne ""
SYNTH_OPERATIONS_ARGS synth.tcl env_var_exists_and_non_empty $::env(X) ne ""

The last four replace the arguments the flow would pass (TclContract.md already says which *_ARGS replace and which append), so empty still means "use the flow's own" and they keep an explicit ne "" test. Every stage that reads each variable is already in its stages: list, so erase_non_stage_variables keeps it. No in-tree config.mk, platform or AutoTuner setting sets any of them to empty. FlowVariables.md renders default: "" as it renders no default, so it is unchanged. (CLUSTER_FLOPS_ARGS already has default: ""; its guard is dropped in #4912.)

TclContract.md gets the rule: an optional argument list defaults to "" and is spliced with {*}$::env(X); no guard is needed.

Why

Easier to read: {*}$::env(GLOBAL_PLACEMENT_ARGS) says what it does. Failures are hard and early: a misspelled or erased variable fails at the line that reads it, where today it silently passes nothing. And fewer squirrels for AI to chase: a helper call around a value that is always set is a code path no CI run takes, and an agent reading the scripts chases it instead of the real problem.

Test

Full flows to 6_report, master vs this branch, separate stages and KEEP_VARS=1, logs (runtimes, memory and paths dropped) and every stage metric compared:

design flow covers logs differing metrics differing
asap7/gcd separate / KEEP_VARS=1 gpl (-place_ios), dpl, cts, drt 0 / 0 0 / 0
nangate45/gcd separate / KEEP_VARS=1 yosys synth, gpl, dpl, cts, drt 0 / 0 0 / 0
nangate45/gcd GPL_PLACE_IOS=0 separate place_pins in io_placement 0 0
sky130hd/gcd separate same 0 0
asap7/riscv32i separate / KEEP_VARS=1 macros: rtl_macro_placer 0 / 0 0 / 0

Non-default values reach the command line, identically before and after (0 logs, 0 metrics differ):

  • asap7/gcd: BUFFER_PORTS_ARGS="-buffer_cell BUFx4_ASAP7_75t_R", GLOBAL_PLACEMENT_ARGS=-skip_initial_place, DETAIL_PLACEMENT_ARGS="-max_displacement 100", CTS_ARGS="... -sink_clustering_size 12", DETAILED_ROUTE_ARGS="-droute_end_iter 30 -drc_report_iter_step 5": the log shows global_placement ... -skip_initial_place, detailed_placement -max_displacement 100 (placement and the CTS re-legalization), clock_tree_synthesis -sink_clustering_enable -repair_clock_nets -sink_clustering_size 12 and the route arguments.
  • asap7/gcd PLACE_PINS_ARGS="-corner_avoidance 0": set_placer_config ... -io_pin_corner_avoidance 0; nangate45/gcd GPL_PLACE_IOS=0 PLACE_PINS_ARGS="-min_distance 2": place_pins ... -min_distance 2.
  • nangate45/gcd SYNTH_ARGS=-nofsm SYNTH_OPERATIONS_ARGS=-booth with a pass-through SYNTH_VERILOG_SURGERY and SYNTH_VERILOG_SURGERY_ARGS="--tag hello" (separate / KEEP_VARS=1): no FSM pass, the BOOTH pass runs, the surgery script gets --tag hello.
  • asap7/riscv32i RTLMP_ARGS="-max_num_level 1 -target_util 0.5" (separate / KEEP_VARS=1): rtl_macro_placer -max_num_level 1 -target_util 0.5.
  • asap7/picorv32 (sets SYNTH_OPERATIONS_ARGS=-booth): the BOOTH pass runs before and after. Its synthesis is not reproducible on master itself (two master runs: 17424 and 17466 instances), so it is not in the table.

Unset in a PRE_<STEP>_TCL hook (or a SYNTH_SCRIPT wrapper): master runs on with no arguments; this branch stops at the read, can't read "::env(X)": no such variable, for each of the ten.

tclint/tclfmt 0.9.0 are clean; flow/test test_generate_vars.py and test_make_issue.py pass; this merges cleanly with #4910, #4911, #4912, #4913 and #4914. (Every full-flow arm, before and after alike, stops at the final GDS merge, as the klayout Python module is not installed here.)

🤖 Generated with Claude Code

The *_ARGS variables lacked a default and were read through
env_var_or_empty or env_var_exists_and_non_empty. Give each one
`default: ""` and read it as $::env(X): an argument list appended to a
command is spliced with {*}$::env(X), which splices nothing when the
list is empty, so no guard is needed. The four that replace the
arguments the flow would pass (CTS_ARGS, RTLMP_ARGS,
DETAILED_ROUTE_ARGS, SYNTH_OPERATIONS_ARGS) are tested with
`$::env(X) ne ""`.

Appended: BUFFER_PORTS_ARGS, GLOBAL_PLACEMENT_ARGS,
DETAIL_PLACEMENT_ARGS, PLACE_PINS_ARGS, SYNTH_ARGS,
SYNTH_VERILOG_SURGERY_ARGS. Every stage that reads each of them is
already in its stages: list, so erase_non_stage_variables keeps it.

TclContract.md gets the rule.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Øyvind Harboe <[email protected]>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the Tcl contract documentation and refactors several Tcl scripts to simplify the handling of optional argument lists. Specifically, it removes the use of helper functions like env_var_or_empty and env_var_exists_and_non_empty in favor of direct environment variable splicing ({*}$::env(X)) and direct empty-string comparisons. To support this, default empty string values (default: "") have been added to the corresponding variables in variables.yaml. I have no feedback to provide as the changes are clean, consistent, and align perfectly with the updated style guidelines.

@openroad-ci

openroad-ci commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

🔍 QoR check

Metrics reflect the PR merge build — i.e. what will land on the target branch.

Commit 7798168 · Jenkins build #1 · Baseline: build · View build on dashboard

62 design(s) checked — 0 with regression(s), 0 without a comparable baseline.

✅ QoR is compared against the master build at this PR's merge base 58710a4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants