Repository navigation
x/sys: Add Darwin support for clonefile and clonefileat #41366
Copy link
Copy link
Closed
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.OS-Darwin
Milestone
Description
What version of Go are you using (go version)?
$ go version 1.14.2
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (go env)?
go env Output
$ go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/Users/stanhu/Library/Caches/go-build" GOENV="/Users/stanhu/Library/Application Support/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOINSECURE="" GONOPROXY="" GONOSUMDB="" GOOS="darwin" GOPATH="/Users/stanhu/.gvm/pkgsets/go1.14.2/global" GOPRIVATE="" GOPROXY="https://goproxy.io,direct" GOROOT="/Users/stanhu/.gvm/gos/go1.14.2" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/Users/stanhu/.gvm/gos/go1.14.2/pkg/tool/darwin_amd64" GCCGO="gccgo" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="/Users/stanhu/github/sys/go.mod" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/6v/0wvd8sg951l59wy4242m3thh0000gn/T/go-build411355479=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
Attempted to build git-lfs with the latest Go version: git-lfs/git-lfs#4245
What did you expect to see?
No errors.
What did you see instead?
git-lfs has a dependency on direct system calls, which is no longer supported in Go v1.12:
util_darwin.go:127:3: undefined: unix.SYS_CLONEFILEAT
Is adding support a matter of just adding these lines?
diff --git a/unix/syscall_darwin.go b/unix/syscall_darwin.go
index e2a05ee..bd4b0a3 100644
--- a/unix/syscall_darwin.go
+++ b/unix/syscall_darwin.go
@@ -401,6 +401,8 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
//sys Chroot(path string) (err error)
//sys ClockGettime(clockid int32, time *Timespec) (err error)
//sys Close(fd int) (err error)
+//sys Clonefile(path string, dst_dirfd int, buf []byte, flags int) (err error)
+//sys Clonefileat(src_dirfd int, path string, dst_dirfd int, buf []byte, flags int) (err error)
//sys Dup(fd int) (nfd int, err error)
//sys Dup2(from int, to int) (err error)
//sys Exchangedata(path1 string, path2 string, options int) (err error)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.OS-Darwin
Activity
tklauser commentedon Sep 14, 2020
Yes, adding these lines and running
mkall.sh(or at leastgo run mksyscall.go) for all supportedGOARCHes should be enough. Would also be nice to have a test for these. Want to send a CL/PR?stanhu commentedon Sep 14, 2020
@tklauser Sure, I will give this shot. I did notice on the latest
masterbranch, runningGOOS=darwin GOARCH=amd64 sh mkall.shwithout changing anything resulted in this diff:diff
Is this expected?
tklauser commentedon Sep 14, 2020
@stanhu Yes, this is expected.
mkall.shwas probably run on an older macOS versions and some additional consts/types have been added in the meantime. For the matter of this change you can ignore these parts of the diff.unix: add Darwin support for clonefile syscalls
stanhu commentedon Sep 14, 2020
@tklauser Thanks, I created https://go-review.googlesource.com/c/sys/+/254757.
gopherbot commentedon Sep 15, 2020
Change https://golang.org/cl/254757 mentions this issue:
unix: add Darwin support for clonefile syscallsutil_darwin.go: Remove use of direct syscalls
tools/util_darwin.go: Remove use of direct syscalls
tools/util_darwin.go: Remove use of direct syscalls
tools/util_darwin.go: Remove use of direct syscalls
tools/util_darwin.go: Remove use of direct syscalls
unix: add Darwin support for clonefile syscalls