1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2026-05-22 10:15:16 +02:00

Set function/variable visibility to hidden.

This saves about 16KiB in the binary and reduces exported symbols by about 75%. All variables are still exported and any functions that are referenced by their pointers or extern'd but never used outside the module where they are defined.

In addition to modest space savings, this should also increase performance a bit since the compiler can simplify calls to these functions and load the binary should also be a little faster.

The GCC documentation does not make it clear that visibility can be used with variables, but it certainly makes a difference in the binary size, so something is happening. Other sources on the internet suggest that visibility can be used with variables. Clearly exports are not affected, but there may be some other optimization happening.
This commit is contained in:
David Steele
2024-03-10 11:09:13 +13:00
committed by GitHub
parent e3d9df3ae9
commit f287178b70
2 changed files with 12 additions and 3 deletions
+6 -1
View File
@@ -35,7 +35,12 @@
<release-improvement-list>
<release-item>
<github-pull-request id="2264"/>
<commit subject="Make meson the primary build system.">
<github-pull-request id="2264"/>
</commit>
<commit subject="Set function/variable visibility to hidden.">
<github-pull-request id="2265"/>
</commit>
<release-item-contributor-list>
<release-item-contributor id="david.steele"/>
+6 -2
View File
@@ -11,8 +11,12 @@ if get_option('unity') == 'on'
# Add args to builds to prevent non-pgbackrest binaries failing due to unused functions
arg_unity += '-Wno-unused-function'
else
configuration.set('FN_EXTERN', 'extern', description: 'Extern function required by other compilation units')
configuration.set('VR_EXTERN_DECLARE', 'extern', description: 'Extern variable declaration required by other compilation units')
configuration.set(
'FN_EXTERN', 'extern __attribute__((visibility ("internal")))',
description: 'Extern function required by other compilation units')
configuration.set(
'VR_EXTERN_DECLARE', 'extern __attribute__((visibility ("internal")))',
description: 'Extern variable declaration required by other compilation units')
configuration.set('VR_EXTERN_DEFINE', '', description: 'Extern variable definition required by other compilation units')
endif