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

Restructure internal library dependencies (Fix #383) #794

Merged
merged 7 commits into from
Feb 10, 2021

Conversation

Hoikas
Copy link
Member

@Hoikas Hoikas commented Jan 27, 2021

This completely fixes #383. In order to do so, I began to reorder some of the include directives as specified in #788 to facilitate
easier inspection of the dependencies. The work on that proposal is not complete. Further, I broke several dependency loops where trivially possible by changing uses of derived classes to base classes and moving virtual function definitions into source files from headers.

This depends on #791 so I can test on Linux.

I suggest looking at some of the resulting CMakeLists, eg plClient's, and large include blocks, eg pfConsole, to understand the goal. Sorry for how gnarly the diff is 😢 .

@Hoikas Hoikas force-pushed the moar-link-libs branch 3 times, most recently from e2cef9d to d50cc1d Compare January 28, 2021 16:18
@Hoikas Hoikas requested a review from dpogue January 28, 2021 16:32
@Hoikas Hoikas marked this pull request as ready for review January 28, 2021 16:32
@Hoikas Hoikas changed the title WIP: Fix #383 Fix #383 Jan 28, 2021
@dpogue dpogue changed the title Fix #383 Restructure internal library dependencies (Fix #383) Jan 29, 2021
@Hoikas
Copy link
Member Author

Hoikas commented Feb 1, 2021

This has been rebased to merge cleanly after the great overriding.

Sources/Plasma/Apps/plFileEncrypt/CMakeLists.txt Outdated Show resolved Hide resolved
Sources/Plasma/Apps/plPageOptimizer/CMakeLists.txt Outdated Show resolved Hide resolved
Sources/Plasma/Apps/plPythonPack/CMakeLists.txt Outdated Show resolved Hide resolved
Sources/Plasma/Apps/plUruLauncher/CMakeLists.txt Outdated Show resolved Hide resolved
Sources/Plasma/FeatureLib/pfConsole/CMakeLists.txt Outdated Show resolved Hide resolved
Sources/Plasma/FeatureLib/pfPatcher/CMakeLists.txt Outdated Show resolved Hide resolved
Sources/Plasma/FeatureLib/pfPython/CMakeLists.txt Outdated Show resolved Hide resolved
Sources/Plasma/NucleusLib/inc/CMakeLists.txt Outdated Show resolved Hide resolved
Sources/Plasma/NucleusLib/pnNetCommon/CMakeLists.txt Outdated Show resolved Hide resolved
Sources/Plasma/PubUtilLib/plAnimation/CMakeLists.txt Outdated Show resolved Hide resolved
@Hoikas Hoikas force-pushed the moar-link-libs branch 2 times, most recently from d96e99a to 4117f43 Compare February 7, 2021 01:32
@Hoikas
Copy link
Member Author

Hoikas commented Feb 7, 2021

Rebased to merge cleanly after the good de-tarray-izing.

Copy link
Member

@zrax zrax left a comment

Choose a reason for hiding this comment

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

[...] moving virtual function definitions into source files from headers

I'm curious why? There's nothing wrong with inlining a virtual function, and modern compilers can even apply devirtualization to an inline virtual function if it knows it can correctly assume the applicable override.

Sources/Tools/MaxMain/plAgeDescInterface.cpp Show resolved Hide resolved
Sources/Plasma/PubUtilLib/plSDL/plStateDataRecord.cpp Outdated Show resolved Hide resolved
Sources/Plasma/PubUtilLib/plSDL/plSDLMgr.cpp Outdated Show resolved Hide resolved
@Hoikas
Copy link
Member Author

Hoikas commented Feb 8, 2021

I'm curious why? There's nothing wrong with inlining a virtual function, and modern compilers can even apply devirtualization to an inline virtual function if it knows it can correctly assume the applicable override.

I was hoping to reduce the size of the dependency graph from headers. In some cases it was fairly successful - by moving IO virtual functions into cpp files, I was able to, for example, avoid other headers pulling in all of st_format from plFileSystem via hsStream. Given the use pattern of Read() and Write(), I don't think the compiler will be able to trivially inline those calls. 😄 Given non-trivial code, I think I'd prefer for something like #810 to allow inlining at link-time as opposed to having large function definitions in headers.

@Hoikas Hoikas force-pushed the moar-link-libs branch 2 times, most recently from a128bd9 to 21c2b99 Compare February 8, 2021 23:54
@zrax
Copy link
Member

zrax commented Feb 9, 2021

I was hoping to reduce the size of the dependency graph from headers. In some cases it was fairly successful - by moving IO virtual functions into cpp files, I was able to, for example, avoid other headers pulling in all of st_format from plFileSystem via hsStream. Given the use pattern of Read() and Write(), I don't think the compiler will be able to trivially inline those calls. 😄 Given non-trivial code, I think I'd prefer for something like #810 to allow inlining at link-time as opposed to having large function definitions in headers.

Ah, that makes sense... I had thought you were trying to remove every virtual function from header files, which seemed excessive to me.

@Hoikas
Copy link
Member Author

Hoikas commented Feb 9, 2021

Yeah, I think any small function that's just a few lines long is fine in a header, especially if it's something we actively want inlined. It's a judgement call based off the length of the function and if that function needed specific or large #includes, IMO.

@Hoikas Hoikas force-pushed the moar-link-libs branch 2 times, most recently from cdae253 to 44e7d64 Compare February 10, 2021 04:17
This fixes the majority of H-uru#383. In order to do so, I began to reorder
some of the include directives as specified in H-uru#788 to facillitate
easier inspection of the dependencies. The work is not complete at all.
Further, I broke several dependencies where trivially possible by
changing uses of derived classes to base classes and moving virtual
function definitions into source files from headers.

The diff is unpleasant, I know :(
Always link against ye olde CoreLib and thou shalt be fine, sayeth
Hoikas.
Hoikas and others added 3 commits February 10, 2021 15:04
Co-authored-by: Michael Hansen <zrax0111@gmail.com>
I mean, the only thing that uses OpenGL currently is a single include
in a stub file. Hardwiring the names of what appears to be Linux
libraries breaks macOS CI.
... And writing in a reader, apparently.
Copy link
Member

@zrax zrax left a comment

Choose a reason for hiding this comment

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

Yay, I finally made it through all the files this time!

Co-authored-by: Michael Hansen <zrax0111@gmail.com>
@zrax zrax merged commit 8e75767 into H-uru:master Feb 10, 2021
@Hoikas Hoikas deleted the moar-link-libs branch February 21, 2022 23:53
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.

Validate target_link_libraries for all projects
2 participants