Skip to content

Commit

Permalink
Meson option to have absolute paths in LD_PRELOAD
Browse files Browse the repository at this point in the history
  • Loading branch information
jackun committed Nov 27, 2020
1 parent 9af4ac5 commit 6a5cd38
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions bin/mangohud.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ if [ "$1" = "--dlsym" ]; then
shift
fi

MANGOHUD_LIB_NAME="libMangoHud.so"
MANGOHUD_LIB_NAME="@ld_libdir_mangohud_abs@libMangoHud.so"

if [ "$MANGOHUD_DLSYM" = "1" ]; then
MANGOHUD_LIB_NAME="libMangoHud_dlsym.so:${MANGOHUD_LIB_NAME}"
MANGOHUD_LIB_NAME="@ld_libdir_mangohud_abs@libMangoHud_dlsym.so:${MANGOHUD_LIB_NAME}"
fi

# Preload using the plain filesnames of the libs, the dynamic linker will
Expand Down
4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,14 @@ configure() {
dependencies
git submodule update --init --depth 50
if [[ ! -f "build/meson64/build.ninja" ]]; then
meson build/meson64 --libdir lib/mangohud/lib --prefix /usr -Dappend_libdir_mangohud=false -Dld_libdir_prefix=true $@ ${CONFIGURE_OPTS}
meson build/meson64 --libdir lib/mangohud/lib --prefix /usr -Dappend_libdir_mangohud=false -Dld_libdir_prefix=true -Dld_libdir_abs=true $@ ${CONFIGURE_OPTS}
fi
if [[ ! -f "build/meson32/build.ninja" ]]; 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}"
export LLVM_CONFIG="/usr/bin/llvm-config32"
meson build/meson32 --libdir lib/mangohud/lib32 --prefix /usr -Dappend_libdir_mangohud=false -Dld_libdir_prefix=true $@ ${CONFIGURE_OPTS}
meson build/meson32 --libdir lib/mangohud/lib32 --prefix /usr -Dappend_libdir_mangohud=false -Dld_libdir_prefix=true -Dld_libdir_abs=true $@ ${CONFIGURE_OPTS}
fi
}

Expand Down
1 change: 1 addition & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ option('glibcxx_asserts', type : 'boolean', value : false)
option('use_system_vulkan', type : 'feature', value : 'disabled', description: 'Use system vulkan headers instead of the provided ones')
option('append_libdir_mangohud', type : 'boolean', value : true, description: 'Append "mangohud" to libdir path or not.')
option('ld_libdir_prefix', type : 'boolean', value : false, description: 'Set ld libdir to "$prefix/lib/mangohud/\$LIB"')
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')
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')
Expand Down
8 changes: 7 additions & 1 deletion src/meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
glslang = find_program('glslangValidator')

ld_libdir_mangohud_abs = ''
# Needs prefix for configure_file()
if get_option('append_libdir_mangohud')
libdir_mangohud = join_paths(get_option('libdir'), 'mangohud')
Expand All @@ -15,6 +16,10 @@ if get_option('ld_libdir_prefix')
ld_libdir_mangohud = get_option('prefix') + '/lib/mangohud/\$LIB/'
endif

if get_option('ld_libdir_abs')
ld_libdir_mangohud_abs = ld_libdir_mangohud
endif

overlay_shaders = [
'overlay.frag',
'overlay.vert',
Expand Down Expand Up @@ -205,7 +210,8 @@ configure_file(input : 'mangohud.json.in',

configure_file(input : '../bin/mangohud.in',
output : 'mangohud',
configuration : {'ld_libdir_mangohud' : ld_libdir_mangohud},
configuration : {'ld_libdir_mangohud' : ld_libdir_mangohud,
'ld_libdir_mangohud_abs': ld_libdir_mangohud_abs},
install_dir : get_option('bindir'),
)

Expand Down

0 comments on commit 6a5cd38

Please sign in to comment.