bazel macos - migrate tcl from rules_hdl to bazel BCR, fix linker problems, swig and regression for macos#9480
Conversation
There was a problem hiding this comment.
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.
| set f0 [open $out_def r] | ||
| set def0 [read $f0] | ||
| close $f0 | ||
|
|
||
| set f1 [open $unzipped_def r] | ||
| set def1 [read $f1] | ||
| close $f1 |
There was a problem hiding this comment.
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
}
|
Thanks for contributing. Commits need to be signed to pass DCO (use |
|
clang-tidy review says "All clean, LGTM! 👍" |
51a8ac2 to
65ed7ae
Compare
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>
65ed7ae to
5a7349e
Compare
I pushed the signed versions. Thanks for working on OpenROAD! |
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 //:openroadI 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:
I can also run the flow regression with
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)