[PATCH v2 0/1] MR3984: configure: Don't link with -Wl,-z,defs on FreeBSD.
On FreeBSD, using `environ` in a shared library linked with `-Wl,-z,defs` causes an undefined reference error: ``` gcc -m64 -o dlls/msv1_0/msv1_0.so -shared -Wl,-Bsymbolic -Wl,-soname,msv1_0.so -Wl,-z,defs dlls/msv1_0/unixlib.o dlls/ntdll/ntdll.so /usr/local/bin/ld: dlls/msv1_0/unixlib.o: in function `ntlm_fork': /usr/home/pip/wine/build64/../dlls/msv1_0/unixlib.c:206: undefined reference to `environ' collect2: error: ld returned 1 exit status *** Error code 1 ``` This is unfortunately a common issue on FreeBSD, see: - https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=263265 - https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=265008 - https://reviews.freebsd.org/D30842 Reported by Gerald Pfeifer. -- v2: configure: Don't link with -Wl,-z,defs on FreeBSD. https://gitlab.winehq.org/wine/wine/-/merge_requests/3984
From: Brendan Shanks <bshanks(a)codeweavers.com> Fixes undefined reference link error in msv1_0. Reported by Gerald Pfeifer. --- configure.ac | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 7229e25dbed..a6666280307 100644 --- a/configure.ac +++ b/configure.ac @@ -765,7 +765,14 @@ case $host_os in LDDLLFLAGS="-fPIC" ;; esac - WINE_TRY_CFLAGS([-Wl,-z,defs],[UNIXLDFLAGS="$UNIXLDFLAGS -Wl,-z,defs"]) + dnl Don't use -Wl,-z,defs on FreeBSD, it prevents 'environ' from being used in shared libraries + case $host_os in + freebsd*) + ;; + *) + WINE_TRY_CFLAGS([-Wl,-z,defs],[UNIXLDFLAGS="$UNIXLDFLAGS -Wl,-z,defs"]) ;; + esac + WINE_TRY_CFLAGS([-Wl,--export-dynamic],[WINELOADER_LDFLAGS="-Wl,--export-dynamic"]) WINEPRELOADER_LDFLAGS="-nostartfiles -nodefaultlibs" -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/3984
I was hoping for a check of the actual failing code, in case other systems inherited the bug. It would also let us do the right thing when/if FreeBSD fixes it. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/3984#note_47232
participants (3)
-
Alexandre Julliard (@julliard) -
Brendan Shanks -
Brendan Shanks (@bshanks)