Skip to content

vk_entrypoints_gen: Apply hidden visibility to generated symbols

Tatsuyuki Ishi requested to merge ishitatsuyuki/mesa:symbolz into main

The symbols were not getting hidden visibility because -fvisibility=hidden only applies to definitions, not declarations. Declare them as hidden explicitly in the header so they don't end up in .dynsym of linked shared objects.

Adjust the comment now that we no longer have double declaration in both .h and .c.

Benchmarks

Done with LLVM on (default).

Before:

libvulkan_intel.so: 4.478ms
libvulkan_radeon.so: 4.212ms

After:

libvulkan_intel.so: 3.012ms
libvulkan_radeon.so: 2.343ms

Relocation and symbol count stats

TLDR: Massive (2k–5k) reduction in number of symbol-resolving .rela.dyn relocations, no change for .relr.dyn relocations (cheap relocations that doesn't require symbol resolution).

Before:

file,.rela.dyn,.relr.dyn,.rela.plt,symbols
build/src/amd/vulkan/libvulkan_radeon.so,5469,7980,655,6935
build/src/gallium/targets/lavapipe/libvulkan_lvp.so,1870,7587,561,3016
build/src/intel/vulkan/libvulkan_intel.so,5552,6309,395,7339
build/src/intel/vulkan_hasvk/libvulkan_intel_hasvk.so,3573,5867,381,4813
build/src/nouveau/vulkan/libvulkan_nouveau.so,2978,13632,402,4585

After:

file,.rela.dyn,.relr.dyn,.rela.plt,symbols
build/src/amd/vulkan/libvulkan_radeon.so,92,7980,655,708
build/src/gallium/targets/lavapipe/libvulkan_lvp.so,45,7587,561,673
build/src/intel/vulkan/libvulkan_intel.so,31,6309,395,434
build/src/intel/vulkan_hasvk/libvulkan_intel_hasvk.so,43,5867,381,433
build/src/nouveau/vulkan/libvulkan_nouveau.so,627,13632,402,2234

I'm using LDFLAGS=-Wl,--pack-dyn-relocs=relr. RELR only contains relocations that doesn't require symbol resolution (they simply add the image base offset), and it's helpful in differentiating these cheap relocations from the expensive relocations that requires symbol resolution (RELA relocations with a symbol).

Edited by Tatsuyuki Ishi

Merge request reports