Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extensible classes: how to be protected from inter-project name clashes for re-declared concrete classes #7390

Open
samolisov opened this issue Jun 21, 2024 · 0 comments

Comments

@samolisov
Copy link
Contributor

Hello everyone, actually this is not and issue (yet?), just a question.

In the amazing documentation about the concept of extensible classes, we can found the following wording (not cited, just meaning): concrete classes should be put in the common (TR:: in our case) namespace and the file name for the header with the class definition should be after the class' name. Also, we can (and do!) re-declare a concrete class between projects.

For example, omr containas the compiler/codegen/CodeGenerator.hpp header and the TR::CodeGenerator class is defined there. Also, openj9 contains the same header where the same class in defined. Unfortunately, I wasn't able to find an example of not header-only concrete class what would be re-declared between the projects, but I believe this example is enough: both CodeGenerator.hpp headers are included in many, many extensible classes in both projects and those classes have a corresponding .cpp implementation part.

So, the question is, whether there is an ODR violation and if so, how the omr and openj9 projects are protected? Because openj9 has omr as a dependency, omr should be built first and will have the compiler library with the corresponding object modules that contain the first definition of the TR::CodeGenerator class. When we build the openj9 project, it gets the its own compiler library, which will contain the second definition of the TR::CodeGenerator class. Then we link both projects and an ODR violation should be there. This is how I get the things.

What protect openj9 from the ODR violation with the upstream project? I believe this is the correct linking ordering for object modules and dependencies, but maybe I'm missing something?

Thank your very much for any help. I think the extensible classes concept is a great invention and would be glad to understand it deeply.

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

No branches or pull requests

1 participant