diff mbox

[libcc1,build] Enable libcc1 on Solaris

Message ID yddbnoow7g4.fsf@CeBiTec.Uni-Bielefeld.DE
State New
Headers show

Commit Message

Rainer Orth Nov. 3, 2014, 4:54 p.m. UTC
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  <ro@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.

Comments

Phil Muldoon Nov. 5, 2014, 2:01 p.m. UTC | #1
On 03/11/14 16:54, Rainer Orth wrote:
> 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  <ro@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.

The configure change is fine.  Also the include.  (From a libcc
authorship point of view).  I am not aware of the history of AF_UNIX
over AF_LOCAL so I have no comment on that.  Please await permission
from a GCC maintainer (I am not one).

Cheers

Phil
Rainer Orth Nov. 6, 2014, 11:33 a.m. UTC | #2
Hi Phil,

> The configure change is fine.  Also the include.  (From a libcc
> authorship point of view).  I am not aware of the history of AF_UNIX
> over AF_LOCAL so I have no comment on that.  Please await permission

the glibc manual states

AF_UNIX

    This is a synonym for AF_LOCAL. Although AF_LOCAL is mandated by
    POSIX.1g, AF_UNIX is portable to more systems. AF_UNIX was the
    traditional name stemming from BSD, so even most POSIX systems
    support it. It is also the name of choice in the Unix98
    specification. (The same is true for PF_UNIX vs. PF_LOCAL).

(http://www.gnu.org/software/libc/manual/html_node/Address-Formats.html)

> from a GCC maintainer (I am not one).

You probably should become the libcc1 maintainer, though :-)

	Rainer
Phil Muldoon Nov. 6, 2014, 11:47 a.m. UTC | #3
On 06/11/14 11:33, Rainer Orth wrote:
> Hi Phil,
>
>> The configure change is fine.  Also the include.  (From a libcc
>> authorship point of view).  I am not aware of the history of AF_UNIX
>> over AF_LOCAL so I have no comment on that.  Please await permission
>
> the glibc manual states
>
> AF_UNIX
>
>     This is a synonym for AF_LOCAL. Although AF_LOCAL is mandated by
>     POSIX.1g, AF_UNIX is portable to more systems. AF_UNIX was the
>     traditional name stemming from BSD, so even most POSIX systems
>     support it. It is also the name of choice in the Unix98
>     specification. (The same is true for PF_UNIX vs. PF_LOCAL).
>
> (http://www.gnu.org/software/libc/manual/html_node/Address-Formats.html)

OK that looks great.  Thanks for explaining!

>
>
>> from a GCC maintainer (I am not one).
>
> You probably should become the libcc1 maintainer, though :-)

I am quite new to GCC (the vast majority of my work is over in GDB),
so not sure how these things work.  I'll be happy to do what the GCC
community think best. We plan to extend libcc1 to include C++ as a
next step (after the GDB patches are approved).  So I will be around a
lot.

Cheers

Phil
diff mbox

Patch

# 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;