egl/meson: Specify which symbols to export

The goal is to reduce symbol pollution, especially when building
with Perfetto support, which previously led to an excessive number
of exported symbols.

 objdump -T build/src/egl/libEGL_mesa.so.0.0.0 | grep perfetto | wc -l
 - before: 6963
 - after: 0

The new egl.sym version script explicitly exports only relevant egl and
MesaGLInteropEGL symbols, while marking all others as local.

While this change effectively removes all Perfetto-related exported symbols,
some C++ standard library symbols remain as undefined. These are pulled in
by the linker due to dependencies.

Signed-off-by: Christian Gmeiner <cgmeiner@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33001>
This commit is contained in:
Christian Gmeiner 2025-01-13 10:33:06 +01:00 committed by Marge Bot
parent 3f6f55e891
commit 10f04dc3df
3 changed files with 31 additions and 1 deletions

6
src/egl/egl-glvnd.sym Normal file
View file

@ -0,0 +1,6 @@
{
global:
__egl_Main;
local:
*;
};

7
src/egl/egl.sym Normal file
View file

@ -0,0 +1,7 @@
{
global:
egl*;
MesaGLInteropEGL*;
local:
*;
};

View file

@ -5,6 +5,8 @@ inc_egl = include_directories('.', 'main')
c_args_for_egl = [asan_c_args]
cpp_args_for_egl = []
link_args_for_egl = []
link_deps_for_egl = []
link_for_egl = [libpipe_loader_dynamic]
if with_dri
link_for_egl += libgallium_dri
@ -172,6 +174,20 @@ else
)
endif
if with_ld_version_script
if with_glvnd
link_args_for_egl += [
'-Wl,--version-script', join_paths(meson.current_source_dir(), 'egl-glvnd.sym')
]
link_deps_for_egl += files('egl-glvnd.sym')
else
link_args_for_egl += [
'-Wl,--version-script', join_paths(meson.current_source_dir(), 'egl.sym')
]
link_deps_for_egl += files('egl.sym')
endif
endif
egl_def = custom_target(
'egl.def',
input: 'main/egl.def.in',
@ -190,7 +206,8 @@ libegl = shared_library(
gnu_symbol_visibility : 'hidden',
include_directories : incs_for_egl,
link_with : [link_for_egl, libglapi],
link_args : [ld_args_bsymbolic, ld_args_gc_sections],
link_args : [ld_args_bsymbolic, ld_args_gc_sections, link_args_for_egl],
link_depends : [link_deps_for_egl],
dependencies : [deps_for_egl, dep_dl, dep_libdrm, dep_clock, dep_thread, idep_mesautil],
install : true,
version : egl_lib_version,