Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/sys/unix: Definition for O_PATH missing for most FreeBSD architectures #54355

Open
dfr opened this issue Aug 9, 2022 · 6 comments
Open

x/sys/unix: Definition for O_PATH missing for most FreeBSD architectures #54355

dfr opened this issue Aug 9, 2022 · 6 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FeatureRequest NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-FreeBSD
Milestone

Comments

@dfr
Copy link

dfr commented Aug 9, 2022

What version of Go are you using (go version)?

$ go version
go version go1.18.2 freebsd/amd64

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="/home/dfr/.cache/go-build"
GOENV="/home/dfr/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="freebsd"
GOINSECURE=""
GOMODCACHE="/home/dfr/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="freebsd"
GOPATH="/home/dfr/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/freebsd_amd64"
GOVCS=""
GOVERSION="go1.18.2"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="cc"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/home/dfr/go/src/github.com/containers/podman/go.mod"
GOWORK=""
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=/tmp/go-build3986639741=/tmp/go-build -gno-record-gcc-switches"

What did you do?

import "golang.org/x/sys/unix" and try to use unix.O_PATH on FreeBSD 13.1 or later

What did you expect to see?

The program should compile

What did you see instead?

the program does not compile

Notes

This symbol has been present in FreeBSD system headers since 13.1-RELEASE. The generated go code in x/sys/unix contains a definition for riscv in zerrors_freebsd_riscv64.go but the constant is missing for all other architectures. This symbol is not arch-dependent and should have the same value on all supported architectures.

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Aug 9, 2022
@gopherbot gopherbot added this to the Unreleased milestone Aug 9, 2022
@dmgk
Copy link
Member

dmgk commented Aug 9, 2022

I think adding O_PATH definition was a bit premature, given that the minimum supported FreeBSD version in go1.20 is 12.3, which lacks O_PATH support.

@dmgk
Copy link
Member

dmgk commented Aug 9, 2022

cc @golang/freebsd

@dmgk dmgk added the OS-FreeBSD label Aug 9, 2022
@dfr
Copy link
Author

dfr commented Aug 9, 2022

As far as I can tell, attempting to use the O_PATH flag on 12.3 will just ignore it and open the directory as a file which probably isn't ideal. In my case, I only plan to use thie in FreeBSD 13.1 or later but perhaps pubishing the symbol in x/sys/unix isn't ideal if 12.x is a supported release. The value for O_PATH does not conflict with any other flags supported in 12.x.

My workaround is to define the O_PATH constant in the application code which is a bit of a mess but otherwise should work.

@dmgk
Copy link
Member

dmgk commented Aug 9, 2022

My concern is that writing/testing application on 13.1 and then using it on 12.3 might create a false assumption that it implements something that in fact is not supported by the host OS.

@paulzhol
Copy link
Member

paulzhol commented Aug 9, 2022

I'm with agreement with @dmgk here, the zerrors_freebsd_riscv64.go should have been generated under a 12.3 Jail.

@dfr
Copy link
Author

dfr commented Aug 9, 2022

Makes sense - thanks for the added context. When my work-in-progress (podman on FreeBSD) makes it to the FreeBSD ports/package tree, I'll make sure its only built for 13.1 or later.

@thanm thanm added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FeatureRequest NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-FreeBSD
Projects
Status: Todo
Development

No branches or pull requests

6 participants