Skip to content

Commit 2567161

Browse files
authored
This fixes a crash when using the OpenROAD GUI on macOS.
1 parent 695c013 commit 2567161

File tree

4 files changed

+95
-1
lines changed

4 files changed

+95
-1
lines changed

Changelog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@
1414
## Documentation
1515
-->
1616

17+
# 2.3.9
18+
19+
## Tool Updates
20+
21+
* Backported https://github.com/The-OpenROAD-Project/OpenROAD/pull/6743 to
22+
OpenROAD to fix GUI crashes on C++ standard libraries that are not libstdc++
23+
(aka: macOS.)
24+
1725
# 2.3.8
1826

1927
## Misc. Enhancements/Bugfixes

nix/openroad.nix

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@
5959
inherit rev;
6060
inherit sha256;
6161
};
62+
63+
patches = [
64+
./patches/openroad/6743.patch
65+
];
6266

6367
cmakeFlagsAll = [
6468
"-DTCL_LIBRARY=${tcl}/lib/libtcl${clangStdenv.hostPlatform.extensions.sharedLibrary}"

nix/patches/openroad/6743.patch

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
diff --git a/.gitignore b/.gitignore
2+
index b33f18f8ef8..8c881b0c8a5 100644
3+
--- a/.gitignore
4+
+++ b/.gitignore
5+
@@ -24,6 +24,8 @@ venv/
6+
include/ord/Version.hh
7+
8+
build
9+
+build_linux
10+
+build_mac
11+
test/results
12+
flow
13+
14+
diff --git a/src/gui/include/gui/gui.h b/src/gui/include/gui/gui.h
15+
index a182172d5f2..fa64aaf2832 100644
16+
--- a/src/gui/include/gui/gui.h
17+
+++ b/src/gui/include/gui/gui.h
18+
@@ -803,8 +803,32 @@ class Gui
19+
utl::Logger* logger_;
20+
odb::dbDatabase* db_;
21+
22+
+ // There are RTTI implementation differences between libstdc++ and libc++,
23+
+ // where the latter seems to generate multiple typeids for classes including
24+
+ // but not limited to sta::Instance* in different compile units. We have been
25+
+ // unable to remedy this.
26+
+ //
27+
+ // These classes are a workaround such that unless __GLIBCXX__ is set, hashing
28+
+ // and comparing are done on the type's name instead, which adds a negligible
29+
+ // performance penalty but has the distinct advantage of not crashing when an
30+
+ // Instance is clicked in the GUI.
31+
+ //
32+
+ // In the event the RTTI issue is ever resolved, the following two structs may
33+
+ // be removed.
34+
+ struct TypeInfoHasher
35+
+ {
36+
+ std::size_t operator()(const std::type_index& x) const;
37+
+ };
38+
+ struct TypeInfoComparator
39+
+ {
40+
+ bool operator()(const std::type_index& a, const std::type_index& b) const;
41+
+ };
42+
+
43+
// Maps types to descriptors
44+
- std::unordered_map<std::type_index, std::unique_ptr<const Descriptor>>
45+
+ std::unordered_map<std::type_index,
46+
+ std::unique_ptr<const Descriptor>,
47+
+ TypeInfoHasher,
48+
+ TypeInfoComparator>
49+
descriptors_;
50+
// Heatmaps
51+
std::set<HeatMapDataSource*> heat_maps_;
52+
diff --git a/src/gui/src/gui.cpp b/src/gui/src/gui.cpp
53+
index 4762022dd84..49a2f493086 100644
54+
--- a/src/gui/src/gui.cpp
55+
+++ b/src/gui/src/gui.cpp
56+
@@ -1336,6 +1336,26 @@ void Gui::updateTimingReport()
57+
main_window->getTimingWidget()->populatePaths();
58+
}
59+
60+
+// See class header for documentation.
61+
+std::size_t Gui::TypeInfoHasher::operator()(const std::type_index& x) const
62+
+{
63+
+#ifdef __GLIBCXX__
64+
+ return std::hash<std::type_index>{}(x);
65+
+#else
66+
+ return std::hash<std::string_view>{}(std::string_view(x.name()));
67+
+#endif
68+
+}
69+
+// See class header for documentation.
70+
+bool Gui::TypeInfoComparator::operator()(const std::type_index& a,
71+
+ const std::type_index& b) const
72+
+{
73+
+#ifdef __GLIBCXX__
74+
+ return a == b;
75+
+#else
76+
+ return strcmp(a.name(), b.name()) == 0;
77+
+#endif
78+
+}
79+
+
80+
class SafeApplication : public QApplication
81+
{
82+
public:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "openlane"
3-
version = "2.3.8"
3+
version = "2.3.9"
44
description = "An infrastructure for implementing chip design flows"
55
authors = ["Efabless Corporation and Contributors <[email protected]>"]
66
readme = "Readme.md"

0 commit comments

Comments
 (0)