-
-
Notifications
You must be signed in to change notification settings - Fork 607
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
[Scons] Added the ability to change the visibility of symbols #1313
Conversation
Would this be worth doing on desktop platforms too for Godot itself, at least as an opt-in option? |
I tried to view the exports of the godot executable for linux downloaded from the official website, but there were no unnecessary exports in it. Maybe I need to know more about exports in Godot 🤷♂️ As far as I understand |
I've been meaning to try using If this would also perhaps make the Godot executeable smaller, that would be another interesting benefit :-) |
Overall, this looks good to me! I think @DmitriySalnikov Can you rebase on the latest |
d6a706a
to
f5e4f95
Compare
Most likely it will not affect in any way. The official GCC documentation mentions only shared objects. It can be useful in godotengine/godot#72883 |
Possibly. However, if you run |
It's relevant for official macOS builds (debug builds have more exposed symbols).
macOS builds always use clang, which might have different defaults. But in most cases, there's almost no difference between shared object and executable. Also, adding |
Thanks! |
Cherry-picked for 4.1 in PR #1491 |
Added an argument to change
-fvisibility
.This greatly reduces the size of the libraries and does not affect the functionality in any way, since only the entry point is used.
This argument mainly affects the size of shared libraries,
.a
files retain approximately the same size, but without this argument in godot-cpp itself, the size of the library does not change much.In my case, I used my library for testing
scons platform=web target=template_release
(need to apply the patch first)Before this PR:
2.44 MB
Export[10781] (viawasm-objdump -x
)After this PR:
512.64 KB
Export[10]-fvisibility=hidden
only in my code:2.13 MB
Export[8936]Initially, I wanted to try to hide symbols only for the Web to reduce the size of the dummy library, because
2.5MB
is too much.But it turned out that by hiding useless symbols for all platforms, I managed to reduce the total size of the libraries from 45MB to 27MB1.
In my understanding, disabling visibility by default will not affect the absolute majority of users, since usually the interaction of the library and godot occurs through a single entry point, which is already explicitly exported via
GDE_EXPORT
.For those who really need it, they can use
symbols_visibility=visible
/symbols_visibility=auto (does not change the compiler arguments in any way)
or explicitly specifyGDE_EXPORT
.Also in godot itself on ios and android,
-fvisibility=hidden
is used by default.-fvisibility=hidden
can be replaced with--exclude-libs
in user's scons, but it is only supported on linux and android. macOS, wasm and probably others either do not have such an argument, or use a different approach.Perhaps the name of the new argument and its enumeration may not be quite correct, it may be worth changing them.
Footnotes
There, in my repository, the use of Android NDK is also fixed, as GitHub has removed NDK r23 support from its images. It does not affect the size. ↩