From patchwork Thu Feb 3 15:06:23 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rainer Orth X-Patchwork-Id: 81672 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id A6009B7125 for ; Fri, 4 Feb 2011 02:06:48 +1100 (EST) Received: (qmail 3748 invoked by alias); 3 Feb 2011 15:06:46 -0000 Received: (qmail 3738 invoked by uid 22791); 3 Feb 2011 15:06:44 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, TW_BF, TW_RG, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from snape.CeBiTec.Uni-Bielefeld.DE (HELO smtp-relay.CeBiTec.Uni-Bielefeld.DE) (129.70.160.84) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 03 Feb 2011 15:06:37 +0000 Received: from localhost (localhost.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) by smtp-relay.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTP id 04C8A677; Thu, 3 Feb 2011 16:06:35 +0100 (CET) Received: from smtp-relay.CeBiTec.Uni-Bielefeld.DE ([127.0.0.1]) by localhost (malfoy.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) (amavisd-new, port 10024) with LMTP id PLcAgaquYSHk; Thu, 3 Feb 2011 16:06:30 +0100 (CET) Received: from manam.CeBiTec.Uni-Bielefeld.DE (manam.CeBiTec.Uni-Bielefeld.DE [129.70.161.120]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp-relay.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTPS id 01B6F675; Thu, 3 Feb 2011 16:06:30 +0100 (CET) Received: (from ro@localhost) by manam.CeBiTec.Uni-Bielefeld.DE (8.14.4+Sun/8.14.4/Submit) id p13F6NTQ015675; Thu, 3 Feb 2011 16:06:23 +0100 (MET) From: Rainer Orth To: gcc-patches@gcc.gnu.org Cc: Ian Lance Taylor Subject: [build] Support libgo on IRIX 6.5 (PR go/47515) Date: Thu, 03 Feb 2011 16:06:23 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (usg-unix-v) MIME-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org I've make quite some progress porting libgo to IRIX, to the point where I can compile and link libgo.so for the N32 and N64 multilibs. Here are the issues I ran into: * The obvious stuff: defining a new GOOS (I haven't dealt with the GOARCH part yet since this is pending already for Linux/MIPS), adding proc_irix.go, syscall_irix.go. * IRIX cannot reasonably use the go_os_sys_file default of go/os/sys_bsd.go. While it has sysctl(3N), this is a limited version and it's better to use the more portable uname(2). * In order for to have the msg_control and msg_controllen members of struct msghdr, we need to define _XOPEN_SOURCE. * On the other hand, if _XOPEN_SOURCE is defined, only sees the necessary u_char/u_short types if is included. * IRIX uses the timespec_t and __timespec types. This allowed the compile and link to finish successfully, but there are a couple of open issues that let the testsuite fail: * Makefile.am (CHECK) currently hardcodes -Wl,-R, while IRIX (and Tru64 UNIX) need -rpath instead. This is either an issue for libtool or could be dealt with using LD_LIBRARY_PATH*. * Even if I hack around this, there are two undefined symbols in libgo.so: ** strerror_r just doesn't exist on IRIX libc. I see that upstrem libgo generates the error table at compile time, but one can probably also use sys_errlist instead. ** syscalls/exec.go hardcodes wait4, which doesn't exist on IRIX. It seems like waitpid is the way to go instead: is in POSIX.1, and the struct rusage * arg to wait4 is nil anyway. Rainer 2011-01-30 Rainer Orth PR go/47515 * configure.ac (GOOS): Handle *-*-irix6*. * configure: Regenerate. * Makefile.am (go_os_sys_file): Use go/os/sys_uname.go on IRIX. * Makefile.in: Regenerate. * mksysinfo.sh (sysinfo.c) [__sgi__]: Define _XOPEN_SOURCE. [__sgi__]: Include . Allow for _timespec_t, __timespec. * go/debug/proc/proc_irix.go: New file. * syscalls/syscall_irix.go: New file. diff -r bfc1c1131e8f libgo/Makefile.am --- a/libgo/Makefile.am Wed Feb 02 18:08:21 2011 +0100 +++ b/libgo/Makefile.am Thu Feb 03 15:57:15 2011 +0100 @@ -660,6 +660,9 @@ if LIBGO_IS_LINUX go_os_sys_file = go/os/sys_linux.go else +if LIBGO_IS_IRIX +go_os_sys_file = go/os/sys_uname.go +else if LIBGO_IS_SOLARIS go_os_sys_file = go/os/sys_uname.go else @@ -670,6 +673,7 @@ endif endif endif +endif go_os_files = \ go/os/dir.go \ diff -r bfc1c1131e8f libgo/configure.ac --- a/libgo/configure.ac Wed Feb 02 18:08:21 2011 +0100 +++ b/libgo/configure.ac Thu Feb 03 15:57:15 2011 +0100 @@ -114,6 +114,7 @@ is_darwin=no is_freebsd=no +is_irix=no is_linux=no is_rtems=no is_solaris=no @@ -121,12 +122,14 @@ case ${host} in *-*-darwin*) is_darwin=yes; GOOS=darwin ;; *-*-freebsd*) is_freebsd=yes; GOOS=freebsd ;; + *-*-irix6*) is_irix=yes; GOOS=irix ;; *-*-linux*) is_linux=yes; GOOS=linux ;; *-*-rtems*) is_rtems=yes; GOOS=rtems ;; *-*-solaris2*) is_solaris=yes; GOOS=solaris ;; esac AM_CONDITIONAL(LIBGO_IS_DARWIN, test $is_darwin = yes) AM_CONDITIONAL(LIBGO_IS_FREEBSD, test $is_freebsd = yes) +AM_CONDITIONAL(LIBGO_IS_IRIX, test $is_irix = yes) AM_CONDITIONAL(LIBGO_IS_LINUX, test $is_linux = yes) AM_CONDITIONAL(LIBGO_IS_RTEMS, test $is_rtems = yes) AM_CONDITIONAL(LIBGO_IS_SOLARIS, test $is_solaris = yes) diff -r bfc1c1131e8f libgo/go/debug/proc/proc_irix.go --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgo/go/debug/proc/proc_irix.go Thu Feb 03 15:57:15 2011 +0100 @@ -0,0 +1,17 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package proc + +import "os" + +// Process tracing is not supported on IRIX yet. + +func Attach(pid int) (Process, os.Error) { + return nil, os.NewError("debug/proc not implemented on IRIX") +} + +func ForkExec(argv0 string, argv []string, envv []string, dir string, fd []*os.File) (Process, os.Error) { + return Attach(0) +} diff -r bfc1c1131e8f libgo/mksysinfo.sh --- a/libgo/mksysinfo.sh Wed Feb 02 18:08:21 2011 +0100 +++ b/libgo/mksysinfo.sh Thu Feb 03 15:57:15 2011 +0100 @@ -26,6 +26,11 @@ #include "config.h" #define _GNU_SOURCE +#if defined(__sgi__) +/* IRIX 6 needs _XOPEN_SOURCE=500 for the XPG5 version of struct msghdr in + . */ +#define _XOPEN_SOURCE 500 +#endif #if defined(__sun__) && defined(__svr4__) /* Needed by Solaris header files. */ #define _XOPEN_SOURCE 600 @@ -37,6 +42,12 @@ #include #include #include +/* needs u_char/u_short, but is only + included by if _SGIAPI (i.e. _SGI_SOURCE + && !_XOPEN_SOURCE. */ +#ifdef __sgi__ +#include +#endif #include #include #if defined(HAVE_SYSCALL_H) @@ -76,12 +87,13 @@ grep -v '^func' | \ grep -v '^type _timeval ' | \ grep -v '^type _timespec ' | \ + grep -v '^type _timespec\(_t\)\? ' | \ grep -v '^type _timestruc_t ' | \ grep -v '^type _epoll_' | \ grep -v 'in6_addr' | \ grep -v 'sockaddr_in6' | \ sed -e 's/\([^a-zA-Z0-9_]\)_timeval\([^a-zA-Z0-9_]\)/\1Timeval\2/g' \ - -e 's/\([^a-zA-Z0-9_]\)_timespec\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \ + -e 's/\([^a-zA-Z0-9_]\)_timespec\(_t\)\?\([^a-zA-Z0-9_]\)/\1Timespec\3/g' \ -e 's/\([^a-zA-Z0-9_]\)_timestruc_t\([^a-zA-Z0-9_]\)/\1Timestruc\2/g' \ >> ${OUT} @@ -283,13 +295,17 @@ sed -e 's/type _timeval /type Timeval /' \ -e 's/tv_sec *[a-zA-Z0-9_]*/Sec Timeval_sec_t/' \ -e 's/tv_usec *[a-zA-Z0-9_]*/Usec Timeval_usec_t/' >> ${OUT} -timespec=`grep '^type _timespec ' gen-sysinfo.go` +timespec=`grep '^type _timespec ' gen-sysinfo.go || true` +if test "$timespec" = ""; then + # IRIX 6.5 has __timespec instead. + timespec=`grep '^type ___timespec ' gen-sysinfo.go || true` +fi timespec_sec=`echo $timespec | sed -n -e 's/^.*tv_sec \([^ ]*\);.*$/\1/p'` timespec_nsec=`echo $timespec | sed -n -e 's/^.*tv_nsec \([^ ]*\);.*$/\1/p'` echo "type Timespec_sec_t $timespec_sec" >> ${OUT} echo "type Timespec_nsec_t $timespec_nsec" >> ${OUT} echo $timespec | \ - sed -e 's/^type _timespec /type Timespec /' \ + sed -e 's/^type \(__\)\?_timespec /type Timespec /' \ -e 's/tv_sec *[a-zA-Z0-9_]*/Sec Timespec_sec_t/' \ -e 's/tv_nsec *[a-zA-Z0-9_]*/Nsec Timespec_nsec_t/' >> ${OUT} @@ -322,7 +338,7 @@ -e 's/st_mtim/Mtime/' \ -e 's/st_ctim/Ctime/' \ -e 's/\([^a-zA-Z0-9_]\)_timeval\([^a-zA-Z0-9_]\)/\1Timeval\2/g' \ - -e 's/\([^a-zA-Z0-9_]\)_timespec\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \ + -e 's/\([^a-zA-Z0-9_]\)_timespec\(_t\)\?\([^a-zA-Z0-9_]\)/\1Timespec\3/g' \ -e 's/\([^a-zA-Z0-9_]\)_timestruc_t\([^a-zA-Z0-9_]\)/\1Timestruc\2/g' \ >> ${OUT} diff -r bfc1c1131e8f libgo/syscalls/syscall_irix.go --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgo/syscalls/syscall_irix.go Thu Feb 03 15:57:15 2011 +0100 @@ -0,0 +1,17 @@ +// syscall_irix.go -- IRIX 6 specific syscall interface. + +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package syscall + +import "unsafe" + +// FIXME: ptrace(3C) has this, but exec.go expects the next. +//func libc_ptrace(request int, pid Pid_t, addr int, data int) int __asm__ ("ptrace") + +func libc_ptrace(request int, pid Pid_t, addr uintptr, data *byte) int __asm__ ("ptrace") + +var dummy *byte +const sizeofPtr uintptr = uintptr(unsafe.Sizeof(dummy))