Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ build --copt "-Wno-dangling" --host_copt "-Wno-dangling"
build --per_file_copt=.*external/.*@-w
build --host_per_file_copt=.*external/.*@-w

##### Platform-specific configs (auto-selected) #############
# --enable_platform_specific_config makes bazel automatically apply
# build:macos on macOS, build:linux on Linux, etc.
common --enable_platform_specific_config

# macOS: boost.stacktrace needs this since backtrace() doesn't require GNU source
build:macos --copt=-DBOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED
build:macos --host_copt=-DBOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED
# Aligned allocation/deallocation for abseil is only available since 10.13
build:macos --macos_minimum_os=10.13
build:macos --host_macos_minimum_os=10.13

# Settings for --config=asan address sanitizer build
build:asan --strip=never
build:asan --copt=-fsanitize=address
Expand Down
3 changes: 2 additions & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")
load("//bazel:notification.bzl", "notification_rule")
load("//bazel:python_wrap_cc.bzl", "PYTHON_STABLE_API_DEFINE", "python_wrap_cc")
load("//bazel:python_wrap_cc.bzl", "PYTHON_EXTENSION_LINKOPTS", "PYTHON_STABLE_API_DEFINE", "python_wrap_cc")
load("//bazel:tcl_encode_or.bzl", "tcl_encode")
load("//bazel:tcl_wrap_cc.bzl", "tcl_wrap_cc")

Expand Down Expand Up @@ -283,6 +283,7 @@ cc_binary(
name = "_openroadpy.so",
srcs = [":openroad_swig-py"],
defines = [PYTHON_STABLE_API_DEFINE],
linkopts = PYTHON_EXTENSION_LINKOPTS,
linkshared = True,
deps = [
":openroad_lib", # Depends on the core odb C++ library
Expand Down
8 changes: 8 additions & 0 deletions bazel/python_wrap_cc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ PythonSwigInfo = provider(

PYTHON_STABLE_API_DEFINE = "Py_LIMITED_API=0x030A0000"

PYTHON_EXTENSION_LINKOPTS = select({
"@platforms//os:macos": [
"-undefined",
"dynamic_lookup",
],
"//conditions:default": [],
})

def _get_transitive_srcs(srcs, deps):
return depset(
srcs,
Expand Down
4 changes: 2 additions & 2 deletions src/OpenRoad-py.i
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ get_db_block();

%}

%include "Exception-py.i"

%template(Corners) std::vector<sta::Scene*>;
%template(MTerms) std::vector<odb::dbMTerm*>;
%template(Masters) std::vector<odb::dbMaster*>;

%include "Exception-py.i"
%include "ord/Tech.h"
%include "ord/Design.h"
%include "ord/Timing.h"
Expand Down
3 changes: 2 additions & 1 deletion src/gpl/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
load("@openroad_rules_python//python:defs.bzl", "py_library")
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("//bazel:python_wrap_cc.bzl", "PYTHON_STABLE_API_DEFINE", "python_wrap_cc")
load("//bazel:python_wrap_cc.bzl", "PYTHON_EXTENSION_LINKOPTS", "PYTHON_STABLE_API_DEFINE", "python_wrap_cc")
load("//bazel:tcl_encode_or.bzl", "tcl_encode")
load("//bazel:tcl_wrap_cc.bzl", "tcl_wrap_cc")

Expand Down Expand Up @@ -95,6 +95,7 @@ cc_binary(
],
defines = [PYTHON_STABLE_API_DEFINE],
includes = ["src"],
linkopts = PYTHON_EXTENSION_LINKOPTS,
linkshared = True,
deps = [
"//src/gpl",
Expand Down
3 changes: 2 additions & 1 deletion src/odb/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
load("@openroad_rules_python//python:defs.bzl", "py_library")
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("//bazel:python_wrap_cc.bzl", "PYTHON_STABLE_API_DEFINE", "python_wrap_cc")
load("//bazel:python_wrap_cc.bzl", "PYTHON_EXTENSION_LINKOPTS", "PYTHON_STABLE_API_DEFINE", "python_wrap_cc")
load("//bazel:tcl_encode_or.bzl", "tcl_encode")
load("//bazel:tcl_wrap_cc.bzl", "tcl_wrap_cc")

Expand Down Expand Up @@ -105,6 +105,7 @@ cc_binary(
srcs = [":swig-py"],
defines = [PYTHON_STABLE_API_DEFINE],
includes = ["src/swig/common"],
linkopts = PYTHON_EXTENSION_LINKOPTS,
linkshared = True,
deps = [
":odb", # Depends on the core odb C++ library
Expand Down
14 changes: 9 additions & 5 deletions src/odb/test/write_def58_gzip.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ set out_gzip_def [make_result_file "write_def58_gzip.zipped.def.gz"]
write_def $out_gzip_def

exec gunzip -f $out_gzip_def
set def0 [exec md5sum $out_def]
set def1 [exec md5sum [string range $out_gzip_def 0 end-3]]
set unzipped_def [string range $out_gzip_def 0 end-3]

set f0 [open $out_def r]
set def0 [read $f0]
close $f0

set f1 [open $unzipped_def r]
set def1 [read $f1]
close $f1
Comment on lines +16 to +22

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

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
}


# Remove filename from output
set def0 [string range $def0 0 32]
set def1 [string range $def1 0 32]
if { $def0 == $def1 } {
puts "Matched"
puts "pass"
Expand Down
3 changes: 2 additions & 1 deletion src/utl/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
load("@openroad_rules_python//python:defs.bzl", "py_library")
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("//bazel:python_wrap_cc.bzl", "PYTHON_STABLE_API_DEFINE", "python_wrap_cc")
load("//bazel:python_wrap_cc.bzl", "PYTHON_EXTENSION_LINKOPTS", "PYTHON_STABLE_API_DEFINE", "python_wrap_cc")
load("//bazel:tcl_encode_or.bzl", "tcl_encode")
load("//bazel:tcl_wrap_cc.bzl", "tcl_wrap_cc")

Expand Down Expand Up @@ -105,6 +105,7 @@ cc_binary(
],
defines = [PYTHON_STABLE_API_DEFINE],
includes = ["src"],
linkopts = PYTHON_EXTENSION_LINKOPTS,
linkshared = True,
deps = [
"//src/utl",
Expand Down
2 changes: 1 addition & 1 deletion test/regression_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ case "$TEST_TYPE" in
esac

echo "Command: $CMD"
$CMD |& tee $LOG_FILE
$CMD 2>&1 | tee $LOG_FILE

echo "Exitcode: $?"

Expand Down
2 changes: 1 addition & 1 deletion third-party/abc
Submodule abc updated 3 files
+2 −2 BUILD
+3 −0 MODULE.bazel
+0 −5 WORKSPACE
Loading