I noticed that the new libcc1 wasn't built on Solaris. This happens because socketpair doesn't live in libc, but in libsocket instead. To deal with this, I've copied the libgo (and libjava) code to detect the need for libsocket and libnsl. Once the build was attempted, two failures had to be dealt with:
* FD_ZERO and friends need <string.h> for a memset declaration. * On Solaris 10, AF_LOCAL isn't defined in system headers, while AF_UNIX is. In both libgo and libjava, there are unconditional uses of AF_UNIX, so I've followed their lead. Those changes allowed libcc1.so to build. Bootstrapped without regressions on i386-pc-solaris2.1[01] and x86_64-unknown-linux-gnu, ok for mainline? Btw., MAINTAINERS doesn't currently list a libcc1 maintainer. I believe it should. Rainer 2014-10-31 Rainer Orth <r...@cebitec.uni-bielefeld.de> * configure.ac (libcc1_cv_lib_sockets): Check for -lsocket -lnsl. * configure: Regenerate. * connection.cc: Include <string.h>. * libcc1.cc (libcc1_compile): Use AF_UNIX instead of AF_LOCAL.
# HG changeset patch # Parent f122bfdb06f01264f8c4766b51f932d37a0eca3d Enable libcc1 on Solaris diff --git a/libcc1/configure.ac b/libcc1/configure.ac --- a/libcc1/configure.ac +++ b/libcc1/configure.ac @@ -63,6 +63,36 @@ if test "$GXX" = yes; then fi AC_SUBST(libsuffix) +dnl Test for -lsocket and -lnsl. Copied from libgo/configure.ac. +AC_CACHE_CHECK([for socket libraries], libcc1_cv_lib_sockets, + [libcc1_cv_lib_sockets= + libcc1_check_both=no + AC_CHECK_FUNC(connect, libcc1_check_socket=no, libcc1_check_socket=yes) + if test "$libcc1_check_socket" = "yes"; then + unset ac_cv_func_connect + AC_CHECK_LIB(socket, main, libcc1_cv_lib_sockets="-lsocket", + libcc1_check_both=yes) + fi + if test "$libcc1_check_both" = "yes"; then + libcc1_old_libs=$LIBS + LIBS="$LIBS -lsocket -lnsl" + unset ac_cv_func_accept + AC_CHECK_FUNC(accept, + [libcc1_check_nsl=no + libcc1_cv_lib_sockets="-lsocket -lnsl"]) + unset ac_cv_func_accept + LIBS=$libcc1_old_libs + fi + unset ac_cv_func_gethostbyname + libcc1_old_libs="$LIBS" + AC_CHECK_FUNC(gethostbyname, , + [AC_CHECK_LIB(nsl, main, + [libcc1_cv_lib_sockets="$libcc1_cv_lib_sockets -lnsl"])]) + unset ac_cv_func_gethostbyname + LIBS=$libcc1_old_libs +]) +LIBS="$LIBS $libcc1_cv_lib_sockets" + # If any of these functions are missing, simply don't bother building # this plugin. GCC_ENABLE_PLUGINS diff --git a/libcc1/connection.cc b/libcc1/connection.cc --- a/libcc1/connection.cc +++ b/libcc1/connection.cc @@ -21,6 +21,7 @@ along with GCC; see the file COPYING3. #include <string> #include <unistd.h> #include <sys/types.h> +#include <string.h> #include <errno.h> #include "marshall.hh" #include "connection.hh" diff --git a/libcc1/libcc1.cc b/libcc1/libcc1.cc --- a/libcc1/libcc1.cc +++ b/libcc1/libcc1.cc @@ -440,7 +440,7 @@ libcc1_compile (struct gcc_base_context libcc1 *self = (libcc1 *) s; int fds[2]; - if (socketpair (AF_LOCAL, SOCK_STREAM, 0, fds) != 0) + if (socketpair (AF_UNIX, SOCK_STREAM, 0, fds) != 0) { self->print ("could not create socketpair\n"); return 0;
-- ----------------------------------------------------------------------------- Rainer Orth, Center for Biotechnology, Bielefeld University