Patchwork libgo patch committed: Simplify Makefile conditionals

login
register
mail settings
Submitter Ian Taylor
Date Jan. 12, 2011, 2:03 a.m.
Message ID <mcrzkr6zxmi.fsf@google.com>
Download mbox | patch
Permalink /patch/78499/
State New
Headers show

Comments

Ian Taylor - Jan. 12, 2011, 2:03 a.m.
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

Patch

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