summary refs log tree commit diff
diff options
context:
space:
mode:
authorDaniel Peebles <copumpkin@users.noreply.github.com>2017-07-08 12:44:35 -0400
committerGitHub <noreply@github.com>2017-07-08 12:44:35 -0400
commitca1089a4f48cee4516fd4a90801ae09059e4a51d (patch)
tree99a5fe49b1b5d450a56ec12ca621a58822fc4092
parentec4a8bb4b4d6b88a824b6d58888018d8331db4ba (diff)
parentf65b55d7ce760a3c9957cc3da1127c1f8fe8e33c (diff)
downloadnixlib-ca1089a4f48cee4516fd4a90801ae09059e4a51d.tar
nixlib-ca1089a4f48cee4516fd4a90801ae09059e4a51d.tar.gz
nixlib-ca1089a4f48cee4516fd4a90801ae09059e4a51d.tar.bz2
nixlib-ca1089a4f48cee4516fd4a90801ae09059e4a51d.tar.lz
nixlib-ca1089a4f48cee4516fd4a90801ae09059e4a51d.tar.xz
nixlib-ca1089a4f48cee4516fd4a90801ae09059e4a51d.tar.zst
nixlib-ca1089a4f48cee4516fd4a90801ae09059e4a51d.zip
Merge pull request #27230 from robx/go16
go_1_6: Fix darwin (sierra) compile, backport systime syscall fix
-rw-r--r--pkgs/development/compilers/go/1.6.nix1
-rw-r--r--pkgs/development/compilers/go/fix-systime-1.6.patch45
2 files changed, 46 insertions, 0 deletions
diff --git a/pkgs/development/compilers/go/1.6.nix b/pkgs/development/compilers/go/1.6.nix
index 4a777d7b4f14..61408c0ebb34 100644
--- a/pkgs/development/compilers/go/1.6.nix
+++ b/pkgs/development/compilers/go/1.6.nix
@@ -113,6 +113,7 @@ stdenv.mkDerivation rec {
   patches = [
     ./remove-tools-1.5.patch
     ./creds-test.patch
+    ./fix-systime-1.6.patch
 
     # This test checks for the wrong thing with recent tzdata. It's been fixed in master but the patch
     # actually works on old versions too.
diff --git a/pkgs/development/compilers/go/fix-systime-1.6.patch b/pkgs/development/compilers/go/fix-systime-1.6.patch
new file mode 100644
index 000000000000..e4a3932001e5
--- /dev/null
+++ b/pkgs/development/compilers/go/fix-systime-1.6.patch
@@ -0,0 +1,45 @@
+diff --git a/src/runtime/sys_darwin_amd64.s b/src/runtime/sys_darwin_amd64.s
+index e09b906ba5..fa8ff2f65c 100644
+--- a/src/runtime/sys_darwin_amd64.s
++++ b/src/runtime/sys_darwin_amd64.s
+@@ -157,6 +157,7 @@ systime:
+ 	// Fall back to system call (usually first call in this thread).
+ 	MOVQ	SP, DI
+ 	MOVQ	$0, SI
++	MOVQ	$0, DX  // required as of Sierra; Issue 16570
+ 	MOVL	$(0x2000000+116), AX
+ 	SYSCALL
+ 	CMPQ	AX, $0
+diff --git a/src/syscall/syscall_darwin_amd64.go b/src/syscall/syscall_darwin_amd64.go
+index 70b53b87f4..79083117b6 100644
+--- a/src/syscall/syscall_darwin_amd64.go
++++ b/src/syscall/syscall_darwin_amd64.go
+@@ -26,14 +26,21 @@ func NsecToTimeval(nsec int64) (tv Timeval) {
+ }
+ 
+ //sysnb	gettimeofday(tp *Timeval) (sec int64, usec int32, err error)
+-func Gettimeofday(tv *Timeval) (err error) {
+-	// The tv passed to gettimeofday must be non-nil
+-	// but is otherwise unused.  The answers come back
+-	// in the two registers.
++func Gettimeofday(tv *Timeval) error {
++	// The tv passed to gettimeofday must be non-nil.
++	// Before macOS Sierra (10.12), tv was otherwise unused and
++	// the answers came back in the two registers.
++	// As of Sierra, gettimeofday return zeros and populates
++	// tv itself.
+ 	sec, usec, err := gettimeofday(tv)
+-	tv.Sec = sec
+-	tv.Usec = usec
+-	return err
++	if err != nil {
++		return err
++	}
++	if sec != 0 || usec != 0 {
++		tv.Sec = sec
++		tv.Usec = usec
++	}
++	return nil
+ }
+ 
+ func SetKevent(k *Kevent_t, fd, mode, flags int) {