Message ID | yddva4idukc.fsf@CeBiTec.Uni-Bielefeld.DE |
---|---|
State | New |
Headers | show |
Series | [build] Fix libgphobos linking on Solaris 11 | expand |
On Tue, 27 Nov 2018 at 23:28, Rainer Orth <ro@cebitec.uni-bielefeld.de> wrote: > > As mentioned in passing in PR d/87864, libgphobos.so currently fails to > link before Solaris 11.4. Until then, you needed to link with -lsocket > -lnsl for the networking functions, in S11.4 they were merged into libc. > > To fix this, I've adapted the check from libgo/configure.ac, for the > moment just moving it into an autoconf macro, reindenting it, renaming > the variables for the new location, and removing the check for sendfile > which isn't used in libphobos. > > With that patch (and the one from PR d/87864 to provide > __start_minfo/__stop_minfo when ld does not), I could bootstrap with > --enable-libphobos on i386-pc-solaris2.11 with gas and > sparc-sun-solaris2.11 with as on both S11.3 and S11.4. On the former, > libsocket and libnsl were properly detected and linked into > libgdruntime.so and libgphobos.so, leaving no undefined symbols, while > on the latter nothing more than libc is needed. > > Ok for mainline? > Hi, Sorry, somehow I missed this and other libphobos related patches. I see no problem with this if still needed, thanks.
Hi Iain, > On Tue, 27 Nov 2018 at 23:28, Rainer Orth <ro@cebitec.uni-bielefeld.de> wrote: >> >> As mentioned in passing in PR d/87864, libgphobos.so currently fails to >> link before Solaris 11.4. Until then, you needed to link with -lsocket >> -lnsl for the networking functions, in S11.4 they were merged into libc. >> >> To fix this, I've adapted the check from libgo/configure.ac, for the >> moment just moving it into an autoconf macro, reindenting it, renaming >> the variables for the new location, and removing the check for sendfile >> which isn't used in libphobos. >> >> With that patch (and the one from PR d/87864 to provide >> __start_minfo/__stop_minfo when ld does not), I could bootstrap with >> --enable-libphobos on i386-pc-solaris2.11 with gas and >> sparc-sun-solaris2.11 with as on both S11.3 and S11.4. On the former, >> libsocket and libnsl were properly detected and linked into >> libgdruntime.so and libgphobos.so, leaving no undefined symbols, while >> on the latter nothing more than libc is needed. >> >> Ok for mainline? >> > > Hi, > > Sorry, somehow I missed this and other libphobos related patches. > > I see no problem with this if still needed, thanks. it is on any Solaris release before 11.4. I still test 11.3 which at least receives occasional updates. Solaris 10 is affected as well, but given that it's already deprecated, support will be removed in GCC 10 and there are a couple of additional problems there (PR d/88238), I think it's a better use of everyone's time to just ignore it. Committed now. Thanks. Rainer
# HG changeset patch # Parent 8068f906d5f73ddb769b1241419ed3a330243e2b Fix libphobos linking on Solaris 11 diff --git a/libphobos/configure.ac b/libphobos/configure.ac --- a/libphobos/configure.ac +++ b/libphobos/configure.ac @@ -140,6 +140,7 @@ WITH_LOCAL_DRUNTIME([ DRUNTIME_LIBRARIES_ATOMIC DRUNTIME_LIBRARIES_BACKTRACE DRUNTIME_LIBRARIES_DLOPEN +DRUNTIME_LIBRARIES_NET DRUNTIME_LIBRARIES_ZLIB DRUNTIME_INSTALL_DIRECTORIES diff --git a/libphobos/m4/druntime/libraries.m4 b/libphobos/m4/druntime/libraries.m4 --- a/libphobos/m4/druntime/libraries.m4 +++ b/libphobos/m4/druntime/libraries.m4 @@ -42,6 +42,40 @@ AC_DEFUN([DRUNTIME_LIBRARIES_DLOPEN], ]) +# DRUNTIME_LIBRARIES_NET +# ----------------------- +# Autodetect and add networking library to LIBS if necessary. +AC_DEFUN([DRUNTIME_LIBRARIES_NET], +[ + dnl Test for -lsocket and -lnsl. Copied from libjava/configure.ac. + AC_CACHE_CHECK([for socket libraries], druntime_cv_lib_sockets, + [druntime_cv_lib_sockets= + druntime_check_both=no + AC_CHECK_FUNC(connect, druntime_check_socket=no, druntime_check_socket=yes) + if test "$druntime_check_socket" = "yes"; then + unset ac_cv_func_connect + AC_CHECK_LIB(socket, main, druntime_cv_lib_sockets="-lsocket", + druntime_check_both=yes) + fi + if test "$druntime_check_both" = "yes"; then + druntime_old_libs=$LIBS + LIBS="$LIBS -lsocket -lnsl" + unset ac_cv_func_accept + AC_CHECK_FUNC(accept, + [druntime_check_nsl=no + druntime_cv_lib_sockets="-lsocket -lnsl"]) + unset ac_cv_func_accept + LIBS=$druntime_old_libs + fi + unset ac_cv_func_gethostbyname + druntime_old_libs="$LIBS" + AC_CHECK_FUNC(gethostbyname, , + [AC_CHECK_LIB(nsl, main, + [druntime_cv_lib_sockets="$druntime_cv_lib_sockets -lnsl"])]) + ]) + LIBS="$LIBS $druntime_cv_lib_sockets" +]) + # DRUNTIME_LIBRARIES_ZLIB # ----------------------- # Allow specifying whether to use the system zlib or