From: "Alex Xu (Hello71)" Subject: [PATCH] configure: add rpath for Unix libs Message-Id: <20220119174135.6318-1-alex_y_xu@yahoo.ca> Date: Wed, 19 Jan 2022 12:41:35 -0500 References: <20220119174135.6318-1-alex_y_xu.ref@yahoo.ca> wine expects that dlopen("/usr/lib/i386-windows/ntdll.so"); dlopen("/usr/lib/i386-windows/ws2_32.so") succeeds. this works on most libcs using ntdll.so SONAME, but fails for musl. there has been some discussion of implementing this in musl, but it is clearly more correct to specify rpath $ORIGIN for ELF, same as darwin. this was always broken on musl but not noticed before 6.19 because dlsym failure was ignored prior to 5689ec7bba ("ntdll: Return a failure if the unix call funcs don't exist.") Fixes https://bugs.winehq.org/show_bug.cgi?id=52418. --- configure | 32 ++++++++++++++++++++++++++++++++ configure.ac | 4 ++++ 2 files changed, 36 insertions(+) diff --git a/configure b/configure index 2cda771fb99..d51850cb76c 100755 --- a/configure +++ b/configure @@ -10858,6 +10858,38 @@ fi LIBWINE_DEPENDS="wine.map" TOP_INSTALL_LIB="$TOP_INSTALL_LIB libs/wine/libwine.so.$libwine_version libs/wine/libwine.so.$libwine_soversion" + + # do this at the end because it needs double dollar for makefile + as_ac_var=`printf "%s\n" "ac_cv_cflags_-Wl,-rpath,\\\\\\$ORIGIN" | $as_tr_sh` +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports -Wl,-rpath,\\\$ORIGIN" >&5 +printf %s "checking whether the compiler supports -Wl,-rpath,\\\$ORIGIN... " >&6; } +if eval test \${$as_ac_var+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_wine_try_cflags_saved=$CFLAGS +CFLAGS="$CFLAGS -Wl,-rpath,\\\$ORIGIN" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int main(int argc, char **argv) { return 0; } +_ACEOF +if ac_fn_c_try_link "$LINENO" +then : + eval "$as_ac_var=yes" +else $as_nop + eval "$as_ac_var=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext +CFLAGS=$ac_wine_try_cflags_saved +fi +eval ac_res=\$$as_ac_var + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +printf "%s\n" "$ac_res" >&6; } +if eval test \"x\$"$as_ac_var"\" = x"yes" +then : + UNIXLDFLAGS="$UNIXLDFLAGS '-Wl,-rpath,\$\$ORIGIN'" +fi ;; esac diff --git a/configure.ac b/configure.ac index 057a2a39948..a887e1ed8e9 100644 --- a/configure.ac +++ b/configure.ac @@ -859,6 +859,10 @@ case $host_os in AC_SUBST(LIBWINE_SHAREDLIB,"libwine.so.$libwine_version") AC_SUBST(LIBWINE_DEPENDS,"wine.map") TOP_INSTALL_LIB="$TOP_INSTALL_LIB libs/wine/libwine.so.$libwine_version libs/wine/libwine.so.$libwine_soversion" + + # musl does not satisfy pathless dlopen requests with prior pathed dlls + # do this at the end because it needs double dollar for makefile + WINE_TRY_CFLAGS([-Wl,-rpath,\\\$ORIGIN],[UNIXLDFLAGS="$UNIXLDFLAGS '-Wl,-rpath,\$\$ORIGIN'"]) ;; esac -- 2.34.1