-
Notifications
You must be signed in to change notification settings - Fork 18.8k
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-Darwincompiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.help wanted
Milestone
Description
What version of Go are you using (go version)?
$ go version go version go1.20.2 darwin/amd64 $ tail -n 1 go.mod require golang.org/x/sys v0.6.0
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/mk/Library/Caches/go-build" GOENV="/Users/mk/Library/Application Support/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOINSECURE="" GOMODCACHE="/Users/mk/.local/share/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="darwin" GOPATH="/Users/mk/.local/share/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/local/Cellar/go/1.20.2/libexec" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/Cellar/go/1.20.2/libexec/pkg/tool/darwin_amd64" GOVCS="" GOVERSION="go1.20.2" GCCGO="gccgo" GOAMD64="v1" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="/dev/null" GOWORK="" CGO_CFLAGS="-O2 -g" CGO_CPPFLAGS="" CGO_CXXFLAGS="-O2 -g" CGO_FFLAGS="-O2 -g" CGO_LDFLAGS="-O2 -g" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/7l/56csh9n54g503487v94kb2pm0000gp/T/go-build1532737799=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
https://go.dev/play/p/yqd7iBRFmEV
package main
import (
"fmt"
"golang.org/x/sys/unix"
)
func main() {
err := unix.Faccessat(unix.AT_FDCWD, "/bin/sh", unix.X_OK, unix.AT_EACCESS)
fmt.Println(err)
}What did you expect to see?
Program to run and (most likely) print <nil>.
What did you see instead?
Compilation error:
$ go run access.go
# command-line-arguments
./access.go:10:66: undefined: unix.AT_EACCESS
Comment
AT_EACCESS is specified by the POSIX standard, in the fcntl.h header; used by the faccessat syscall.
If the latter syscall is exposed, I don't see any reason why the AT_EACCESS constant is not provided.
Looking through the source code of the x/sys/unix package however, AT_EACCESS seems to only be available on Linux AT_EACCESS is missing from AIX and Darwin.
Workaround
I can workaround the issue by using CGo and manually poking at fcntl.h.
package main
import (
"fmt"
"golang.org/x/sys/unix"
)
// #include <fcntl.h>
import "C"
func main() {
err := unix.Faccessat(unix.AT_FDCWD, "/bin/sh", unix.X_OK, C.AT_EACCESS)
fmt.Println(err)
}$ go run access.go
<nil>
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-Darwincompiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.help wanted