meson: unwrap ld_libdir_mangohud handling, remove ld_libdir_abs

Currently we have ld_libdir_abs which defaults to false. In that case,
both the mangohud shell wrapper, as well as the json files, reference
the DSOs directly without any path component.

This means that at run-time the dynamic linker, vulkan loader as well as
pressure-vessel will need to jump through hoops and figure out the
bitness of the DSO, whether one wants the 32 or 64bit one and even then
there will be confusing messages like:

fatal: /usr/lib/libMangoHud.so: wrong ELF class: ELFCLASS32

When set to true, as seen in the in-tree build.sh we'll append empty
path to LD_LIBRARY_PATH (bad), the full path with the $LIB token will be
used with LD_PRELOAD (good) and json files (bad).

Since we are generating separate json files, we can use the actual path
(while $LIB currently works, it's not really strict json nor documented
as supported). We can also drop the dubious LD_LIBRARY_PATH manipulation

This basically reinstates the prepend_libdir_vk=true option that was
dropped earlier.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
pull/956/head
Emil Velikov 1 year ago committed by flightlessmango
parent dd374d4c9e
commit f47f777e26

@ -13,16 +13,14 @@ if [ "$1" = "--dlsym" ]; then
shift
fi
MANGOHUD_LIB_NAME="@ld_libdir_mangohud_abs@libMangoHud.so"
MANGOHUD_LIB_NAME="@ld_libdir_mangohud@libMangoHud.so"
if [ "$MANGOHUD_DLSYM" = "1" ]; then
MANGOHUD_LIB_NAME="@ld_libdir_mangohud_abs@libMangoHud_dlsym.so:${MANGOHUD_LIB_NAME}"
MANGOHUD_LIB_NAME="@ld_libdir_mangohud@libMangoHud_dlsym.so:${MANGOHUD_LIB_NAME}"
fi
# Preload using the plain filenames of the libs, the dynamic linker will
# figure out whether the 32 or 64 bit version should be used, and will search
# for it in the correct directory
# figure out whether the 32 or 64 bit version should be used
LD_PRELOAD="${LD_PRELOAD}${LD_PRELOAD:+:}${MANGOHUD_LIB_NAME}"
LD_LIBRARY_PATH="${LD_LIBRARY_PATH}${LD_LIBRARY_PATH:+:}@ld_libdir_mangohud@"
exec env MANGOHUD=1 LD_LIBRARY_PATH="${LD_LIBRARY_PATH}" LD_PRELOAD="${LD_PRELOAD}" "$@"
exec env MANGOHUD=1 LD_PRELOAD="${LD_PRELOAD}" "$@"

@ -142,13 +142,13 @@ configure() {
git submodule update --init --depth 50
CONFIGURE_OPTS="-Dwerror=true"
if [[ ! -f "build/meson64/build.ninja" ]]; then
meson build/meson64 --libdir lib/mangohud/lib64 --prefix /usr -Dappend_libdir_mangohud=false -Dld_libdir_abs=true $@ ${CONFIGURE_OPTS}
meson build/meson64 --libdir lib/mangohud/lib64 --prefix /usr -Dappend_libdir_mangohud=false $@ ${CONFIGURE_OPTS}
fi
if [[ ! -f "build/meson32/build.ninja" && "$MACHINE" = "x86_64" ]]; then
export CC="gcc -m32"
export CXX="g++ -m32"
export PKG_CONFIG_PATH="/usr/lib32/pkgconfig:/usr/lib/i386-linux-gnu/pkgconfig:/usr/lib/pkgconfig:${PKG_CONFIG_PATH_32}"
meson build/meson32 --libdir lib/mangohud/lib32 --prefix /usr -Dappend_libdir_mangohud=false -Dld_libdir_abs=true $@ ${CONFIGURE_OPTS}
meson build/meson32 --libdir lib/mangohud/lib32 --prefix /usr -Dappend_libdir_mangohud=false $@ ${CONFIGURE_OPTS}
fi
}

