Skip to content

make: immediately expand deferred vars, v2 - #4573

Open
gtkiku wants to merge 1 commit into
The-OpenROAD-Project:masterfrom
gtkiku:immediate-expand
Open

gtkiku wants to merge 1 commit into
The-OpenROAD-Project:masterfrom
gtkiku:immediate-expand

Conversation

@gtkiku

@gtkiku gtkiku commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Previous approach apparently caused some externally-defined variables to become overwritten, and modifications made in 72eca88 effectively reverted back to the old behaviour of spawning 28k shells for each make invocation. Try to cut that number down to 41 again by explicitly checking if the variables have been externally defined.


@oharboe Does this look alright? ifeq ($(origin ... should be identical to ?= according to the GNU Make manual, and passing variables from outside like PYTHON_EXE=... make ... seems to work on my machine.

Previous approach apparently caused some externally-defined variables to
become overwritten, and modifications made in 72eca88 effectively
reverted back to the old behaviour of spawning 28k shells for each
`make` invocation. Try to cut that number down to 41 again by explicitly
checking if the variables have been externally defined.

Signed-off-by: ctkiku <kim.kuparinen@tuni.fi>

@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 flow/scripts/variables.mk to replace the conditional variable assignment operator ?= with explicit ifeq ($(origin VAR), undefined) checks for PYTHON_EXE, OPENROAD_EXE, OPENSTA_EXE, and YOSYS_EXE. This ensures that these variables are only assigned default values if they are completely undefined, preventing unintended overrides. There are no review comments to assess, and I have no additional feedback to provide.

@oharboe

oharboe commented Sep 28, 2026

Copy link
Copy Markdown
Collaborator

Let me test it with bazel-orfs, which is my use-case

@openroad-ci

Copy link
Copy Markdown
Member

🔍 QoR check

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

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

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

❌ asap7/aes-mbff base — 2 failing metric(s)
Metric target base delta limit band
constraints__clocks__count 1 2 -50.0% 2 Direct 0%
globalroute__timing__setup__tns -269.882 -2.43366 10989.552361463804% -78.43366 PeriodPadding 20%
❌ asap7/ibex base — 4 failing metric(s)
Metric target base delta limit band
cts__timing__setup__tns -25560.4 0 — -200.0 PeriodPadding 20%
finish__timing__setup__tns -22264.4 0 — -200.0 PeriodPadding 20%
globalroute__timing__setup__tns -42980.7 -0.908162 4732612.886026942% -200.908162 PeriodPadding 20%
globalroute__timing__setup__ws -65.1011 -0.796807 8070.2469983320925% -50.796807 PeriodPadding 5.0%
❌ asap7/mock-cpu base — 6 failing metric(s)
Metric target base delta limit band
cts__timing__setup__tns -252.167 0 — -66.6 PeriodPadding 20%
cts__timing__setup__ws -33.5438 2.69612 -1344.1508538195628% -16.65 PeriodPadding 5.0%
finish__timing__setup__tns -269.7 0 — -66.6 PeriodPadding 20%
finish__timing__setup__ws -33.658 12.8525 -361.87901186539585% -16.65 PeriodPadding 5.0%
globalroute__timing__setup__tns -348.256 0 — -66.6 PeriodPadding 20%
globalroute__timing__setup__ws -41.411 2.35761 -1856.4822001942646% -16.65 PeriodPadding 5.0%
❌ gt2n/gcd base — 7 failing metric(s)
Metric target base delta limit band
cts__timing__setup__tns -786.696 0 — -100.0 PeriodPadding 20%
cts__timing__setup__ws -62.9036 158.356 -139.72290282654274% -25.0 PeriodPadding 5%
finish__timing__setup__tns -1187.76 0 — -100.0 PeriodPadding 20%
finish__timing__setup__ws -68.8317 150.061 -145.86914654707087% -25.0 PeriodPadding 5%
globalroute__timing__setup__tns -1187.75 0 — -100.0 PeriodPadding 20%
globalroute__timing__setup__ws -68.8299 150.061 -145.8679470348725% -25.0 PeriodPadding 5%
placeopt__design__instance__area 21.5127 18.5432 16.013956598645326% 21.32468 Padding 15%
❌ gt2n/jpeg base — 4 failing metric(s)
Metric target base delta limit band
cts__timing__setup__tns -15681.9 0 — -200.0 PeriodPadding 20%
cts__timing__setup__ws -60.0663 131.953 -145.52098095534015% -50.0 PeriodPadding 5%
finish__timing__setup__tns -4650.05 0 — -200.0 PeriodPadding 20%
globalroute__timing__setup__tns -4617.66 0 — -200.0 PeriodPadding 20%
❌ ihp-sg13g2/gcd base — 10 failing metric(s)
Metric target base delta limit band
cts__timing__setup__tns -6.49389 0 — -0.56 PeriodPadding 20%
cts__timing__setup__ws -0.215104 0.458359 -146.92915378556984% -0.14 PeriodPadding 5.0%
detailedroute__route__wirelength 12010 9892 21.411241407197735% 11375.8 Padding 15%
finish__design__instance__area 6686.06 5189.18 28.846176081770146% 5967.557 Padding 15%
finish__timing__setup__tns -6.98143 0 — -0.56 PeriodPadding 20%
finish__timing__setup__ws -0.239075 0.473577 -150.482814832646% -0.14 PeriodPadding 5.0%
globalroute__timing__setup__tns -12.1207 0 — -0.56 PeriodPadding 20%
globalroute__timing__setup__ws -0.397871 0.220928 -280.09079881228274% -0.14 PeriodPadding 5.0%
placeopt__design__instance__area 5858.7 4944.24 18.49546138536964% 5685.876 Padding 15%
placeopt__design__instance__count__stdcell 510 400 27.5% 460.0 Padding 15%
❌ ihp-sg13g2/jpeg base — 5 failing metric(s)
Metric target base delta limit band
cts__timing__setup__tns -21.4754 0 — -1.6 PeriodPadding 20%
cts__timing__setup__ws -0.542417 0.935878 -157.95808855427737% -0.4 PeriodPadding 5.0%
finish__timing__setup__tns -3.82476 0 — -1.6 PeriodPadding 20%
globalroute__timing__setup__tns -48.242 0 — -1.6 PeriodPadding 20%
placeopt__design__instance__count__stdcell 88817 76451 16.17506638238872% 87918.65 Padding 15%
❌ nangate45/cva6 base — 5 failing metric(s)
Metric target base delta limit band
cts__timing__setup__tns -5721.48 0 — -200.0 PeriodPadding 20%
detailedroute__route__wirelength 2414976 2069992 16.66595812930678% 2380490.8 Padding 15%
finish__timing__setup__tns -5764.63 0 — -200.0 PeriodPadding 20%
globalroute__timing__setup__tns -5855.95 0 — -200.0 PeriodPadding 20%
placeopt__design__instance__count__stdcell 118614 100935 17.515232575419823% 116075.25 Padding 15%
❌ sky130hd/ibex base — 6 failing metric(s)
Metric target base delta limit band
cts__timing__setup__tns -403.299 0 — -2.0 PeriodPadding 20%
cts__timing__setup__ws -0.675496 0.00169686 -39908.58762655729% -0.5 PeriodPadding 5.0%
finish__timing__setup__tns -330.156 -1.92918 17013.799645445215% -3.92918 PeriodPadding 20%
finish__timing__setup__ws -0.607174 -0.106836 468.3234115841102% -0.606836 PeriodPadding 5.0%
globalroute__timing__setup__tns -594.81 -0.091509 649901.6391830312% -2.091509 PeriodPadding 20%
globalroute__timing__setup__ws -0.834436 -0.0305391 2632.3529508073257% -0.5305391 PeriodPadding 5.0%

@oharboe

oharboe commented Sep 28, 2026

Copy link
Copy Markdown
Collaborator

Thanks. I tested this: it works, and it doesn't break bazel-orfs. It made me think about a direction that could make the Makefile more environment-agnostic, so that bazel-orfs, Nix and whatever comes next are all first-class, with no special case for any of them.

For one make print-… on nangate45/gcd:

before after
IN_NIX_SHELL=1 15 501 processes 38
plain ORFS 135 43
bazel-orfs 40 40

ORFS already has the mechanism, and bazel-orfs uses it: the environment sets OPENROAD_EXE, OPENSTA_EXE, YOSYS_EXE and PYTHON_EXE, and variables.mk only falls back to the in-tree install. Nix supports this natively, since mkShell exports any extra attribute as an environment variable:

devShells.default = pkgs.mkShell {
  buildInputs = [ ... ];
  OPENROAD_EXE = "${openroad.packages.${system}.default}/bin/openroad";
  OPENSTA_EXE  = "${openroad.packages.${system}.default}/bin/sta";
  YOSYS_EXE    = "${yosys.packages.${system}.default}/bin/yosys";
  PYTHON_EXE   = "${pkgs.python3}/bin/python3";
};

variables.mk then has one path for everyone. Each tool is one ?= pointing at the in-tree install, and whatever the environment supplies wins. With no $(shell) in those defaults they cost nothing and need no origin guard. PYTHON_EXE is the one default that still runs $(shell), so it gets := inside ifeq ($(origin PYTHON_EXE),undefined).

The comment block can carry that as the rule for the future: the environment supplies tool paths, whether it's bazel-orfs, a Nix shell or a user; defaults here never call $(shell). A default that must run a shell is assigned with := inside an origin guard.

One behaviour changes: a Nix shell other than ORFS's flake, with openroad on PATH, would set OPENROAD_EXE the same way every other environment does.

Would you be up for reshaping the PR that way? I don't have Nix to test the flake half.

Two more of the same kind, if you're in there anyway:

  • KLAYOUT_ENV_VAR_IN_PATH has no readers and is re-evaluated every time make exports its environment, so it can be deleted.
  • ihp-sg13g2's ABC_CLOCK_PERIOD_IN_PS ?= $(shell sed …) can be :=, since it's already inside an origin guard.

@oharboe

oharboe commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

@hzeller @maliberty FYI. TL;DR I think we should generalize and narrow the interface of ORFS to support nix and bazel-orfs as first class citizens rather than add more conditional code to the makefiles.

#4573 (comment)

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.

3 participants