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

Auto generate symbols map #2517

Closed
wants to merge 32 commits into from
Closed

Auto generate symbols map #2517

wants to merge 32 commits into from

Conversation

wmww
Copy link
Contributor

@wmww wmww commented Jul 22, 2022

WIP attempt to auto-generate symbols.map and debian/*.symbols files based on doxygen data. Only file it tries to generate so far is miral/symbols.map, and that isn't complete enough to work yet.

@wmww wmww force-pushed the auto-generate-symbols-map branch from 0c0561a to e63fbfe Compare July 27, 2022 03:42
@wmww wmww changed the base branch from miral-bump-to-so-5 to main July 27, 2022 03:43
@wmww wmww force-pushed the auto-generate-symbols-map branch from e63fbfe to 2b175f3 Compare July 27, 2022 03:44
@wmww wmww marked this pull request as ready for review July 27, 2022 23:24
Copy link
Contributor

@RAOF RAOF left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems an interesting approach, but it looks like maybe there could be more smarts in the script and less lying in the comments? Particularly: it seems the script could take a “what is the MirAL SOVER” parameter, and use that as the version for all symbols either without “Since” annotations, or with annotations indicating a version less than SOVER?

That'd dramatically cut down the diff, remove the need to lie in comments, and reduce the amount of future diff needed, too?

/// \remark Since MirAL 2.4
/// \remark Since MirAL 3.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. This change is a lie, right? This was introduced in MirAL 2.4, but because we've bumped SONAME the symbols are for MIRAL_3.0?

And so, when we bump SONAME again (as we will soon), all the “Since” remarks will want to change to “MirAL 4.0”?

class WindowManagerTools
{
public:
explicit WindowManagerTools(WindowManagerToolsImplementation* tools);
explicit WindowManagerTools(miral::WindowManagerToolsImplementation* tools);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the failure mode if the (otherwise unnecessary) miral:: namespace specifier is left off here?

Copy link
Contributor Author

@wmww wmww Jul 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The miral:: doesn't make it into the symbol, because for some reason doxygen can't resolve it the way it can most things (presumably something to do with it being forward-declared?). Investing more work and complexity into fixing that didn't seem worth it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explained in comment

Copy link
Contributor

@AlanGriffiths AlanGriffiths left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bold attempt. But it is getting stuff wrong and the need for "Since" tags and "unnecessary" explicit naming will be high maintenance

@@ -31,6 +31,7 @@ namespace mir
* Note the reason parameter is a simple char* so its value is clearly visible
* in stack trace output.
* \remark There is no attempt to make this thread-safe, if it needs to be changed
* \remark Since MirCore 0.25
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want (nor should we need) "Since" annotations that date from before the current major version/SONAME.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exactly are you suggesting? Are you saying you prefer the current system of maintaining a separate file with symbols, or do you just want a different type of in-code annotation?

This PR comes out of discussions with RAOF where we concluded keeping export info alongside the symbols in the code would be nicer than in a separate file (in which case, all exported functions need to be annotated somehow). I suppose the generator could read a symbols.map file and leave previous stanzas as-is, but I like the idea of the generator being a pure function from source code to symbols.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems the script could take a “what is the MirAL SOVER” parameter, and use that as the version for all symbols either without “Since” annotations

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's less about the version, and more about knowing which symbols to export at all. If the version seems like clutter we could make a different annotation that doesn't include the version but still marks them for export.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's less about the version, and more about knowing which symbols to export at all. If the version seems like clutter we could make a different annotation that doesn't include the version but still marks them for export.

It isn't obvious why annotations are required, or even that they are a good, solution to this.

Symbols should be exported if they are:

  1. Declared in a public header;
  2. Accessible (i.e. namespace scope, public/protected static members, public/protected member functions);
  3. Not inline, nor template

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oooh, yeah. That's a nice approach!

There's the chance with 3. that they do need to be exported, but that's only for weird scenarios (eg: where something takes the address of the function) and I don't think we rely on any of that behaviour.

It seems that Doxygen collects that information, how hard would it be to use it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not very, that's used in regenerate-miral-symbols-map.py already

Comment on lines 422 to 426
(c++)"miral::WaylandExtensions::Context::Context()@MIRAL_3.6" 3.6.0
(c++)"miral::WaylandExtensions::Context::~Context()@MIRAL_3.6" 3.6.0
(c++)"vtable for miral::WaylandExtensions::Context@MIRAL_3.6" 3.6.0
(c++)"typeinfo for miral::WaylandExtensions::Context@MIRAL_3.6" 3.6.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong. WaylandExtensions::Context comes from MIRAL_2.5 - so it belongs in the 3.0 stanza

Comment on lines -197 to +200
auto create_workspace() -> std::shared_ptr<Workspace>;
auto create_workspace() -> std::shared_ptr<miral::Workspace>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not looked at fixing this, but I'm not a fan of adding noise to code where it isn't necessary (except for deficiencies in this toolchain).

vtable?for?miral::WindowSpecification::AspectRatio;
vtable?for?miral::X11Support;
vtable?for?miral::Zone;
"::SetApplicationAuthorizer(typename..., Args const&...)";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong: template<typename Policy> class SetApplicationAuthorizer is in namespace miral, and templates don't export symbols unless instantiated.

@wmww
Copy link
Contributor Author

wmww commented Aug 11, 2022

Ah, looks like we're not building the docs in CI. We need to do that for the test to pass.

@Saviq
Copy link
Collaborator

Saviq commented Sep 21, 2022

@wmww should this go on?

@wmww
Copy link
Contributor Author

wmww commented Sep 21, 2022

Lets try CI again so I can look at some logs.

@wmww
Copy link
Contributor Author

wmww commented Sep 21, 2022

I think it's worth doing, bug it needs a rework based on feedback. Haven't gotten back to that yet.

@Saviq
Copy link
Collaborator

Saviq commented Apr 24, 2024

@Saviq Saviq closed this Apr 24, 2024
@Saviq Saviq deleted the auto-generate-symbols-map branch April 24, 2024 11:50
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.

None yet

4 participants