DescentDevelopers / Descent3

Descent 3 by Outrage Entertainment
GNU General Public License v3.0
2.86k stars 245 forks source link

Hide module symbols by default #340

Closed MaddTheSane closed 4 months ago

MaddTheSane commented 4 months ago

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.

MaddTheSane commented 4 months ago

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.

JeodC commented 4 months ago

I did some research on this subject and came up with some possible downsides:

MaddTheSane commented 4 months ago
JeodC commented 4 months ago
  • It doesn't just target net games, but also the level scripts.
  • If you feel like this is too soon, you can wait until the project is a bit more mature.

@jcoby @winterheart @Arcnor What do you think?

winterheart commented 4 months ago

I have little experience on dll using, but changes looks fine for me.