[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#840574: Please backport libgo fixes for sparc64



Control: tags -1 patch
(almost; explained below)

Hi Matthias,
On Tue, Oct 18, 2016 at 01:47:20PM +0200, Matthias Klose wrote:
> Control: tags -1 - patch
>
> James, based on your feedback, I tried to apply these revisions on the branch,
> had to update some of these, and got a failed build. I'm not intending to work
> on this, and would like to ask you to prepare a tested debdiff for a backport or
> to get the backport upstream if you want to include the libgo port into the
> gcc-6 Debian packages.

Please find a debdiff attached; I have successfully built it on sparc64.

There is just *one* little detail which messes this up (and perhaps was
the cause of your failure?): libgo-elf-relocations-sparc64.diff
references a new binary file (for the test suite), but "svn diff"
doesn't include the actual data, nor does quilt seem to support
git-style binary diffs. Please either remove the hunks for
libgo/go/debug/elf/{file_test.go,testdata/go-relocation-test-gcc620-sparc64.obj}
or place a copy of the latter .obj in the source package and ensure it
gets copied to the same relative directory under src when
unpacking/patching.

Do let me know if I can do anything else to make this happen. I will
also see if I can get them backported upstream (though even with that
you'll still need to faff about with the .obj or drop the test...).

Thanks,
James

> On 16.10.2016 19:40, James Clarke wrote:
> > Control: tags -1 - help + patch
> >
> > Hi Matthias,
> > On Thu, Oct 13, 2016 at 01:50:43PM +0200, Matthias Klose wrote:
> >> Control: tags -1 + help
> >> Control: tags -1 - patch
> >>
> >> James, please could you name the revisions in the GCC subversion repository?
> >> Afaics these are r241084, r241077, r241051.  Even better, could you test and
> >> propose this backport upstream?
> >
> > To confirm, they are the following revisions:
> >
> > * r241171 (sparc64 relocations, e1fc2925 in go master, now also in
> >            gofrontend/gccgo)
> > * r241084 (don't use pt_regs; unnecessary, and seemingly not defined by
> >            the included headers on arm64)
> > * r241072 (make rawClone no_split_stack)
> > * r241051 (fix getrandom on sparc64 and clone on sparc*)
> > * r240457 (add getrandom for MIPS/SPARC)
> >
> > We've been using the latest gcc-6 package with these patches (other than
> > no_split_stack and pt_regs fixups) applied on top for sparc64 (uploaded
> > to unreleased) for the past few days, and the only packages which fail
> > to build seem to be because Debian currently has an out-of-date x/sys
> > package without sparc64 definitions. I haven't been aware of any
> > regressions.
> >
> > Ian: I imagine the getrandom and elf changes would be fine for gcc-6,
> > but what about the clone changes? I can understand if that's too
> > invasive, but backporting would be great.
> >
> > Regards,
> > James
> >
> >> On 12.10.2016 23:35, James Clarke wrote:
> >>> Source: gcc-6
> >>> Version: 6.2.0-6
> >>> User: debian-sparc@lists.debian.org
> >>> Usertags: sparc64
> >>> X-Debbugs-Cc: debian-sparc@lists.debian.org
> >>> Tags: patch fixed-upstream
> >>>
> >>> Hi,
> >>> Could you please backport the patches listed below so that we can have a
> >>> working gccgo? They fix the (minor) issue of using the wrong syscall
> >>> number for getrandom (if code uses it), add support for sparc64's
> >>> relocations, and also the following error when running go build:
> >>>
> >>>     /usr/bin/sparc64-linux-gnu-gccgo-6: wait: no child processes
> >>>     /usr/bin/sparc64-linux-gnu-gccgo-6: exit status 1
> >>>
> >>> The patches are:
> >>>
> >>> https://go.googlesource.com/go/+/e1fc292500aa70c265937aebad00ac010031cbaf
> >>>     (not yet pulled into gofrontend's libgo)
> >>> https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=a357a86a9f2772561454ce17ef13a89a51fc4a27
> >>> https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=0509fa0eae193f8d99886e9b6a1feda4c6c16356
> >>> https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=3457370357929d70f26873e914fae6ea6f1a8ffd
> >>>
> >>> With all but the last patch (a minor fixup after my patches), I have
> >>> been able to successfully build and run go programs on sparc64.
> >>>
> >>> Regards,
> >>> James
> >>>
> >>
>
diff -u gcc-6-6.2.0/debian/changelog gcc-6-6.2.0/debian/changelog
--- gcc-6-6.2.0/debian/changelog
+++ gcc-6-6.2.0/debian/changelog
@@ -1,3 +1,16 @@
+gcc-6 (6.2.0-7+sparc64) unreleased; urgency=medium
+
+  * Backport upstream revisions from trunk:
+    - r240457 (add getrandom for MIPS/SPARC)
+    - r241051 (fix getrandom on sparc64 and clone on sparc*)
+    - r241072 (make rawClone no_split_stack)
+    - r241084 (don't use pt_regs; unnecessary, and seemingly not defined by
+               the included headers on arm64)
+    - r241171 (sparc64 relocations, e1fc2925 in go master, now also in
+               gofrontend/gccgo)
+
+ -- James Clarke <jrtc27@jrtc27.com>  Tue, 18 Oct 2016 18:11:43 +0100
+
 gcc-6 (6.2.0-7) unstable; urgency=medium
 
   * Update to SVN 20161018 (r241301, 6.2.1) from the gcc-6-branch.
diff -u gcc-6-6.2.0/debian/rules.patch gcc-6-6.2.0/debian/rules.patch
--- gcc-6-6.2.0/debian/rules.patch
+++ gcc-6-6.2.0/debian/rules.patch
@@ -94,6 +94,11 @@
 	libffi-pax \
 	libffi-race-condition \
 	pr77686-workaround \
+	libgo-add-getrandom-mips-sparc \
+	libgo-fix-getrandom-clone-sparc64 \
+	libgo-rawClone-no_split_stack \
+	libgo-rawClone-no-pt_regs \
+	libgo-elf-relocations-sparc64 \
 
 # this is still needed on powerpc, e.g. firefox and insighttoolkit4 will ftbfs.
 ifneq (,$(filter $(DEB_TARGET_ARCH),powerpc))
only in patch2:
unchanged:
--- gcc-6-6.2.0.orig/debian/patches/libgo-add-getrandom-mips-sparc.diff
+++ gcc-6-6.2.0/debian/patches/libgo-add-getrandom-mips-sparc.diff
@@ -0,0 +1,67 @@
+# DP: Backport r240457 from trunk
+
+internal/syscall/unix: add getrandom syscall for MIPS and SPARC
+
+Reviewed-on: https://go-review.googlesource.com/29678
+
+Index: b/src/libgo/go/internal/syscall/unix/getrandom_linux_mipso32.go
+===================================================================
+--- a/src/libgo/go/internal/syscall/unix/getrandom_linux_mipso32.go	(nonexistent)
++++ b/src/libgo/go/internal/syscall/unix/getrandom_linux_mipso32.go	(revision 240457)
+@@ -0,0 +1,11 @@
++// Copyright 2016 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.
++
++// +build mipso32
++
++package unix
++
++// Linux getrandom system call number.
++// See GetRandom in getrandom_linux.go.
++const randomTrap uintptr = 4353
+Index: b/src/libgo/go/internal/syscall/unix/getrandom_linux_sparc.go
+===================================================================
+--- a/src/libgo/go/internal/syscall/unix/getrandom_linux_sparc.go	(nonexistent)
++++ b/src/libgo/go/internal/syscall/unix/getrandom_linux_sparc.go	(revision 240457)
+@@ -0,0 +1,11 @@
++// Copyright 2016 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.
++
++// +build sparc sparc64
++
++package unix
++
++// Linux getrandom system call number.
++// See GetRandom in getrandom_linux.go.
++const randomTrap uintptr = 347
+Index: b/src/libgo/go/internal/syscall/unix/getrandom_linux_mips64x.go
+===================================================================
+--- a/src/libgo/go/internal/syscall/unix/getrandom_linux_mips64x.go	(revision 240456)
++++ b/src/libgo/go/internal/syscall/unix/getrandom_linux_mips64x.go	(revision 240457)
+@@ -2,7 +2,7 @@
+ // Use of this source code is governed by a BSD-style
+ // license that can be found in the LICENSE file.
+ 
+-// +build mips64 mips64le
++// +build mips64 mips64le mipsn64 mipso64
+ 
+ package unix
+ 
+Index: b/src/libgo/go/internal/syscall/unix/getrandom_linux_mipsn32.go
+===================================================================
+--- a/src/libgo/go/internal/syscall/unix/getrandom_linux_mipsn32.go	(nonexistent)
++++ b/src/libgo/go/internal/syscall/unix/getrandom_linux_mipsn32.go	(revision 240457)
+@@ -0,0 +1,11 @@
++// Copyright 2016 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.
++
++// +build mipsn32
++
++package unix
++
++// Linux getrandom system call number.
++// See GetRandom in getrandom_linux.go.
++const randomTrap uintptr = 6317
only in patch2:
unchanged:
--- gcc-6-6.2.0.orig/debian/patches/libgo-elf-relocations-sparc64.diff
+++ gcc-6-6.2.0/debian/patches/libgo-elf-relocations-sparc64.diff
@@ -0,0 +1,107 @@
+# DP: Backport r241051 from trunk
+
+debug/elf: add sparc64 relocations
+
+This is a backport of https://go-review.googlesource.com/30870.
+
+Reviewed-on: https://go-review.googlesource.com/30916
+
+Index: b/src/libgo/go/debug/elf/file_test.go
+===================================================================
+--- a/src/libgo/go/debug/elf/file_test.go	(revision 241170)
++++ b/src/libgo/go/debug/elf/file_test.go	(revision 241171)
+@@ -492,6 +492,25 @@
+ 		},
+ 	},
+ 	{
++		"testdata/go-relocation-test-gcc620-sparc64.obj",
++		[]relocationTestEntry{
++			{0, &dwarf.Entry{
++				Offset:   0xb,
++				Tag:      dwarf.TagCompileUnit,
++				Children: true,
++				Field: []dwarf.Field{
++					{Attr: dwarf.AttrProducer, Val: "GNU C11 6.2.0 20160914 -mcpu=v9 -g -fstack-protector-strong", Class: dwarf.ClassString},
++					{Attr: dwarf.AttrLanguage, Val: int64(12), Class: dwarf.ClassConstant},
++					{Attr: dwarf.AttrName, Val: "hello.c", Class: dwarf.ClassString},
++					{Attr: dwarf.AttrCompDir, Val: "/tmp", Class: dwarf.ClassString},
++					{Attr: dwarf.AttrLowpc, Val: uint64(0x0), Class: dwarf.ClassAddress},
++					{Attr: dwarf.AttrHighpc, Val: int64(0x2c), Class: dwarf.ClassConstant},
++					{Attr: dwarf.AttrStmtList, Val: int64(0), Class: dwarf.ClassLinePtr},
++				},
++			}},
++		},
++	},
++	{
+ 		"testdata/go-relocation-test-gcc493-mips64le.obj",
+ 		[]relocationTestEntry{
+ 			{0, &dwarf.Entry{
+Index: b/src/libgo/go/debug/elf/file.go
+===================================================================
+--- a/src/libgo/go/debug/elf/file.go	(revision 241170)
++++ b/src/libgo/go/debug/elf/file.go	(revision 241171)
+@@ -598,6 +598,8 @@
+ 		return f.applyRelocationsMIPS64(dst, rels)
+ 	case f.Class == ELFCLASS64 && f.Machine == EM_S390:
+ 		return f.applyRelocationsS390x(dst, rels)
++	case f.Class == ELFCLASS64 && f.Machine == EM_SPARCV9:
++		return f.applyRelocationsSPARC64(dst, rels)
+ 	default:
+ 		return errors.New("applyRelocations: not implemented")
+ 	}
+@@ -962,6 +964,51 @@
+ 	return nil
+ }
+ 
++func (f *File) applyRelocationsSPARC64(dst []byte, rels []byte) error {
++	// 24 is the size of Rela64.
++	if len(rels)%24 != 0 {
++		return errors.New("length of relocation section is not a multiple of 24")
++	}
++
++	symbols, _, err := f.getSymbols(SHT_SYMTAB)
++	if err != nil {
++		return err
++	}
++
++	b := bytes.NewReader(rels)
++	var rela Rela64
++
++	for b.Len() > 0 {
++		binary.Read(b, f.ByteOrder, &rela)
++		symNo := rela.Info >> 32
++		t := R_SPARC(rela.Info & 0xffff)
++
++		if symNo == 0 || symNo > uint64(len(symbols)) {
++			continue
++		}
++		sym := &symbols[symNo-1]
++		if SymType(sym.Info&0xf) != STT_SECTION {
++			// We don't handle non-section relocations for now.
++			continue
++		}
++
++		switch t {
++		case R_SPARC_64, R_SPARC_UA64:
++			if rela.Off+8 >= uint64(len(dst)) || rela.Addend < 0 {
++				continue
++			}
++			f.ByteOrder.PutUint64(dst[rela.Off:rela.Off+8], uint64(rela.Addend))
++		case R_SPARC_32, R_SPARC_UA32:
++			if rela.Off+4 >= uint64(len(dst)) || rela.Addend < 0 {
++				continue
++			}
++			f.ByteOrder.PutUint32(dst[rela.Off:rela.Off+4], uint32(rela.Addend))
++		}
++	}
++
++	return nil
++}
++
+ func (f *File) DWARF() (*dwarf.Data, error) {
+ 	// sectionData gets the data for s, checks its size, and
+ 	// applies any applicable relations.
+Index: b/src/libgo/go/debug/elf/testdata/go-relocation-test-gcc620-sparc64.obj
+===================================================================
+Cannot display: file marked as a binary type.
+svn:mime-type = application/octet-stream
only in patch2:
unchanged:
--- gcc-6-6.2.0.orig/debian/patches/libgo-fix-getrandom-clone-sparc64.diff
+++ gcc-6-6.2.0/debian/patches/libgo-fix-getrandom-clone-sparc64.diff
@@ -0,0 +1,343 @@
+# DP: Backport r241072 from trunk
+
+syscall, internal/syscall/unix: Fix getrandom, clone on sparc64
+
+Since sparc is a valid architecture, the name of
+getrandom_linux_sparc.go means that it will be ignored on sparc64,
+even though it's whitelisted with a +build line.
+
+On SPARC, clone has a unique return value convention which requires
+some inline assembly to convert it to the normal convention.
+
+Reviewed-on: https://go-review.googlesource.com/30873
+
+Index: b/src/libgo/mksysinfo.sh
+===================================================================
+--- a/src/libgo/mksysinfo.sh
++++ b/src/libgo/mksysinfo.sh
+@@ -603,8 +603,10 @@ fi
+ sizeof_long=`grep '^const ___SIZEOF_LONG__ = ' gen-sysinfo.go | sed -e 's/.*= //'`
+ if test "$sizeof_long" = "4"; then
+   echo "type _C_long int32" >> ${OUT}
++  echo "type _C_ulong uint32" >> ${OUT}
+ elif test "$sizeof_long" = "8"; then
+   echo "type _C_long int64" >> ${OUT}
++  echo "type _C_ulong uint64" >> ${OUT}
+ else
+   echo 1>&2 "mksysinfo.sh: could not determine size of long (got $sizeof_long)"
+   exit 1
+Index: b/src/libgo/go/internal/syscall/unix/getrandom_linux_sparc.go
+===================================================================
+--- a/src/libgo/go/internal/syscall/unix/getrandom_linux_sparc.go
++++ b/src/libgo/go/internal/syscall/unix/getrandom_linux_sparc.go
+@@ -1,11 +0,0 @@
+-// Copyright 2016 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.
+-
+-// +build sparc sparc64
+-
+-package unix
+-
+-// Linux getrandom system call number.
+-// See GetRandom in getrandom_linux.go.
+-const randomTrap uintptr = 347
+Index: b/src/libgo/go/internal/syscall/unix/getrandom_linux_sparcx.go
+===================================================================
+--- /dev/null
++++ b/src/libgo/go/internal/syscall/unix/getrandom_linux_sparcx.go
+@@ -0,0 +1,11 @@
++// Copyright 2016 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.
++
++// +build sparc sparc64
++
++package unix
++
++// Linux getrandom system call number.
++// See GetRandom in getrandom_linux.go.
++const randomTrap uintptr = 347
+Index: b/src/libgo/go/syscall/clone_linux.c
+===================================================================
+--- /dev/null
++++ b/src/libgo/go/syscall/clone_linux.c
+@@ -0,0 +1,100 @@
++/* clone_linux.c -- consistent wrapper around Linux clone syscall
++
++   Copyright 2016 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.  */
++
++#include <errno.h>
++#include <asm/ptrace.h>
++#include <sys/syscall.h>
++
++#include "runtime.h"
++
++long rawClone (unsigned long flags, void *child_stack, void *ptid, void *ctid, struct pt_regs *regs) __asm__ (GOSYM_PREFIX "syscall.rawClone");
++
++long
++rawClone (unsigned long flags, void *child_stack, void *ptid, void *ctid, struct pt_regs *regs)
++{
++#if defined(__arc__) || defined(__aarch64__) || defined(__arm__) || defined(__mips__) || defined(__hppa__) || defined(__powerpc__) || defined(__score__) || defined(__i386__) || defined(__xtensa__)
++  // CLONE_BACKWARDS
++  return syscall(__NR_clone, flags, child_stack, ptid, regs, ctid);
++#elif defined(__s390__) || defined(__cris__)
++  // CLONE_BACKWARDS2
++  return syscall(__NR_clone, child_stack, flags, ptid, ctid, regs);
++#elif defined(__microblaze__)
++  // CLONE_BACKWARDS3
++  return syscall(__NR_clone, flags, child_stack, 0, ptid, ctid, regs);
++#elif defined(__sparc__)
++
++  /* SPARC has a unique return value convention:
++
++     Parent -->  %o0 == child's  pid, %o1 == 0
++     Child  -->  %o0 == parent's pid, %o1 == 1
++
++     Translate this to look like a normal clone.  */
++
++# if defined(__arch64__)
++
++#  define SYSCALL_STRING						\
++	"ta	0x6d;"							\
++	"bcc,pt	%%xcc, 1f;"						\
++	" mov	0, %%g1;"						\
++	"sub	%%g0, %%o0, %%o0;"					\
++	"mov	1, %%g1;"						\
++	"1:"
++
++#  define SYSCALL_CLOBBERS						\
++	"f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",			\
++	"f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",		\
++	"f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23",		\
++	"f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31",		\
++	"f32", "f34", "f36", "f38", "f40", "f42", "f44", "f46",		\
++	"f48", "f50", "f52", "f54", "f56", "f58", "f60", "f62",		\
++	"cc", "memory"
++
++# else /* __arch64__ */
++
++#  define SYSCALL_STRING						\
++	"ta	0x10;"							\
++	"bcc	1f;"							\
++	" mov	0, %%g1;"						\
++	"sub	%%g0, %%o0, %%o0;"					\
++	"mov	1, %%g1;"						\
++	"1:"
++
++#  define SYSCALL_CLOBBERS						\
++	"f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",			\
++	"f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",		\
++	"f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23",		\
++	"f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31",		\
++	"cc", "memory"
++
++# endif /* __arch64__ */
++
++  register long o0 __asm__ ("o0") = (long)flags;
++  register long o1 __asm__ ("o1") = (long)child_stack;
++  register long o2 __asm__ ("o2") = (long)ptid;
++  register long o3 __asm__ ("o3") = (long)ctid;
++  register long o4 __asm__ ("o4") = (long)regs;
++  register long g1 __asm__ ("g1") = __NR_clone;
++
++  __asm __volatile (SYSCALL_STRING :
++		    "=r" (g1), "=r" (o0), "=r" (o1) :
++		    "0" (g1), "1" (o0), "2" (o1),
++		    "r" (o2), "r" (o3), "r" (o4) :
++		    SYSCALL_CLOBBERS);
++
++  if (__builtin_expect(g1 != 0, 0))
++    {
++      errno = -o0;
++      o0 = -1L;
++    }
++  else
++    o0 &= (o1 - 1);
++
++  return o0;
++
++#else
++  return syscall(__NR_clone, flags, child_stack, ptid, ctid, regs);
++#endif
++}
+Index: b/src/libgo/go/syscall/exec_linux.go
+===================================================================
+--- a/src/libgo/go/syscall/exec_linux.go
++++ b/src/libgo/go/syscall/exec_linux.go
+@@ -7,7 +7,6 @@
+ package syscall
+ 
+ import (
+-	"runtime"
+ 	"unsafe"
+ )
+ 
+@@ -48,6 +47,9 @@ type SysProcAttr struct {
+ func runtime_BeforeFork()
+ func runtime_AfterFork()
+ 
++// Implemented in clone_linux.c
++func rawClone(flags _C_ulong, child_stack *byte, ptid *Pid_t, ctid *Pid_t, regs unsafe.Pointer) _C_long
++
+ // Fork, dup fd onto 0..len(fd), and exec(argv0, argvv, envv) in child.
+ // If a dup or exec fails, write the errno error to pipe.
+ // (Pipe is close-on-exec so if exec succeeds, it will be closed.)
+@@ -63,6 +65,7 @@ func forkAndExecInChild(argv0 *byte, arg
+ 	// declarations require heap allocation (e.g., err1).
+ 	var (
+ 		r1     uintptr
++		r2     _C_long
+ 		err1   Errno
+ 		err2   Errno
+ 		nextfd int
+@@ -97,20 +100,16 @@ func forkAndExecInChild(argv0 *byte, arg
+ 	// About to call fork.
+ 	// No more allocation or calls of non-assembly functions.
+ 	runtime_BeforeFork()
+-	if runtime.GOARCH == "s390x" || runtime.GOARCH == "s390" {
+-		r1, _, err1 = RawSyscall6(SYS_CLONE, 0, uintptr(SIGCHLD)|sys.Cloneflags, 0, 0, 0, 0)
+-	} else {
+-		r1, _, err1 = RawSyscall6(SYS_CLONE, uintptr(SIGCHLD)|sys.Cloneflags, 0, 0, 0, 0, 0)
+-	}
+-	if err1 != 0 {
++	r2 = rawClone(_C_ulong(uintptr(SIGCHLD)|sys.Cloneflags), nil, nil, nil, unsafe.Pointer(nil))
++	if r2 < 0 {
+ 		runtime_AfterFork()
+-		return 0, err1
++		return 0, GetErrno()
+ 	}
+ 
+-	if r1 != 0 {
++	if r2 != 0 {
+ 		// parent; return PID
+ 		runtime_AfterFork()
+-		pid = int(r1)
++		pid = int(r2)
+ 
+ 		if sys.UidMappings != nil || sys.GidMappings != nil {
+ 			Close(p[0])
+Index: b/src/libgo/Makefile.am
+===================================================================
+--- a/src/libgo/Makefile.am
++++ b/src/libgo/Makefile.am
+@@ -2145,6 +2145,12 @@ else
+ os_lib_inotify_lo =
+ endif
+ 
++if LIBGO_IS_LINUX
++syscall_lib_clone_lo = syscall/clone_linux.lo
++else
++syscall_lib_clone_lo =
++endif
++
+ libgo_go_objs = \
+ 	bufio.lo \
+ 	bytes.lo \
+@@ -2175,6 +2181,7 @@ libgo_go_objs = \
+ 	strings/index.lo \
+ 	sync.lo \
+ 	syscall.lo \
++	$(syscall_lib_clone_lo) \
+ 	syscall/errno.lo \
+ 	syscall/signame.lo \
+ 	syscall/wait.lo \
+@@ -3820,6 +3827,9 @@ syscall.lo.dep: $(go_syscall_files)
+ 	$(BUILDDEPS)
+ syscall.lo: $(go_syscall_files)
+ 	$(BUILDPACKAGE)
++syscall/clone_linux.lo: go/syscall/clone_linux.c
++	@$(MKDIR_P) syscall
++	$(LTCOMPILE) -c -o $@ $<
+ syscall/errno.lo: go/syscall/errno.c
+ 	@$(MKDIR_P) syscall
+ 	$(LTCOMPILE) -c -o $@ $<
+Index: b/src/libgo/Makefile.in
+===================================================================
+--- a/src/libgo/Makefile.in
++++ b/src/libgo/Makefile.in
+@@ -173,15 +173,16 @@ am__objects_3 = $(am__objects_2)
+ am_libnetgo_a_OBJECTS = $(am__objects_3)
+ libnetgo_a_OBJECTS = $(am_libnetgo_a_OBJECTS)
+ LTLIBRARIES = $(toolexeclib_LTLIBRARIES)
+-am__DEPENDENCIES_1 =
+-am__DEPENDENCIES_2 = bufio.lo bytes.lo bytes/index.lo crypto.lo \
++@LIBGO_IS_LINUX_TRUE@am__DEPENDENCIES_1 = syscall/clone_linux.lo
++am__DEPENDENCIES_2 =
++am__DEPENDENCIES_3 = bufio.lo bytes.lo bytes/index.lo crypto.lo \
+ 	encoding.lo errors.lo expvar.lo flag.lo fmt.lo hash.lo html.lo \
+ 	image.lo io.lo log.lo math.lo mime.lo net.lo os.lo path.lo \
+ 	reflect-go.lo reflect/makefunc_ffi_c.lo regexp.lo \
+ 	runtime-go.lo sort.lo strconv.lo strings.lo strings/index.lo \
+-	sync.lo syscall.lo syscall/errno.lo syscall/signame.lo \
+-	syscall/wait.lo testing.lo time-go.lo unicode.lo \
+-	archive/tar.lo archive/zip.lo compress/bzip2.lo \
++	sync.lo syscall.lo $(am__DEPENDENCIES_1) syscall/errno.lo \
++	syscall/signame.lo syscall/wait.lo testing.lo time-go.lo \
++	unicode.lo archive/tar.lo archive/zip.lo compress/bzip2.lo \
+ 	compress/flate.lo compress/gzip.lo compress/lzw.lo \
+ 	compress/zlib.lo container/heap.lo container/list.lo \
+ 	container/ring.lo crypto/aes.lo crypto/cipher.lo crypto/des.lo \
+@@ -213,18 +214,18 @@ am__DEPENDENCIES_2 = bufio.lo bytes.lo b
+ 	math/rand.lo mime/multipart.lo mime/quotedprintable.lo \
+ 	net/http.lo net/internal/socktest.lo net/mail.lo net/rpc.lo \
+ 	net/smtp.lo net/textproto.lo net/url.lo old/regexp.lo \
+-	old/template.lo os/exec.lo $(am__DEPENDENCIES_1) os/signal.lo \
++	old/template.lo os/exec.lo $(am__DEPENDENCIES_2) os/signal.lo \
+ 	os/user.lo path/filepath.lo regexp/syntax.lo \
+ 	net/rpc/jsonrpc.lo runtime/debug.lo runtime/pprof.lo \
+ 	sync/atomic.lo sync/atomic_c.lo text/scanner.lo \
+ 	text/tabwriter.lo text/template.lo text/template/parse.lo \
+ 	testing/iotest.lo testing/quick.lo unicode/utf16.lo \
+ 	unicode/utf8.lo
+-am__DEPENDENCIES_3 = $(am__DEPENDENCIES_2) \
+-	../libbacktrace/libbacktrace.la $(am__DEPENDENCIES_1) \
+-	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+-	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+-libgo_llgo_la_DEPENDENCIES = $(am__DEPENDENCIES_3)
++am__DEPENDENCIES_4 = $(am__DEPENDENCIES_3) \
++	../libbacktrace/libbacktrace.la $(am__DEPENDENCIES_2) \
++	$(am__DEPENDENCIES_2) $(am__DEPENDENCIES_2) \
++	$(am__DEPENDENCIES_2) $(am__DEPENDENCIES_2)
++libgo_llgo_la_DEPENDENCIES = $(am__DEPENDENCIES_4)
+ @LIBGO_IS_LINUX_FALSE@am__objects_4 = lock_sema.lo thread-sema.lo
+ @LIBGO_IS_LINUX_TRUE@am__objects_4 = lock_futex.lo thread-linux.lo
+ @HAVE_SYS_MMAN_H_FALSE@am__objects_5 = mem_posix_memalign.lo
+@@ -276,7 +277,7 @@ libgo_llgo_la_LINK = $(LIBTOOL) --tag=CC
+ 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ 	$(libgo_llgo_la_LDFLAGS) $(LDFLAGS) -o $@
+ @GOC_IS_LLGO_TRUE@am_libgo_llgo_la_rpath = -rpath $(toolexeclibdir)
+-libgo_la_DEPENDENCIES = $(am__DEPENDENCIES_3)
++libgo_la_DEPENDENCIES = $(am__DEPENDENCIES_4)
+ am_libgo_la_OBJECTS = $(am__objects_9)
+ libgo_la_OBJECTS = $(am_libgo_la_OBJECTS)
+ libgo_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+@@ -2156,6 +2157,8 @@ go_syscall_test_files = \
+ 
+ # os_lib_inotify_lo = os/inotify.lo
+ @LIBGO_IS_LINUX_TRUE@os_lib_inotify_lo = 
++@LIBGO_IS_LINUX_FALSE@syscall_lib_clone_lo = 
++@LIBGO_IS_LINUX_TRUE@syscall_lib_clone_lo = syscall/clone_linux.lo
+ libgo_go_objs = \
+ 	bufio.lo \
+ 	bytes.lo \
+@@ -2186,6 +2189,7 @@ libgo_go_objs = \
+ 	strings/index.lo \
+ 	sync.lo \
+ 	syscall.lo \
++	$(syscall_lib_clone_lo) \
+ 	syscall/errno.lo \
+ 	syscall/signame.lo \
+ 	syscall/wait.lo \
+@@ -6197,6 +6201,9 @@ syscall.lo.dep: $(go_syscall_files)
+ 	$(BUILDDEPS)
+ syscall.lo: $(go_syscall_files)
+ 	$(BUILDPACKAGE)
++syscall/clone_linux.lo: go/syscall/clone_linux.c
++	@$(MKDIR_P) syscall
++	$(LTCOMPILE) -c -o $@ $<
+ syscall/errno.lo: go/syscall/errno.c
+ 	@$(MKDIR_P) syscall
+ 	$(LTCOMPILE) -c -o $@ $<
only in patch2:
unchanged:
--- gcc-6-6.2.0.orig/debian/patches/libgo-rawClone-no-pt_regs.diff
+++ gcc-6-6.2.0/debian/patches/libgo-rawClone-no-pt_regs.diff
@@ -0,0 +1,33 @@
+# DP: Backport r241084 from trunk
+
+syscall: don't use pt_regs in clone_linux.c
+
+It's unnecessary and it reportedly breaks the build on arm64 GNU/Linux.
+
+Reviewed-on: https://go-review.googlesource.com/30978
+
+Index: b/src/libgo/go/syscall/clone_linux.c
+===================================================================
+--- a/src/libgo/go/syscall/clone_linux.c	(revision 241083)
++++ b/src/libgo/go/syscall/clone_linux.c	(revision 241084)
+@@ -5,18 +5,17 @@
+    license that can be found in the LICENSE file.  */
+ 
+ #include <errno.h>
+-#include <asm/ptrace.h>
+ #include <sys/syscall.h>
+ 
+ #include "runtime.h"
+ 
+ long rawClone (unsigned long flags, void *child_stack, void *ptid,
+-	       void *ctid, struct pt_regs *regs)
++	       void *ctid, void *regs)
+   __asm__ (GOSYM_PREFIX "syscall.rawClone")
+   __attribute__ ((no_split_stack));
+ 
+ long
+-rawClone (unsigned long flags, void *child_stack, void *ptid, void *ctid, struct pt_regs *regs)
++rawClone (unsigned long flags, void *child_stack, void *ptid, void *ctid, void *regs)
+ {
+ #if defined(__arc__) || defined(__aarch64__) || defined(__arm__) || defined(__mips__) || defined(__hppa__) || defined(__powerpc__) || defined(__score__) || defined(__i386__) || defined(__xtensa__)
+   // CLONE_BACKWARDS
only in patch2:
unchanged:
--- gcc-6-6.2.0.orig/debian/patches/libgo-rawClone-no_split_stack.diff
+++ gcc-6-6.2.0/debian/patches/libgo-rawClone-no_split_stack.diff
@@ -0,0 +1,22 @@
+# DP: Backport r241171 from trunk
+
+syscall: mark rawClone as no_split_stack
+
+Reviewed-on: https://go-review.googlesource.com/30955
+
+Index: b/src/libgo/go/syscall/clone_linux.c
+===================================================================
+--- a/src/libgo/go/syscall/clone_linux.c	(revision 241071)
++++ b/src/libgo/go/syscall/clone_linux.c	(revision 241072)
+@@ -10,7 +10,10 @@
+ 
+ #include "runtime.h"
+ 
+-long rawClone (unsigned long flags, void *child_stack, void *ptid, void *ctid, struct pt_regs *regs) __asm__ (GOSYM_PREFIX "syscall.rawClone");
++long rawClone (unsigned long flags, void *child_stack, void *ptid,
++	       void *ctid, struct pt_regs *regs)
++  __asm__ (GOSYM_PREFIX "syscall.rawClone")
++  __attribute__ ((no_split_stack));
+ 
+ long
+ rawClone (unsigned long flags, void *child_stack, void *ptid, void *ctid, struct pt_regs *regs)

Attachment: signature.asc
Description: PGP signature


Reply to: