Skip to content

Fix writability of 1_synth.sdc - #10818

Closed
hzeller wants to merge 1 commit into
The-OpenROAD-Project:masterfrom
hzeller:feature-20260705-make-writable
Closed

hzeller wants to merge 1 commit into
The-OpenROAD-Project:masterfrom
hzeller:feature-20260705-make-writable

Conversation

@hzeller

@hzeller hzeller commented Jul 5, 2026

Copy link
Copy Markdown
Collaborator

The 1_synth.sdc is copied from a template from the bazel input files, which are read-only. The exec cp then will copy the file which then is still read-only, thus the subsequent write will fail.

Make the file writable.

(this was discovered attempting to run in an RBE environment where the readonlyness of the inputs is very strict).

@hzeller
hzeller requested a review from a team as a code owner July 5, 2026 14:15
@hzeller
hzeller requested a review from osamahammad21 July 5, 2026 14:15
The `1_synth.sdc` is copied from a template from the bazel
input files, which are read-only. The `exec cp` then will copy
the file which then is still read-only, thus the subsequent
write will fail.

Make the file writable.

(this was discovered attempting to run in an RBE environment where
the readonlyness of the inputs is very strict).

Signed-off-by: Henner Zeller <h.zeller@acm.org>
@hzeller
hzeller force-pushed the feature-20260705-make-writable branch from 056d4a3 to 463c959 Compare July 5, 2026 14:16

@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 introduces a new patch, 0036-fix-sdc-readonly.patch, which ensures that the target SDC file is writable before attempting to write to it in synth_odb.tcl. The review feedback suggests using Tcl's built-in file attributes command instead of spawning an external chmod process to improve efficiency and portability.

# the user could have dependencies, such as sourcing util.tcl,
# which are read in here and a canonicalized version is written
# out by OpenSTA that has no dependencies.
+catch {exec chmod +w $::env(RESULTS_DIR)/1_synth.sdc}

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.

medium

Using exec chmod spawns an external process, which is less efficient and less portable than using Tcl's built-in file attributes command. Consider using file attributes -permissions u+w instead.

+catch {file attributes $::env(RESULTS_DIR)/1_synth.sdc -permissions u+w}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is just to fix the build, I am leaving this tweak up to @oharboe when he applies the fix upstream.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't see any downside to this change

@hzeller

hzeller commented Jul 5, 2026

Copy link
Copy Markdown
Collaborator Author

@oharboe looks good ?

@oharboe

oharboe commented Jul 5, 2026

Copy link
Copy Markdown
Collaborator

@oharboe looks good ?

It makes no sense to me.

Show the exact steps where this is a problem?

Why is this needed or useful and why is it not a much broader problem?

@hzeller

hzeller commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator Author

If you run the following test for instance:

bazel test -c opt //test/orfs/gcd:gcd_idempotent_test_cts

... and look at the log, you see that the 1_synth.sdc file is initially created by copying from the source directory

exec cp test/orfs/gcd/constraint.sdc bazel-out/k8-opt/bin/test/orfs/gcd/results/asap7/gcd/b/1_synth.sdc

... and then later attempted to be overwritten.

Of course, the original source-code is not writable, and it fact it is coming from a read-only filesystem when compiling in an RBE environment, so there is no write-bit on the input file. When copying, the non-set write bit is retained, and now we have a 1_synth.sdc file in the output that is read-only.
Later, the tcl-file attempts to open the very same file for writing and fails.

This is why we have to set the write-bit. Maybe there is something wrong in the logic and the first sdc file should never have been written, but I leave that test logic question to you. All i needed to make the test work is to make sure that the write call then can succeed.

The above-mentioned test is one of them, but since this code is used in other tests, about 25 tests fail to build on an RBE (and accidentally work when compiling locally).

@oharboe

oharboe commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

@hzeller You're using the ORFS idempotency tests I made 🥳

I'll have a look at this...

@oharboe

oharboe commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

I see what is going on... Fix coming up...

This PR should be closed, it is trying to treat a symptom of the underlying problem.

@hzeller

hzeller commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator Author

Closing, awaiting proper fix.

@oharboe

oharboe commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

@hzeller Root cause found: 1_synth.sdc had two writers. yosys' synth.tcl copies the user's SDC_FILE into place (a leftover from before SDC canonicalization existed), then synth_odb.tcl overwrites it in place with the OpenSTA-canonicalized version. cp preserves mode bits, so with RBE's read-only inputs the copy is read-only and the second write fails — locally it only accidentally works.

Proper fix is up as The-OpenROAD-Project/bazel-orfs#754: the yosys stage no longer produces 1_synth.sdc at all (its output is 1_2_yosys.sdc, the raw copy); synth_odb.tcl/synth_syn.tcl are the sole writers, carried as a bazel-orfs patch until the same fix lands in ORFS. It also stops bazel-orfs from touch-stubbing missing primary artifacts, so this class of problem fails the action immediately instead of surfacing as read-only/empty files downstream.

Once that merges, bazelisk run @bazel-orfs//:bump here picks it up — no chmod needed, so I'll close this PR in favor of that.

@oharboe

oharboe commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

The bump PR is up: #10823 (bazel-orfs pinned to the PR head ahead of its merge). bazelisk test //test/orfs/gcd/... passes 9/9 locally — @hzeller, if you get a chance, that branch should be directly testable on your RBE setup.

@hzeller

hzeller commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator Author

I see #10823 was closed without merge.
Are you still working on it ? it is still broken at head.

@oharboe

oharboe commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

I see #10823 was closed without merge. Are you still working on it ? it is still broken at head.

Fixed The-OpenROAD-Project/OpenROAD-flow-scripts#4333

