Skip to content

Commit

Permalink
unix: drop support for pre-1.12 direct syscalls on darwin
Browse files Browse the repository at this point in the history
Go 1.12 and newer are using libSystem for syscalls on darwin.
Go 1.11 is the last release to use direct syscalls. It hasn't been
supported since the release of Go 1.13 in September 2019, so drop
support for direct syscalls.

Change-Id: I2baf6f3d1031de8e474dc770369a25147e5efe2a
Reviewed-on: https://go-review.googlesource.com/c/sys/+/250437
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
  • Loading branch information
tklauser committed Aug 28, 2020
1 parent f9321e4 commit 6fcdbc0
Show file tree
Hide file tree
Showing 17 changed files with 0 additions and 8,990 deletions.
6 changes: 0 additions & 6 deletions unix/mkall.sh
Expand Up @@ -73,26 +73,22 @@ aix_ppc64)
darwin_386)
mkerrors="$mkerrors -m32"
mksyscall="go run mksyscall.go -l32"
mksysnum="go run mksysnum.go $(xcrun --show-sdk-path --sdk macosx)/usr/include/sys/syscall.h"
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
mkasm="go run mkasm_darwin.go"
;;
darwin_amd64)
mkerrors="$mkerrors -m64"
mksysnum="go run mksysnum.go $(xcrun --show-sdk-path --sdk macosx)/usr/include/sys/syscall.h"
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
mkasm="go run mkasm_darwin.go"
;;
darwin_arm)
mkerrors="$mkerrors"
mksyscall="go run mksyscall.go -l32"
mksysnum="go run mksysnum.go $(xcrun --show-sdk-path --sdk iphoneos)/usr/include/sys/syscall.h"
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
mkasm="go run mkasm_darwin.go"
;;
darwin_arm64)
mkerrors="$mkerrors -m64"
mksysnum="go run mksysnum.go $(xcrun --show-sdk-path --sdk iphoneos)/usr/include/sys/syscall.h"
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
mkasm="go run mkasm_darwin.go"
;;
Expand Down Expand Up @@ -226,8 +222,6 @@ esac
# aix/ppc64 script generates files instead of writing to stdin.
echo "$mksyscall -tags $GOOS,$GOARCH $syscall_goos $GOOSARCH_in && gofmt -w zsyscall_$GOOSARCH.go && gofmt -w zsyscall_"$GOOSARCH"_gccgo.go && gofmt -w zsyscall_"$GOOSARCH"_gc.go " ;
elif [ "$GOOS" == "darwin" ]; then
# pre-1.12, direct syscalls
echo "$mksyscall -tags $GOOS,$GOARCH,!go1.12 $syscall_goos syscall_darwin_${GOARCH}.1_11.go $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.1_11.go";
# 1.12 and later, syscalls via libSystem
echo "$mksyscall -tags $GOOS,$GOARCH,go1.12 $syscall_goos $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.go";
# 1.13 and later, syscalls via libSystem (including syscallPtr)
Expand Down
9 changes: 0 additions & 9 deletions unix/syscall_darwin_386.1_11.go

This file was deleted.

4 changes: 0 additions & 4 deletions unix/syscall_darwin_386.go
Expand Up @@ -44,10 +44,6 @@ func (cmsg *Cmsghdr) SetLen(length int) {

func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)

// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
// of darwin/386 the syscall is called sysctl instead of __sysctl.
const SYS___SYSCTL = SYS_SYSCTL

//sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64
//sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64
//sys Fstatfs(fd int, stat *Statfs_t) (err error) = SYS_FSTATFS64
Expand Down
9 changes: 0 additions & 9 deletions unix/syscall_darwin_amd64.1_11.go

This file was deleted.

4 changes: 0 additions & 4 deletions unix/syscall_darwin_amd64.go
Expand Up @@ -44,10 +44,6 @@ func (cmsg *Cmsghdr) SetLen(length int) {

func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)

// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
// of darwin/amd64 the syscall is called sysctl instead of __sysctl.
const SYS___SYSCTL = SYS_SYSCTL

//sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64
//sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64
//sys Fstatfs(fd int, stat *Statfs_t) (err error) = SYS_FSTATFS64
Expand Down
11 changes: 0 additions & 11 deletions unix/syscall_darwin_arm.1_11.go

This file was deleted.

4 changes: 0 additions & 4 deletions unix/syscall_darwin_arm.go
Expand Up @@ -44,10 +44,6 @@ func (cmsg *Cmsghdr) SetLen(length int) {

func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic

// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
// of darwin/arm the syscall is called sysctl instead of __sysctl.
const SYS___SYSCTL = SYS_SYSCTL

//sys Fstat(fd int, stat *Stat_t) (err error)
//sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error)
//sys Fstatfs(fd int, stat *Statfs_t) (err error)
Expand Down
11 changes: 0 additions & 11 deletions unix/syscall_darwin_arm64.1_11.go

This file was deleted.

4 changes: 0 additions & 4 deletions unix/syscall_darwin_arm64.go
Expand Up @@ -46,10 +46,6 @@ func (cmsg *Cmsghdr) SetLen(length int) {

func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic

// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
// of darwin/arm64 the syscall is called sysctl instead of __sysctl.
const SYS___SYSCTL = SYS_SYSCTL

//sys Fstat(fd int, stat *Stat_t) (err error)
//sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error)
//sys Fstatfs(fd int, stat *Statfs_t) (err error)
Expand Down

7 comments on commit 6fcdbc0

@itchyny
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit makes the build fail with Go 1.12 on macOS. SYS_GETDIRENTRIES64 is still used at

r0, _, e1 := Syscall6(SYS_GETDIRENTRIES64, uintptr(fd), uintptr(p), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0)
, which was defined in zsysnum_darwin_amd64.go. You dropped intentionally supporting Go 1.12 from this commit, right? We can cleanup the syscall_darwin.1_12.go and update go.mod.

# golang.org/x/sys/unix
##[error]../../../go/src/golang.org/x/sys/unix/syscall_darwin.1_12.go:23:24: undefined: SYS_GETDIRENTRIES64

@tklauser
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit makes the build fail with Go 1.12 on macOS. SYS_GETDIRENTRIES64 is still used at

r0, _, e1 := Syscall6(SYS_GETDIRENTRIES64, uintptr(fd), uintptr(p), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0)

, which was defined in zsysnum_darwin_amd64.go. You dropped intentionally supporting Go 1.12 from this commit, right? We can cleanup the syscall_darwin.1_12.go and update go.mod.

# golang.org/x/sys/unix
##[error]../../../go/src/golang.org/x/sys/unix/syscall_darwin.1_12.go:23:24: undefined: SYS_GETDIRENTRIES64

Thanks @itchyny. We use Gerrit for comments on changes, so usually people don't check GitHub. Thus, I copied your comment to https://golang.org/cl/250437 and will send a follow-up CL. The intention was to still keep compatibility for Go 1.12 for a while and only drop support for Go 1.11 and earlier.

@tklauser
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sent https://golang.org/cl/251317 with a fix.

@itchyny
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your quick fix.

@shivanvss
Copy link

@shivanvss shivanvss commented on 6fcdbc0 Aug 31, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit makes mac-os in go.1.13.11 fail. Could you please help

vendor/github.com/shirou/gopsutil/internal/common/common_darwin.go:39:3: undefined: unix.SYS___SYSCTL
vendor/github.com/shirou/gopsutil/internal/common/common_darwin.go:57:3: undefined: unix.SYS___SYSCTL

@ianlancetaylor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use GitHub as our primary review platform. Please comment on Gerrit, at https://golang.org/cl/250437. I will copy this comment there. Thanks.

@sethvargo
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tklauser @ianlancetaylor this appears to have broken dockertest as well: ory/dockertest#212

Please sign in to comment.