-
Notifications
You must be signed in to change notification settings - Fork 232
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
Hide module symbols by default #340
Conversation
An alternative to marking specific symbols as exportable in the source code is to have an exported symbols list that is passed to the linker. The problem is, macOS and Windows start each symbol with an underscore, while Linux/other UNIXes do not. This would resolve the DMFC symbols being exported, though. |
I did some research on this subject and came up with some possible downsides:
|
|
@jcoby @winterheart @Arcnor What do you think? |
I have little experience on dll using, but changes looks fine for me. |
@@ -4,6 +4,7 @@ set(CPPS EntropyBase.cpp EntropyPackets.cpp EntropyRoom.cpp) | |||
set(NETGAME_MODULE entropy) | |||
|
|||
add_library(${NETGAME_MODULE} MODULE ${CPPS} ${HEADERS}) | |||
set_target_properties(${NETGAME_MODULE} PROPERTIES CXX_VISIBILITY_PRESET "hidden") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking about writing a custom CMake command for netgames that are all built the same way, maybe for a future contribution
Pull Request Type
Description
This changes the visibility of the symbols of the plug-ins, the net games, and the TCP/IP net module. This can be great for LTO and dead code stripping, as only exported symbols (and symbols that the exported symbols reference) are included, reducing the size of linked objects.
Checklist
Additional Comments
Due to how DMFC is statically-linked and built for Linux and macOS, a lot of the DMFC symbols will still be exported. The next part would be changing visibility of the DMFC library for macOS and Linux to not export its symbols if they're not building for Windows.