From ac5d9decd2ed57e0569fb8cf0db5cf18a1fa8663 Mon Sep 17 00:00:00 2001 From: Jacek Konieczny Date: Fri, 15 Sep 2023 20:04:24 +0200 Subject: [PATCH] linux: preserve existing LD_PRELOAD content that is needed for Steam overlay and game streaming to work fixes https://github.com/DFHack/dfhack/issues/3768 --- docs/about/Authors.rst | 1 + docs/changelog.txt | 1 + package/linux/dfhack | 16 ++++++++-------- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/docs/about/Authors.rst b/docs/about/Authors.rst index 4b5d4e0c2..e81649d8d 100644 --- a/docs/about/Authors.rst +++ b/docs/about/Authors.rst @@ -83,6 +83,7 @@ Herwig Hochleitner bendlas Hevlikn Hevlikn Ian S kremlin- IndigoFenix +Jacek Konieczny Jajcus James 20k James Gilles kazimuth James Logsdon jlogsdon diff --git a/docs/changelog.txt b/docs/changelog.txt index c29879631..6579cf1a8 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -56,6 +56,7 @@ Template for new versions: ## New Features ## Fixes +- Linux launcher: preserve LD_PRELOAD set by Steam, so Steam Overlay and game streaming works ## Misc Improvements diff --git a/package/linux/dfhack b/package/linux/dfhack index a83da71b4..fab3d0602 100755 --- a/package/linux/dfhack +++ b/package/linux/dfhack @@ -60,7 +60,7 @@ fi case "$1" in -g | --gdb) shift - echo "set exec-wrapper env LD_LIBRARY_PATH='$LD_LIBRARY_PATH' LD_PRELOAD='$PRELOAD_LIB' MALLOC_PERTURB_=45" > gdbcmd.tmp + echo "set exec-wrapper env LD_LIBRARY_PATH='$LD_LIBRARY_PATH' LD_PRELOAD='${LD_PRELOAD:+$LD_PRELOAD:}$PRELOAD_LIB' MALLOC_PERTURB_=45" > gdbcmd.tmp gdb $DF_GDB_OPTS -x gdbcmd.tmp --args ./dwarfort "$@" rm gdbcmd.tmp ret=$? @@ -95,35 +95,35 @@ case "$1" in ;; -h | --helgrind) shift - LD_PRELOAD="$PRELOAD_LIB" setarch "$setarch_arch" -R valgrind $DF_HELGRIND_OPTS --tool=helgrind --log-file=helgrind.log ./dwarfort "$@" + LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}$PRELOAD_LIB" setarch "$setarch_arch" -R valgrind $DF_HELGRIND_OPTS --tool=helgrind --log-file=helgrind.log ./dwarfort "$@" ret=$? ;; -v | --valgrind) shift - LD_PRELOAD="$PRELOAD_LIB" setarch "$setarch_arch" -R valgrind $DF_VALGRIND_OPTS --log-file=valgrind.log ./dwarfort "$@" + LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}$PRELOAD_LIB" setarch "$setarch_arch" -R valgrind $DF_VALGRIND_OPTS --log-file=valgrind.log ./dwarfort "$@" ret=$? ;; -c | --callgrind) shift - LD_PRELOAD="$PRELOAD_LIB" setarch "$setarch_arch" -R valgrind $DF_CALLGRIND_OPTS --tool=callgrind --separate-threads=yes --dump-instr=yes --instr-atstart=no --log-file=callgrind.log ./dwarfort "$@" + LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}$PRELOAD_LIB" setarch "$setarch_arch" -R valgrind $DF_CALLGRIND_OPTS --tool=callgrind --separate-threads=yes --dump-instr=yes --instr-atstart=no --log-file=callgrind.log ./dwarfort "$@" ret=$? ;; --strace) shift - strace -f setarch "$setarch_arch" -R env LD_PRELOAD="$PRELOAD_LIB" ./dwarfort "$@" 2> strace.log + strace -f setarch "$setarch_arch" -R env LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}$PRELOAD_LIB" ./dwarfort "$@" 2> strace.log ret=$? ;; -x | --exec) - exec setarch "$setarch_arch" -R env LD_PRELOAD="$PRELOAD_LIB" ./dwarfort "$@" + exec setarch "$setarch_arch" -R env LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}$PRELOAD_LIB" ./dwarfort "$@" # script does not resume ;; --sc | --sizecheck) PRELOAD_LIB="${PRELOAD_LIB:+$PRELOAD_LIB:}./hack/libsizecheck.so" - MALLOC_PERTURB_=45 setarch "$setarch_arch" -R env LD_PRELOAD="$PRELOAD_LIB" ./dwarfort "$@" + MALLOC_PERTURB_=45 setarch "$setarch_arch" -R env LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}$PRELOAD_LIB" ./dwarfort "$@" ret=$? ;; *) - setarch "$setarch_arch" -R env LD_PRELOAD="$PRELOAD_LIB" ./dwarfort "$@" + setarch "$setarch_arch" -R env LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}$PRELOAD_LIB" ./dwarfort "$@" ret=$? ;; esac