From d1d0e097f97aaae7d24ebbc8bdd1e8d5f9e97007 Mon Sep 17 00:00:00 2001 From: James Cherry Date: Thu, 2 Jan 2025 15:20:41 -0800 Subject: [PATCH] survive tcl9 damage infliced by homebrew/OpenROAD DependencyInstaller commit b08f24685f52d242985c1c1f48c5b3821728d355 Author: James Cherry Date: Thu Jan 2 15:18:46 2025 -0800 tcl9 conditional support Signed-off-by: James Cherry commit bc0ebaa856196d09ea95cbd4e12e4d88b8a8d13e Author: James Cherry Date: Thu Jan 2 11:33:46 2025 -0800 tcl9 partial support Signed-off-by: James Cherry Signed-off-by: James Cherry --- CMakeLists.txt | 2 +- README.md | 13 ++++++-- cmake/FindTCL.cmake | 5 +-- tcl/StaTclTypes.i | 28 +++++++++------- util/ReportTcl.cc | 78 ++++++++++++++++++++++++++++----------------- 5 files changed, 80 insertions(+), 46 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e8c3ccdf..e80a0ba3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -cmake_minimum_required (VERSION 3.9) +cmake_minimum_required (VERSION 3.10) if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.13) # Use standard target names cmake_policy(SET CMP0078 NEW) diff --git a/README.md b/README.md index 2edc943a..e5e39fc7 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ work, but these are the versions used for development. cmake 3.24.2 3.29.2 clang 15.0.0 gcc 11.4.0 -tcl 8.6 8.6.6 +tcl 8.6 8.6.16 swig 4.1.0 4.1.1 bison 3.8.2 3.8.2 flex 2.6.4 2.6.4 @@ -103,13 +103,22 @@ are illegal in c++17. External library dependencies: ``` - Ubuntu Macos license + Ubuntu Darwin License eigen 3.4.0 3.4.0 MPL2 required cudd 3.0.0 3.0.0 BSD required tclreadline 2.3.8 2.3.8 BSD optional zLib 1.2.5 1.2.8 zlib optional ``` +On Darwin/MacOS the Xcode supplied versions of Tcl, Flex and Bison are +problematic. Use homebrew to install them instead. + + brew install cmake bison flex swig tcl-tk@8 eigen zlib + +Note that the most recent versions of homebrew install Tcl9, which is +not supported because swig does not support it yet. Install tcl8 as +shown above. + The [TCL readline library](https://tclreadline.sourceforge.net/tclreadline.html) links the GNU readline library to the TCL interpreter for command line editing On OSX, Homebrew does not support tclreadline, but the macports system does diff --git a/cmake/FindTCL.cmake b/cmake/FindTCL.cmake index 33104447..46d61f33 100644 --- a/cmake/FindTCL.cmake +++ b/cmake/FindTCL.cmake @@ -22,7 +22,8 @@ # because there doesn't appear to be a way to override # searching OSX system directories before unix directories. -set(TCL_POSSIBLE_NAMES tcl87 tcl8.7 +set(TCL_POSSIBLE_NAMES + tcl87 tcl8.7 tcl86 tcl8.6 tcl85 tcl8.5 ) @@ -30,7 +31,7 @@ set(TCL_POSSIBLE_NAMES tcl87 tcl8.7 # tcl lib path guesses. if (NOT TCL_LIB_PATHS) if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") - set(TCL_LIB_PATHS /usr/local/lib /opt/homebrew/opt/tcl-tk/lib) + set(TCL_LIB_PATHS /opt/homebrew/Cellar/tcl-tk@8/8.6.16/lib /opt/homebrew/opt/tcl-tk/lib /usr/local/lib) set(TCL_NO_DEFAULT_PATH TRUE) elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux") set(TCL_LIB_PATHS /usr/lib /usr/lib64 /usr/local/lib) diff --git a/tcl/StaTclTypes.i b/tcl/StaTclTypes.i index 541be2ae..2526b548 100644 --- a/tcl/StaTclTypes.i +++ b/tcl/StaTclTypes.i @@ -48,13 +48,17 @@ namespace sta { typedef MinPulseWidthCheckSeq::Iterator MinPulseWidthCheckSeqIterator; typedef MinMaxAll MinMaxAllNull; +#if TCL_MAJOR_VERSION < 9 + typedef int Tcl_Size; +#endif + template Vector * tclListSeqPtr(Tcl_Obj *const source, swig_type_info *swig_type, Tcl_Interp *interp) { - int argc; + Tcl_Size argc; Tcl_Obj **argv; if (Tcl_ListObjGetElements(interp, source, &argc, &argv) == TCL_OK @@ -78,7 +82,7 @@ tclListSeq(Tcl_Obj *const source, swig_type_info *swig_type, Tcl_Interp *interp) { - int argc; + Tcl_Size argc; Tcl_Obj **argv; std::vector seq; @@ -100,7 +104,7 @@ tclListSetPtr(Tcl_Obj *const source, swig_type_info *swig_type, Tcl_Interp *interp) { - int argc; + Tcl_Size argc; Tcl_Obj **argv; if (Tcl_ListObjGetElements(interp, source, &argc, &argv) == TCL_OK && argc > 0) { @@ -123,7 +127,7 @@ tclListSet(Tcl_Obj *const source, swig_type_info *swig_type, Tcl_Interp *interp) { - int argc; + Tcl_Size argc; Tcl_Obj **argv; if (Tcl_ListObjGetElements(interp, source, &argc, &argv) == TCL_OK && argc > 0) { @@ -147,7 +151,7 @@ tclListNetworkSet(Tcl_Obj *const source, Tcl_Interp *interp, const Network *network) { - int argc; + Tcl_Size argc; Tcl_Obj **argv; if (Tcl_ListObjGetElements(interp, source, &argc, &argv) == TCL_OK && argc > 0) { @@ -171,7 +175,7 @@ tclListNetworkSet1(Tcl_Obj *const source, Tcl_Interp *interp, const Network *network) { - int argc; + Tcl_Size argc; Tcl_Obj **argv; SET_TYPE set(network); if (Tcl_ListObjGetElements(interp, source, &argc, &argv) == TCL_OK @@ -190,7 +194,7 @@ static StringSet * tclListSetConstChar(Tcl_Obj *const source, Tcl_Interp *interp) { - int argc; + Tcl_Size argc; Tcl_Obj **argv; if (Tcl_ListObjGetElements(interp, source, &argc, &argv) == TCL_OK) { @@ -210,7 +214,7 @@ static StringSeq * tclListSeqConstChar(Tcl_Obj *const source, Tcl_Interp *interp) { - int argc; + Tcl_Size argc; Tcl_Obj **argv; if (Tcl_ListObjGetElements(interp, source, &argc, &argv) == TCL_OK) { @@ -230,7 +234,7 @@ static StdStringSet * tclListSetStdString(Tcl_Obj *const source, Tcl_Interp *interp) { - int argc; + Tcl_Size argc; Tcl_Obj **argv; if (Tcl_ListObjGetElements(interp, source, &argc, &argv) == TCL_OK) { @@ -909,7 +913,7 @@ using namespace sta; } %typemap(in) FloatSeq* { - int argc; + Tcl_Size argc; Tcl_Obj **argv; FloatSeq *floats = nullptr; @@ -954,7 +958,7 @@ using namespace sta; } %typemap(in) IntSeq* { - int argc; + Tcl_Size argc; Tcl_Obj **argv; IntSeq *ints = nullptr; @@ -1582,7 +1586,7 @@ using namespace sta; %typemap(in) ArcDcalcArgSeq { Tcl_Obj *const source = $input; - int argc; + Tcl_Size argc; Tcl_Obj **argv; Sta *sta = Sta::sta(); diff --git a/util/ReportTcl.cc b/util/ReportTcl.cc index 83173070..80c06f1a 100644 --- a/util/ReportTcl.cc +++ b/util/ReportTcl.cc @@ -31,14 +31,16 @@ using ::Tcl_GetChannelType; extern "C" { +#if TCL_MAJOR_VERSION >= 9 +#define CONST84 const +#endif + static int encapOutputProc(ClientData instanceData, CONST84 char *buf, int toWrite, int *errorCodePtr); static int -encapCloseProc(ClientData instanceData, Tcl_Interp *interp); -static int encapSetOptionProc(ClientData instanceData, Tcl_Interp *interp, CONST84 char *optionName, @@ -53,11 +55,6 @@ encapInputProc(ClientData instanceData, char *buf, int bufSize, int *errorCodePtr); -static int -encapSeekProc(ClientData instanceData, - long offset, - int seekMode, - int *errorCodePtr); static void encapWatchProc(ClientData instanceData, int mask); static int @@ -66,15 +63,34 @@ encapGetHandleProc(ClientData instanceData, ClientData *handlePtr); static int encapBlockModeProc(ClientData instanceData, int mode); + +#if TCL_MAJOR_VERSION < 9 +static int +encapCloseProc(ClientData instanceData, Tcl_Interp *interp); +static int +encapSeekProc(ClientData instanceData, + long offset, + int seekMode, + int *errorCodePtr); +#endif + } // extern "C" Tcl_ChannelType tcl_encap_type_stdout = { - const_cast("file"), - TCL_CHANNEL_VERSION_4, + "file", + TCL_CHANNEL_VERSION_5, +#if TCL_MAJOR_VERSION < 9 encapCloseProc, +#else + nullptr, // closeProc unused +#endif encapInputProc, encapOutputProc, +#if TCL_MAJOR_VERSION < 9 encapSeekProc, +#else + nullptr, // close2Proc +#endif encapSetOptionProc, encapGetOptionProc, encapWatchProc, @@ -228,17 +244,6 @@ encapInputProc(ClientData, return -1; } -static int -encapCloseProc(ClientData instanceData, - Tcl_Interp *) -{ - ReportTcl *report = reinterpret_cast(instanceData); - report->logEnd(); - report->redirectFileEnd(); - report->redirectStringEnd(); - return 0; -} - static int encapSetOptionProc(ClientData, Tcl_Interp *, @@ -257,15 +262,6 @@ encapGetOptionProc(ClientData, return 0; } -static int -encapSeekProc(ClientData, - long, - int, - int *) -{ - return -1; -} - static void encapWatchProc(ClientData, int) { @@ -286,4 +282,28 @@ encapBlockModeProc(ClientData, return 0; } +#if TCL_MAJOR_VERSION < 9 + +static int +encapCloseProc(ClientData instanceData, + Tcl_Interp *) +{ + ReportTcl *report = reinterpret_cast(instanceData); + report->logEnd(); + report->redirectFileEnd(); + report->redirectStringEnd(); + return 0; +} + +static int +encapSeekProc(ClientData, + long, + int, + int *) +{ + return -1; +} + +#endif + } // namespace sta