@hzeller

hzeller commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator Author

Even with BAZEL_ORFS_COMMIT = "82f2aa4a486e95f6780c1ccc50ca5cf4cbce1689" I get the same issue

write_db bazel-out/k8-opt/bin/test/orfs/gcd/results/asap7/gcd/base/1_synth.odb
write_sdc -no_timestamp bazel-out/k8-opt/bin/test/orfs/gcd/results/asap7/gcd/base/1_synth.sdc
Error: synth_odb.tcl, 36 cannot write file bazel-out/k8-opt/bin/test/orfs/gcd/results/asap7/gcd/base/1_synth.sdc.
Target //test/orfs/gcd:gcd_whittle_test failed to build

grepping anything that looks like 1_synth it looks like there is still the copy of the constraint.sdc to 1_synth.sdc, creating a read-only copy of 1_synt.sdc

exec cp test/orfs/gcd/constraint.sdc bazel-out/k8-opt/bin/test/orfs/gcd/results/asap7/gcd/base/1_synth.sdc
external/orfs+/flow/scripts/flow.sh 1_synth synth_odb
Running synth_odb.tcl, stage 1_synth
write_db bazel-out/k8-opt/bin/test/orfs/gcd/results/asap7/gcd/base/1_synth.odb
write_sdc -no_timestamp bazel-out/k8-opt/bin/test/orfs/gcd/results/asap7/gcd/base/1_synth.sdc
Error: synth_odb.tcl, 36 cannot write file bazel-out/k8-opt/bin/test/orfs/gcd/results/asap7/gcd/base/1_synth.sdc.

@oharboe

oharboe commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

The fix is in ORFS not bazel-orfs

@oharboe

oharboe commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

@hzeller bazel-orfs != ORFS, you bumped bazel-orfs, fix is in ORFS. Claude ran the test locally, confirmed your problem and that bumping ORFS fixes it.

eder-matheus pushed a commit that referenced this pull request Jul 14, 2026
ORFS afad87da includes OpenROAD-flow-scripts#4333: yosys' synth.tcl no
longer copies SDC_FILE over 1_synth.sdc, so synth_odb.tcl's write_sdc
is the sole writer and no longer fails when bazel inputs are read-only
(RBE; cp preserves the missing write bit). Follow-up to #10818.

Drop 0035-orfs-bazel-orfs-visible-non-root.patch: upstreamed, @orfs now
declares its bazel-orfs bazel_dep non-dev.

Verified with chmod a-w test/orfs/gcd/constraint.sdc to emulate RBE's
read-only inputs: //test/orfs/gcd:gcd_synth fails before this change
with "cannot write file .../1_synth.sdc" and passes after.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
@hzeller

hzeller commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator Author

@hzeller bazel-orfs != ORFS, you bumped bazel-orfs, fix is in ORFS. Claude ran the test locally, confirmed your problem and that bumping ORFS fixes it.

Ah, this was because I followed #10896 (comment)
Looks like you fixed it in #10907 and it works now on my RBE set-up!

@oharboe

oharboe commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

@hzeller bazel-orfs != ORFS, you bumped bazel-orfs, fix is in ORFS. Claude ran the test locally, confirmed your problem and that bumping ORFS fixes it.

Ah, this was because I followed #10896 (comment) Looks like you fixed it in #10907 and it works now on my RBE set-up!

Yes, bazelisk run @bazel-orfs//:bump doesn't bump ORFS in OpenROAD. I think it should, can't see why not.

@oharboe

oharboe commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Fix: The-OpenROAD-Project/bazel-orfs#768 — bazelisk run @bazel-orfs//:bump now bumps ORFS_COMMIT (and its sha256) in OpenROAD's MODULE.bazel too, keeping the + ORFS_COMMIT concatenation intact. @hzeller

oharboe added a commit to The-OpenROAD-Project/bazel-orfs that referenced this pull request Jul 14, 2026
Running bazelisk run @bazel-orfs//:bump inside OpenROAD bumped
bazel-orfs but intentionally skipped ORFS, so picking up an ORFS fix
still required hand-editing ORFS_COMMIT (the sucker-punch behind
The-OpenROAD-Project/OpenROAD#10818 / #10907).

Drop the project-type gate on the ORFS bump and dispatch on the
override shape instead:

- git_override(orfs): unchanged.
- archive_override(orfs), literal commit in urls/strip_prefix
  (bazel-orfs's own MODULE.bazel): unchanged behavior, plus support
  for sha256-hex digests alongside SRI integrity.
- archive_override(orfs), commit held in a top-level variable
  concatenated into strip_prefix/urls (OpenROAD's shape): rewrite the
  variable assignment and the digest, leaving the concatenation
  intact.  The assignment rewrite is anchored at line start because
  BAZEL_ORFS_COMMIT contains ORFS_COMMIT as a substring and an
  unanchored substitution would clobber the just-bumped bazel-orfs
  pin.  A mixed shape (only one field referencing the variable) fails
  loudly rather than half-updating.

This also fixes a latent failure where a downstream project pinning
orfs via archive_override hit the git_override expectation and raised.

OpenROAD still never bumps its own commit: the tools loop only touches
an openroad bazel_dep, which OpenROAD's own MODULE.bazel doesn't have.
Its yosys dev_dependency pin now follows ORFS tools/yosys like any
other consumer.  (Follow-up idea: bump abc from YOSYS_ABC_PAIRS in
lockstep when both yosys and abc are declared.)

Verified against OpenROAD's real MODULE.bazel: with ORFS_COMMIT and
sha256 reset to stale values, bump restores exactly the values
hand-committed upstream, and a second run is a no-op.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants