Skip to content

bazel macos - migrate tcl from rules_hdl to bazel BCR, fix linker problems, swig and regression for macos#9480

Open
fredowski wants to merge 6 commits intoThe-OpenROAD-Project:masterfrom
fredowski:bazel-macos
Open

bazel macos - migrate tcl from rules_hdl to bazel BCR, fix linker problems, swig and regression for macos#9480
fredowski wants to merge 6 commits intoThe-OpenROAD-Project:masterfrom
fredowski:bazel-macos

Conversation

@fredowski
Copy link

I fixed some parts of the bazel build on macos to be able to build the openroad commandline version and to run the regression. During that part I migrated tcl from the rules_hdl repository to the bazel BCR version. This includes the move to zlib from BCR. The tool starts (builds) with

bazelisk run //:openroad

I start the regression with

bazelisk test //src/...

and have

Executed 1117 out of 1157 tests: 1096 tests pass and 61 fail locally.

Most failures are in gpl (33), rmp (8) with some (small) deviations in numbers. This is what claude says:

  Full Regression Results: 1096 passed, 61 failed out of 1157 tests

  Failure categories:

  ┌────────┬───────┬──────────────────────────────────────────────────────────────────────────┐
  │ Module │ Count │                                Root Cause                                │
  ├────────┼───────┼──────────────────────────────────────────────────────────────────────────┤
  │ gpl    │ 33    │ Placement coordinate diffs (macOS ARM floating point differences)        │
  ├────────┼───────┼──────────────────────────────────────────────────────────────────────────┤
  │ rmp    │ 8     │ Likely similar numerical diffs from restructuring/ABC                    │
  ├────────┼───────┼──────────────────────────────────────────────────────────────────────────┤
  │ rsz    │ 3     │ Placement coordinate diffs (e.g. 96726 vs 96673)                         │
  ├────────┼───────┼──────────────────────────────────────────────────────────────────────────┤
  │ psm    │ 2     │ Numerical diffs                                                          │
  ├────────┼───────┼──────────────────────────────────────────────────────────────────────────┤
  │ odb    │ 1     │ md5sum command not found on macOS (needs md5 instead)                    │
  ├────────┼───────┼──────────────────────────────────────────────────────────────────────────┤
  │ utl    │ 1     │ Metrics server socket shutdown error (Boost.Asio test environment issue) │
  └────────┴───────┴──────────────────────────────────────────────────────────────────────────┘

  Analysis:

  - None of the failures are caused by our changes (the SWIG fix or the Tcl runfiles fix)
  - ~58 failures are cross-platform numerical differences — placement coordinates differ slightly between macOS ARM and the Linux x86
  reference. These are expected when running on a different platform.
  - 1 failure (odb:write_def58_gzip) is a macOS compatibility issue — the test uses md5sum which doesn't exist on macOS (it's md5 instead).
  - 1 failure (utl:utl_cfile_unittest) is a Boost.Asio socket test issue in the metrics server test, unrelated to our changes.

I can also run the flow regression with

MacBookProM4-2:OpenROAD fritz$ OPENROAD_EXE=/Users/fritz/OpenROAD/bazel-bin/openroad test/regression flow
------------------------------------------------------
Flow
gcd_nangate45 (tcl) pass
gcd_sky130hd (tcl) *FAIL* RSZ::repair_design_buffer_count    2 >    1 ; DRT::clock_skew  0.04 >  0.04
gcd_sky130hs (tcl) pass
gcd_asap7 (tcl) pass
ibex_sky130hd (tcl) *FAIL* DRT::max_slew_slack -39% < -15% ; DRT::max_capacitance_slack -44% <   0%
ibex_sky130hs (tcl) *FAIL* DRT::max_slew_slack -18% <  -2% ; DRT::max_capacitance_slack -20% <  -5%
aes_nangate45 (tcl) *FAIL* RSZ::max_capacitance_slack -25% <   0% ; DRT::clock_skew  0.10 >  0.09 ; DRT::max_capacitance_slack -30% < -19%
aes_sky130hd (tcl) *FAIL* DRT::clock_skew  0.64 >  0.56
aes_sky130hs (tcl) *FAIL* RSZ::hold_buffer_count  465 >  128
aes_asap7 (tcl) *FAIL* DRT::worst_slack_max -206.71 <= -117.20 ; DRT::max_slew_slack -118% < -31%
tinyRocket_nangate45 (tcl) pass
jpeg_sky130hs (tcl) *FAIL* DRT::ANT::errors   2 >   0
jpeg_sky130hd (tcl) *FAIL* DRT::max_slew_slack -23% < -20% ; DRT::max_capacitance_slack -23% <  -1%
------------------------------------------------------
Failed 9/13

and see some parts failing. I run this on a MacbookPro M4 with macos 15.7.3 (24G419)

I made some changes for the tcl migration on the sta and the abc submodule. In the meantime abc has changed and it works right away with the new abc version. But OpenSTA needs the tcl changes. The gui build on MacOS does not work. So this is only commandline and regression.

The OpenSTA changes are here: https://github.com/fredowski/OpenSTA/tree/bazel-macos
abc changes for the OpenRoad abc version: https://github.com/fredowski/abc/tree/bazel-macos (not needed)

Copy link
Contributor

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

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 successfully migrates the Tcl dependency from rules_hdl to the Bazel Central Registry (BCR), a significant step in modernizing the build system. It also introduces several fixes to enable building on macOS, including necessary linker flags for Python extensions and compiler definitions. The changes are extensive but largely consist of mechanical updates to BUILD files, replacing the old Tcl dependency. Additionally, a test script has been updated for better cross-platform compatibility. My review includes a suggestion to further improve the robustness of this test script's file handling.

Comment on lines +16 to +22
set f0 [open $out_def r]
set def0 [read $f0]
close $f0

set f1 [open $unzipped_def r]
set def1 [read $f1]
close $f1
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The change to compare file contents directly is great for cross-platform compatibility. However, the file handling can be made more robust. If an error occurs during the read command, the corresponding close command will not be executed, leading to a resource leak. It's better to use try...finally blocks to ensure files are always closed.

set f0 [open $out_def r]
try {
  set def0 [read $f0]
} finally {
  close $f0
}

set f1 [open $unzipped_def r]
try {
  set def1 [read $f1]
} finally {
  close $f1
}

@maliberty
Copy link
Member

Thanks for contributing. Commits need to be signed to pass DCO (use git commit -s to sign). To fix the commits in this PR click the DCO link for info.

@maliberty maliberty requested a review from QuantamHD February 16, 2026 21:16
@github-actions
Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Friedrich Beckmann added 6 commits February 16, 2026 23:30
For better compatibility with MacOS I changed the tcl library from
rules_hdl to bazel repository.

Signed-off-by: Friedrich Beckmann <friedrich.beckmann@tha.de>
Added -undefined dynamic_lookup linkopts on macOS for Python
extension .so targets. The reference symbols are resolved at
load time not link time. Without this the linker errors on
undefined Python symbols. The change affects only the macos
build.

Signed-off-by: Friedrich Beckmann <friedrich.beckmann@tha.de>
Moved %include "Exception-py.i" before %template declarations so
the Python exception handler is active when SWIG generates template
wrapper code. Without this the python tests in the regression fail
because the ask for tcl symbols.

Signed-off-by: Friedrich Beckmann <friedrich.beckmann@tha.de>
I rewrote the test to use pure tcl file reads and string
comparison. Now the test also works on macos.

Signed-off-by: Friedrich Beckmann <friedrich.beckmann@tha.de>
Signed-off-by: Friedrich Beckmann <friedrich.beckmann@tha.de>
Signed-off-by: Friedrich Beckmann <friedrich.beckmann@tha.de>
@fredowski
Copy link
Author

Thanks for contributing. Commits need to be signed to pass DCO (use git commit -s to sign). To fix the commits in this PR click the DCO link for info.

I pushed the signed versions. Thanks for working on OpenROAD!

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