From patchwork Wed Jan 12 02:03:49 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 78499 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 8C742B7043 for ; Wed, 12 Jan 2011 13:04:10 +1100 (EST) Received: (qmail 18546 invoked by alias); 12 Jan 2011 02:04:06 -0000 Received: (qmail 18536 invoked by uid 22791); 12 Jan 2011 02:04:04 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_LOW, SPF_HELO_PASS, TW_RG, T_RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.44.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 12 Jan 2011 02:03:58 +0000 Received: from hpaq11.eem.corp.google.com (hpaq11.eem.corp.google.com [172.25.149.11]) by smtp-out.google.com with ESMTP id p0C23u3s030658 for ; Tue, 11 Jan 2011 18:03:56 -0800 Received: from iye19 (iye19.prod.google.com [10.241.50.19]) by hpaq11.eem.corp.google.com with ESMTP id p0C22V14016106 for ; Tue, 11 Jan 2011 18:03:54 -0800 Received: by iye19 with SMTP id 19so101271iye.24 for ; Tue, 11 Jan 2011 18:03:54 -0800 (PST) Received: by 10.42.223.134 with SMTP id ik6mr323337icb.455.1294797834373; Tue, 11 Jan 2011 18:03:54 -0800 (PST) Received: from coign.google.com ([67.218.105.75]) by mx.google.com with ESMTPS id 8sm119211iba.4.2011.01.11.18.03.52 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 11 Jan 2011 18:03:53 -0800 (PST) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: libgo patch committed: Simplify Makefile conditionals Date: Tue, 11 Jan 2011 18:03:49 -0800 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 X-System-Of-Record: true 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 This patch to libgo simplifies the Makefile conditionals by setting GOOS and GOARCH in the configure script. I then use those variables in setting the filenames to compile. The cost of this approach is some more dummy files for RTEMS support, but this is at least an improvement on the current situation. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian diff -r 2e9b90df3976 libgo/Makefile.am --- a/libgo/Makefile.am Tue Jan 11 15:32:50 2011 -0800 +++ b/libgo/Makefile.am Tue Jan 11 17:50:51 2011 -0800 @@ -682,38 +682,6 @@ go/runtime/type.go \ version.go -if LIBGO_IS_386 -GOARCH = 386 -else -if LIBGO_IS_X86_64 -GOARCH = amd64 -else -if LIBGO_IS_ARM -GOARCH = arm -else -GOARCH = unknown -endif -endif -endif - -if LIBGO_IS_LINUX -GOOS = linux -else -if LIBGO_IS_DARWIN -GOOS = darwin -else -if LIBGO_IS_FREEBSD -GOOS = freebsd -else -if LIBGO_IS_RTEMS -GOOS = rtems -else -GOOS = unknown -endif -endif -endif -endif - version.go: s-version; @true s-version: Makefile rm -f version.go.tmp @@ -930,52 +898,10 @@ go/debug/pe/file.go \ go/debug/pe/pe.go -if LIBGO_IS_LINUX -proc_file = go/debug/proc/proc_linux.go -if LIBGO_IS_386 -regs_file = go/debug/proc/regs_linux_386.go -else -if LIBGO_IS_X86_64 -regs_file = go/debug/proc/regs_linux_amd64.go -else -regs_file = -endif -endif -else -if LIBGO_IS_DARWIN -proc_file = go/debug/proc/proc_darwin.go -if LIBGO_IS_386 -regs_file = go/debug/proc/regs_darwin_386.go -else -if LIBGO_IS_X86_64 -regs_file = go/debug/proc/regs_darwin_amd64.go -else -regs_file = -endif -endif -else -if LIBGO_IS_FREEBSD -proc_file = go/debug/proc/proc_freebsd.go -if LIBGO_IS_386 -regs_file = go/debug/proc/regs_freebsd_386.go -else -if LIBGO_IS_X86_64 -regs_file = go/debug/proc/regs_freebsd_amd64.go -else -regs_file = -endif -endif -else -proc_file = -regs_file = -endif -endif -endif - go_debug_proc_files = \ go/debug/proc/proc.go \ - $(proc_file) \ - $(regs_file) + go/debug/proc/proc_$(GOOS).go \ + go/debug/proc/regs_$(GOOS)_$(GOARCH).go go_encoding_ascii85_files = \ go/encoding/ascii85/ascii85.go @@ -1093,26 +1019,10 @@ go_testing_script_files = \ go/testing/script/script.go -if LIBGO_IS_LINUX -syscall_os_file = syscalls/syscall_linux.go -if LIBGO_IS_386 -syscall_arch_file = syscalls/syscall_linux_386.go -else -if LIBGO_IS_X86_64 -syscall_arch_file = syscalls/syscall_linux_amd64.go -else -syscall_arch_file = -endif -endif -else -syscall_os_file = -syscall_arch_file = -endif - if LIBGO_IS_RTEMS syscall_exec_os_file = syscalls/exec_stubs.go syscall_socket_os_file = syscalls/socket_bsd.go -syscall_socket_epoll_file= +syscall_socket_epoll_file = syscall_sysfile_os_file = syscalls/sysfile_rtems.go syscall_syscall_file = syscalls/syscall_stubs.go syscall_errstr_file = syscalls/errstr_rtems.go @@ -1131,6 +1041,14 @@ endif endif +syscall_arch.go: s-syscall_arch; @true +s-syscall_arch: Makefile + rm -f syscall_arch.go.tmp + echo "package syscall" > syscall_arch.go.tmp + echo 'const ARCH = "'$(GOARCH)'"' >> syscall_arch.go.tmp + $(SHELL) $(srcdir)/../move-if-change syscall_arch.go.tmp syscall_arch.go + $(STAMP) $@ + go_syscall_files = \ $(syscall_errstr_file) \ $(syscall_errstr_decl_file) \ @@ -1142,11 +1060,12 @@ $(syscall_syscall_file) \ syscalls/syscall_unix.go \ syscalls/stringbyte.go \ - $(syscall_os_file) \ - $(syscall_arch_file) \ + syscalls/syscall_$(GOOS).go \ + syscalls/syscall_$(GOOS)_$(GOARCH).go \ syscalls/sysfile_posix.go \ $(syscall_sysfile_os_file) \ - sysinfo.go + sysinfo.go \ + syscall_arch.go go_syscall_c_files = \ syscalls/errno.c diff -r 2e9b90df3976 libgo/configure.ac --- a/libgo/configure.ac Tue Jan 11 15:32:50 2011 -0800 +++ b/libgo/configure.ac Tue Jan 11 17:50:51 2011 -0800 @@ -116,40 +116,47 @@ is_freebsd=no is_linux=no is_rtems=no +GOOS=unknown case ${host} in - *-*-darwin*) is_darwin=yes ;; - *-*-freebsd*) is_freebsd=yes ;; - *-*-linux*) is_linux=yes ;; - *-*-rtems*) is_rtems=yes ;; + *-*-darwin*) is_darwin=yes; GOOS=darwin ;; + *-*-freebsd*) is_freebsd=yes; GOOS=freebsd ;; + *-*-linux*) is_linux=yes; GOOS=linux ;; + *-*-rtems*) is_rtems=yes; GOOS=rtems ;; esac AM_CONDITIONAL(LIBGO_IS_DARWIN, test $is_darwin = yes) AM_CONDITIONAL(LIBGO_IS_FREEBSD, test $is_freebsd = yes) AM_CONDITIONAL(LIBGO_IS_LINUX, test $is_linux = yes) AM_CONDITIONAL(LIBGO_IS_RTEMS, test $is_rtems = yes) +AC_SUBST(GOOS) is_386=no is_x86_64=no is_arm=no +GOARCH=unknown case ${host} in changequote(,)dnl - i[34567]86-*-*) + i[34567]86-*-* | x86_64-*-*) changequote([,])dnl - is_386=yes - ;; - x86_64-*-*) - if test "$with_multisubdir" = "32"; then - is_386=yes + AC_PREPROC_IFELSE([ +#ifdef __x86_64__ +#error 64-bit +#endif], +[is_386=yes], [is_x86_64=yes]) + if test "$is_386" = "yes"; then + GOARCH=386 else - is_x86_64=yes + GOARCH=amd64 fi ;; arm*-*-* | strongarm*-*-* | ep9312*-*-* | xscale-*-*) is_arm=yes + GOARCH=arm ;; esac AM_CONDITIONAL(LIBGO_IS_386, test $is_386 = yes) AM_CONDITIONAL(LIBGO_IS_X86_64, test $is_x86_64 = yes) AM_CONDITIONAL(LIBGO_IS_ARM, test $is_arm = yes) +AC_SUBST(GOARCH) dnl Use -fsplit-stack when compiling C code if available. AC_CACHE_CHECK([whether -fsplit-stack is supported], diff -r 2e9b90df3976 libgo/go/debug/proc/proc_rtems.go --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgo/go/debug/proc/proc_rtems.go Tue Jan 11 17:50:51 2011 -0800 @@ -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 RTEMS yet. + +func Attach(pid int) (Process, os.Error) { + return nil, os.NewError("debug/proc not implemented on RTEMS") +} + +func ForkExec(argv0 string, argv []string, envv []string, dir string, fd []*os.File) (Process, os.Error) { + return Attach(0) +} diff -r 2e9b90df3976 libgo/go/debug/proc/regs_rtems_386.go --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgo/go/debug/proc/regs_rtems_386.go Tue Jan 11 17:50:51 2011 -0800 @@ -0,0 +1,5 @@ +// 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 diff -r 2e9b90df3976 libgo/go/debug/proc/regs_rtems_amd64.go --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgo/go/debug/proc/regs_rtems_amd64.go Tue Jan 11 17:50:51 2011 -0800 @@ -0,0 +1,5 @@ +// 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 diff -r 2e9b90df3976 libgo/syscalls/syscall_linux_386.go --- a/libgo/syscalls/syscall_linux_386.go Tue Jan 11 15:32:50 2011 -0800 +++ b/libgo/syscalls/syscall_linux_386.go Tue Jan 11 17:50:51 2011 -0800 @@ -6,8 +6,6 @@ package syscall -const ARCH = "386" - func (r *PtraceRegs) PC() uint64 { return uint64(uint32(r.Eip)); } diff -r 2e9b90df3976 libgo/syscalls/syscall_linux_amd64.go --- a/libgo/syscalls/syscall_linux_amd64.go Tue Jan 11 15:32:50 2011 -0800 +++ b/libgo/syscalls/syscall_linux_amd64.go Tue Jan 11 17:50:51 2011 -0800 @@ -6,8 +6,6 @@ package syscall -const ARCH = "amd64" - func (r *PtraceRegs) PC() uint64 { return r.Rip; } diff -r 2e9b90df3976 libgo/syscalls/syscall_rtems.go --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgo/syscalls/syscall_rtems.go Tue Jan 11 17:50:51 2011 -0800 @@ -0,0 +1,7 @@ +// syscall_rtems.go -- RTEMS 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 diff -r 2e9b90df3976 libgo/syscalls/syscall_rtems_386.go --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgo/syscalls/syscall_rtems_386.go Tue Jan 11 17:50:51 2011 -0800 @@ -0,0 +1,7 @@ +// syscall_rtems_386.go -- RTEMS 386 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 diff -r 2e9b90df3976 libgo/syscalls/syscall_rtems_amd64.go --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgo/syscalls/syscall_rtems_amd64.go Tue Jan 11 17:50:51 2011 -0800 @@ -0,0 +1,7 @@ +// syscall_rtems_amd64.go -- RTEMS AMD64 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