@ -3,7 +3,6 @@ option('use_system_vulkan', type : 'feature', value : 'disabled', description: '
option('use_system_spdlog', type : 'feature', value : 'disabled', description: 'Use system spdlog library')
option('vulkan_datadir', type : 'string', value : '', description: 'Path to the system vulkan headers data directory if different from MangoHud\'s datadir')
option('append_libdir_mangohud', type : 'boolean', value : true, description: 'Append "mangohud" to libdir path or not.')
option('ld_libdir_abs', type : 'boolean', value : false, description: 'Use absolute path in LD_PRELOAD')
option('include_doc', type : 'boolean', value : true, description: 'Include the example config, man pages, appstream files etc.')
option('with_nvml', type : 'combo', value : 'enabled', choices: ['enabled', 'system', 'disabled'], description: 'Enable NVML support')
option('with_xnvctrl', type : 'feature', value : 'enabled', description: 'Enable XNVCtrl support')

@ -4,7 +4,7 @@
"name": "VK_LAYER_MANGOAPP_overlay",
"type": "GLOBAL",
"api_version": "1.3.0",
"library_path": "@ld_libdir_mangohud@libMangoApp.so",
"library_path": "@ld_libdir_mangohud_abs@/libMangoApp.so",
"implementation_version": "1",
"description": "Mangoapp Layer",
"functions": {

@ -4,7 +4,7 @@
"name": "VK_LAYER_MANGOHUD_overlay",
"type": "GLOBAL",
"api_version": "1.3.0",
"library_path": "@ld_libdir_mangohud@libMangoHud.so",
"library_path": "@ld_libdir_mangohud_abs@/libMangoHud.so",
"implementation_version": "1",
"description": "Vulkan Hud Overlay",
"functions": {

@ -2,22 +2,17 @@ glslang = find_program('glslangValidator')
# Needs prefix for configure_file()
if get_option('append_libdir_mangohud')
libdir_mangohud = join_paths(get_option('libdir'), 'mangohud')
libdir_mangohud = join_paths(get_option('prefix'), get_option('libdir'), 'mangohud')
ld_libdir_mangohud = get_option('prefix') + '/\$LIB/mangohud/'
else
libdir_mangohud = get_option('libdir')
libdir_mangohud = join_paths(get_option('prefix'), get_option('libdir'))
ld_libdir_mangohud = get_option('prefix') + '/\$LIB/'
endif
conf_data = configuration_data()
if get_option('ld_libdir_abs')
conf_data.set('ld_libdir_mangohud_abs', ld_libdir_mangohud)
conf_data.set('ld_libdir_mangohud', '')
else
conf_data.set('ld_libdir_mangohud_abs', '')
conf_data.set('ld_libdir_mangohud', ld_libdir_mangohud)
endif
conf_data.set('ld_libdir_mangohud_abs', libdir_mangohud)
conf_data.set('ld_libdir_mangohud', ld_libdir_mangohud)
overlay_shaders = [
'overlay.frag',
@ -284,7 +279,7 @@ endif
configure_file(input : 'mangohud.json.in',
output : '@0@.@1@.json'.format(meson.project_name(), host_machine.cpu_family()),
configuration : {'ld_libdir_mangohud' : ld_libdir_mangohud.replace('\$', '$')},
configuration : conf_data,
install : true,
install_dir : join_paths(get_option('datadir'), 'vulkan', 'implicit_layer.d'),
install_tag : 'runtime',
@ -300,7 +295,7 @@ configure_file(input : '../bin/mangohud.in',
if get_option('mangoapp_layer')
configure_file(input : 'app/layer.json.in',
output : 'libMangoApp.@0@.json'.format(host_machine.cpu_family()),
configuration : {'ld_libdir_mangohud' : ld_libdir_mangohud.replace('\$', '$')},
configuration : conf_data,
install : true,
install_dir : join_paths(get_option('datadir'), 'vulkan', 'implicit_layer.d'),
install_tag : 'mangoapp',

Loading…
Cancel
Save