git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #27230 from robx/go16

go_1_6: Fix darwin (sierra) compile, backport systime syscall fix

commitca1089a4f48cee4516fd4a90801ae09059e4a51d authorDaniel Peebles <copumpkin@users.noreply.github.com> dateSat 8 Jul 2017, 12:44 (9 years ago) parentec4a8bbf65b55d
2 files changed+46
pkgs/development/compilers/go/1.6.nix+1 pkgs/development/compilers/go/fix-systime-1.6.patch+45
pkgs/development/compilers/go/1.6.nix+1
@@ -113,6 +113,7 @@ stdenv.mkDerivation rec {
113113 patches = [
114114 ./remove-tools-1.5.patch
115115 ./creds-test.patch
116+ ./fix-systime-1.6.patch
116117
117118 # This test checks for the wrong thing with recent tzdata. It's been fixed in master but the patch
118119 # actually works on old versions too.
pkgs/development/compilers/go/fix-systime-1.6.patchnew file+45
@@ -0,0 +1,45 @@
1+diff --git a/src/runtime/sys_darwin_amd64.s b/src/runtime/sys_darwin_amd64.s
2+index e09b906ba5..fa8ff2f65c 100644
3+--- a/src/runtime/sys_darwin_amd64.s
4++++ b/src/runtime/sys_darwin_amd64.s
5+@@ -157,6 +157,7 @@ systime:
6+ // Fall back to system call (usually first call in this thread).
7+ MOVQ SP, DI
8+ MOVQ $0, SI
9++ MOVQ $0, DX // required as of Sierra; Issue 16570
10+ MOVL $(0x2000000+116), AX
11+ SYSCALL
12+ CMPQ AX, $0
13+diff --git a/src/syscall/syscall_darwin_amd64.go b/src/syscall/syscall_darwin_amd64.go
14+index 70b53b87f4..79083117b6 100644
15+--- a/src/syscall/syscall_darwin_amd64.go
16++++ b/src/syscall/syscall_darwin_amd64.go
17+@@ -26,14 +26,21 @@ func NsecToTimeval(nsec int64) (tv Timeval) {
18+ }
19+
20+ //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error)
21+-func Gettimeofday(tv *Timeval) (err error) {
22+- // The tv passed to gettimeofday must be non-nil
23+- // but is otherwise unused. The answers come back
24+- // in the two registers.
25++func Gettimeofday(tv *Timeval) error {
26++ // The tv passed to gettimeofday must be non-nil.
27++ // Before macOS Sierra (10.12), tv was otherwise unused and
28++ // the answers came back in the two registers.
29++ // As of Sierra, gettimeofday return zeros and populates
30++ // tv itself.
31+ sec, usec, err := gettimeofday(tv)
32+- tv.Sec = sec
33+- tv.Usec = usec
34+- return err
35++ if err != nil {
36++ return err
37++ }
38++ if sec != 0 || usec != 0 {
39++ tv.Sec = sec
40++ tv.Usec = usec
41++ }
42++ return nil
43+ }
44+
45+ func SetKevent(k *Kevent_t, fd, mode, flags int) {