diff --git a/.bazelrc b/.bazelrc index 33dedb14cac..534717c2733 100644 --- a/.bazelrc +++ b/.bazelrc @@ -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 diff --git a/BUILD.bazel b/BUILD.bazel index 370c9b36b75..3a69d8213df 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -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") @@ -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 diff --git a/bazel/python_wrap_cc.bzl b/bazel/python_wrap_cc.bzl index 43705d590cd..9af088824c7 100644 --- a/bazel/python_wrap_cc.bzl +++ b/bazel/python_wrap_cc.bzl @@ -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, diff --git a/src/OpenRoad-py.i b/src/OpenRoad-py.i index 17a2476835e..529b08ca7bf 100644 --- a/src/OpenRoad-py.i +++ b/src/OpenRoad-py.i @@ -47,11 +47,11 @@ get_db_block(); %} +%include "Exception-py.i" + %template(Corners) std::vector; %template(MTerms) std::vector; %template(Masters) std::vector; - -%include "Exception-py.i" %include "ord/Tech.h" %include "ord/Design.h" %include "ord/Timing.h" diff --git a/src/gpl/BUILD b/src/gpl/BUILD index f58041f238b..a761be270ea 100644 --- a/src/gpl/BUILD +++ b/src/gpl/BUILD @@ -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") @@ -95,6 +95,7 @@ cc_binary( ], defines = [PYTHON_STABLE_API_DEFINE], includes = ["src"], + linkopts = PYTHON_EXTENSION_LINKOPTS, linkshared = True, deps = [ "//src/gpl", diff --git a/src/odb/BUILD b/src/odb/BUILD index 427dd649cb9..edc14eeeca9 100644 --- a/src/odb/BUILD +++ b/src/odb/BUILD @@ -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") @@ -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 diff --git a/src/odb/test/write_def58_gzip.tcl b/src/odb/test/write_def58_gzip.tcl index 7f5b3ceba9a..5c97a02072f 100644 --- a/src/odb/test/write_def58_gzip.tcl +++ b/src/odb/test/write_def58_gzip.tcl @@ -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 -# 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" diff --git a/src/utl/BUILD b/src/utl/BUILD index c4bb280665a..31dcea32a52 100644 --- a/src/utl/BUILD +++ b/src/utl/BUILD @@ -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") @@ -105,6 +105,7 @@ cc_binary( ], defines = [PYTHON_STABLE_API_DEFINE], includes = ["src"], + linkopts = PYTHON_EXTENSION_LINKOPTS, linkshared = True, deps = [ "//src/utl", diff --git a/test/regression_test.sh b/test/regression_test.sh index 128d65b9820..5f483bd0885 100755 --- a/test/regression_test.sh +++ b/test/regression_test.sh @@ -23,7 +23,7 @@ case "$TEST_TYPE" in esac echo "Command: $CMD" -$CMD |& tee $LOG_FILE +$CMD 2>&1 | tee $LOG_FILE echo "Exitcode: $?" diff --git a/third-party/abc b/third-party/abc index 4c756ffb8df..a68b23c77d4 160000 --- a/third-party/abc +++ b/third-party/abc @@ -1 +1 @@ -Subproject commit 4c756ffb8dff7c583e80c7970d117abd3dfddb5c +Subproject commit a68b23c77d4c9b3947fcff9cdb7d509cad7fe46a