From 47014fe68c208c62e578bdb18b7d44067db00e56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Harboe?= Date: Fri, 6 Nov 2026 11:04:52 +0100 Subject: [PATCH 1/2] synth: a partition can read its blackbox list from a file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A partition of a parallel synthesis takes the modules to blackbox in SYNTH_BLACKBOXES, one environment variable. Linux caps one environment string at 128 KiB (MAX_ARG_STRLEN): XiangShan's XSTile, synthesised with 2,250 kept modules, is 206 KB of names, and starting synthesis fails with "Argument list too long" on every partition. SYNTH_BLACKBOXES_FILE names a file with more modules to blackbox, one per line, added to SYNTH_BLACKBOXES. Signed-off-by: Øyvind Harboe --- docs/user/FlowVariables.md | 2 ++ flow/scripts/synth.tcl | 18 +++++++++++++++--- flow/scripts/variables.json | 6 ++++++ flow/scripts/variables.yaml | 7 +++++++ 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/docs/user/FlowVariables.md b/docs/user/FlowVariables.md index 449ec84425..d49fd3a84a 100644 --- a/docs/user/FlowVariables.md +++ b/docs/user/FlowVariables.md @@ -301,6 +301,7 @@ configuration file. | SWAP_ARITH_OPERATORS| Improve timing QoR by swapping ALU and MULT arithmetic operators.| 0| | SYNTH_ARGS| Optional synthesis variables for yosys.| | | SYNTH_BLACKBOXES| List of cells treated as a black box by Yosys. With Bazel, this can be used to run synthesis in parallel for the large modules of the design. Non-existant modules are ignored silently, useful when listing modules statically, even if modules come and go dynamically.| | +| SYNTH_BLACKBOXES_FILE| Path to a file with more modules to treat as black boxes, one name per line, added to SYNTH_BLACKBOXES. For a parallel synthesis whose list is too long for one environment variable: Linux caps one at 128 KiB.| | | SYNTH_CANONICALIZE_TCL| Specifies a Tcl script with commands to run as part of the synth canonicalize step.| | | SYNTH_CHECKPOINT| Path to a Yosys RTLIL checkpoint to read in place of the default canonicalization checkpoint at the start of synth.tcl. Intended for parallel synthesis flows that reuse a checkpoint taken after coarse synthesis and `keep_hierarchy` have already been decided, so each partition skips that common prefix. Leave unset for the normal flow.| | | SYNTH_GUT| Load design and remove all internal logic before doing synthesis. This is useful when creating a mock .lef abstract that has a smaller area than the amount of logic would allow. bazel-orfs uses this to mock SRAMs, for instance.| 0| @@ -374,6 +375,7 @@ configuration file. - [SKIP_REPORT_METRICS](#SKIP_REPORT_METRICS) - [SYNTH_ARGS](#SYNTH_ARGS) - [SYNTH_BLACKBOXES](#SYNTH_BLACKBOXES) +- [SYNTH_BLACKBOXES_FILE](#SYNTH_BLACKBOXES_FILE) - [SYNTH_CANONICALIZE_TCL](#SYNTH_CANONICALIZE_TCL) - [SYNTH_CHECKPOINT](#SYNTH_CHECKPOINT) - [SYNTH_GUT](#SYNTH_GUT) diff --git a/flow/scripts/synth.tcl b/flow/scripts/synth.tcl index f13789c04e..8455d6fbe8 100644 --- a/flow/scripts/synth.tcl +++ b/flow/scripts/synth.tcl @@ -58,10 +58,22 @@ if { [env_var_exists_and_non_empty SYNTH_CHECKPOINT] } { # the checkpoint. In synth_preamble.tcl a single design is being # synthesised, so an unknown name is almost certainly a user typo and # should fail loudly — `blackbox $m` without `catch` is intentional. -if { [env_var_exists_and_non_empty SYNTH_BLACKBOXES] } { - foreach m $::env(SYNTH_BLACKBOXES) { - catch { blackbox $m } +# +# An orchestrator with thousands of kept modules gives the list in a file +# instead, SYNTH_BLACKBOXES_FILE, one name per line: Linux caps one +# environment string at 128 KiB, and 2,250 names are 206 KB. +set synth_blackboxes [env_var_or_empty SYNTH_BLACKBOXES] +if { [env_var_exists_and_non_empty SYNTH_BLACKBOXES_FILE] } { + set fid [open $::env(SYNTH_BLACKBOXES_FILE) r] + foreach m [split [read $fid] "\n"] { + if { $m ne "" } { + lappend synth_blackboxes $m + } } + close $fid +} +foreach m $synth_blackboxes { + catch { blackbox $m } } hierarchy -check -top $::env(DESIGN_NAME) diff --git a/flow/scripts/variables.json b/flow/scripts/variables.json index 7ac2d93f3b..5a77ad501e 100644 --- a/flow/scripts/variables.json +++ b/flow/scripts/variables.json @@ -1327,6 +1327,12 @@ "synth" ] }, + "SYNTH_BLACKBOXES_FILE": { + "description": "Path to a file with more modules to treat as black boxes, one name per line, added to SYNTH_BLACKBOXES. For a parallel synthesis whose list is too long for one environment variable: Linux caps one at 128 KiB.\n", + "stages": [ + "synth" + ] + }, "SYNTH_CANONICALIZE_TCL": { "description": "Specifies a Tcl script with commands to run as part of the synth canonicalize step.\n", "stages": [ diff --git a/flow/scripts/variables.yaml b/flow/scripts/variables.yaml index a2119190de..ba04ae9376 100644 --- a/flow/scripts/variables.yaml +++ b/flow/scripts/variables.yaml @@ -372,6 +372,13 @@ SYNTH_BLACKBOXES: statically, even if modules come and go dynamically. stages: - synth +SYNTH_BLACKBOXES_FILE: + description: > + Path to a file with more modules to treat as black boxes, one name per + line, added to SYNTH_BLACKBOXES. For a parallel synthesis whose list is + too long for one environment variable: Linux caps one at 128 KiB. + stages: + - synth SYNTH_CHECKPOINT: description: > Path to a Yosys RTLIL checkpoint to read in place of the default From 38ebb93674ba692d5754bc0a6ae461c4ab8eb234 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Harboe?= Date: Fri, 6 Nov 2026 11:08:30 +0100 Subject: [PATCH 2/2] synth: read the blackbox file a line at a time, trimmed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A CRLF line or stray spaces would have made a name that blackbox then skipped silently. Signed-off-by: Øyvind Harboe --- flow/scripts/synth.tcl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flow/scripts/synth.tcl b/flow/scripts/synth.tcl index 8455d6fbe8..c33ef9019c 100644 --- a/flow/scripts/synth.tcl +++ b/flow/scripts/synth.tcl @@ -65,7 +65,8 @@ if { [env_var_exists_and_non_empty SYNTH_CHECKPOINT] } { set synth_blackboxes [env_var_or_empty SYNTH_BLACKBOXES] if { [env_var_exists_and_non_empty SYNTH_BLACKBOXES_FILE] } { set fid [open $::env(SYNTH_BLACKBOXES_FILE) r] - foreach m [split [read $fid] "\n"] { + while { [gets $fid line] >= 0 } { + set m [string trim $line] if { $m ne "" } { lappend synth_blackboxes $m }