Skip to content

Conversation

@hzeller
Copy link
Contributor

@hzeller hzeller commented Sep 23, 2025

To be fixed later, but this way it is already documented. (what needs to be done is probably break out the libraries in the BUILD file better).

@github-actions
Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

To be fixed later, but this way it is already documented.
(what needs to be done is probably break out the libraries
in the BUILD file better).

Signed-off-by: Henner Zeller <[email protected]>
@hzeller hzeller force-pushed the feature-20250923-document-cyclic branch from 206cef2 to 55b2b1f Compare September 23, 2025 07:58
@github-actions
Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@maliberty
Copy link
Member

It would be helpful to state the actual symbols involved in the circular dependency.

@hzeller
Copy link
Contributor Author

hzeller commented Sep 23, 2025

I mentioned one in one of the files (sta::Cell), but there were a few more that all required dbSta.hh (currently off computer, but can have a look later)

@maliberty
Copy link
Member

You can get that from sta/include/sta/NetworkClass.hh

@hzeller
Copy link
Contributor Author

hzeller commented Sep 23, 2025

Ok, looked
both need sta::Cell and sta::Instance

NetwokClass.hh only has a forward declare, not a definition.

@maliberty
Copy link
Member

There is no definition - it is just used for type puning.

@hzeller
Copy link
Contributor Author

hzeller commented Sep 23, 2025

yes, but even opaque types should be defined (like what you do in dbSta.hh; and the comment even gives a reason why this is needed for the RTTI constructs).

@maliberty
Copy link
Member

As it states there

// talking to the OpenSTA author about implementing these
// upstream instead.

is the right fix. Putting it in dbSta was a hack and causes the cycles you see. @QuantamHD what came of those discussions? We can put it in our fork if necessary.

@hzeller
Copy link
Contributor Author

hzeller commented Sep 24, 2025

This might be one of the cases where a Macro can improve readability because it describes the intent.
I am thinking of something like this:

#define MAKE_OPAQUE_TYPE(T)                     \
class T                                         \
{                                               \
 public:                                        \
  T() = delete;                                 \
}

MAKE_OPAQUE_TYPE(Cell);
MAKE_OPAQUE_TYPE(Instance);
// ...
#undef  MAKE_OPAQUE_TYPE

Since it will not only improve the use of the types in RTTI context, but also strictly improve the readability, it might be easier to upstream such change to sta/NetworkClass.hh

@hzeller hzeller marked this pull request as draft September 30, 2025 07:25
@hzeller
Copy link
Contributor Author

hzeller commented Sep 30, 2025

Converting this to draft, as other includes should be used; but leaving it open so that we don't forget to move the opaque type stuff into sta.

@maliberty
Copy link
Member

I think the easiest way to break the cycle is to just move these defintions into their own header and make it a more base level dep than dbSta which is more high level.

@hzeller
Copy link
Contributor Author

hzeller commented Oct 15, 2025

w.r.t. #8407 (comment)

The change would be something like

--- a/include/sta/NetworkClass.hh
+++ b/include/sta/NetworkClass.hh
@@ -34,19 +34,29 @@
 
 namespace sta {
 
+#define MAKE_OPAQUE_TYPE(T)                     \
+class T                                         \
+{                                               \
+ public:                                        \
+  T() = delete;                                 \
+}
+
+MAKE_OPAQUE_TYPE(Cell);
+MAKE_OPAQUE_TYPE(Library);
+MAKE_OPAQUE_TYPE(Port);
+MAKE_OPAQUE_TYPE(Instance);
+MAKE_OPAQUE_TYPE(Pin);
+MAKE_OPAQUE_TYPE(Term);
+MAKE_OPAQUE_TYPE(Net);
+MAKE_OPAQUE_TYPE(ViewType);
+
+#undef  MAKE_OPAQUE_TYPE
+
 class Network;
 class NetworkEdit;
 class NetworkReader;
-class Library;
-class Cell;
-class Port;
 class PortDirection;
-class Instance;
-class Pin;
-class Term;
-class Net;
 class ConstantPinIterator;
-class ViewType;
 class LibertyLibrary;
 
 typedef Iterator<Library*> LibraryIterator;

should I file a PR against https://github.com/The-OpenROAD-Project/OpenSta or try to parallaxsw ?

@maliberty
Copy link
Member

I have no idea if you can get it into parallax but let's see. I would include a description of the motivating issue with RTTI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants