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

cmd/cgo: generated code uses aliases even in modules using Go older than 1.9 #67738

Open
dominikh opened this issue May 30, 2024 · 1 comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. help wanted NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@dominikh
Copy link
Member

dominikh commented May 30, 2024

Go version

go version devel go1.23-722d59436b Thu May 16 02:00:26 2024 +0000 linux/amd64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/dominikh/.cache/go-build'
GOENV='/home/dominikh/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/dominikh/prj/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/dominikh/prj'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/dominikh/prj/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/dominikh/prj/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='devel go1.23-722d59436b Thu May 16 02:00:26 2024 +0000'
GODEBUG=''
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/tmp/foo/go.mod'
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 -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1611460511=/tmp/go-build -gno-record-gcc-switches'

What did you do?

Try to go build

-- foo.go --
package pkg

// #include <stdlib.h>
import "C"

func foo() {
	C.malloc(0)
}
-- go.mod --
module example.com

go 1.0

What did you see happen?

# example.com
$WORK/b001/_cgo_gotypes.go:23:6: type alias requires go1.9 or later (-lang was set to go1; check go.mod)

What did you expect to see?

No failure.

I'm mostly filing this for the sake of documentation, as it's probably not worth fixing. I don't think it negatively impacts any real projects. Any 1.0 module can upgrade to 1.9 (or 1.21, for that matter) without risking backwards incompatible changes. Additionally, any code base targeting a Go version older than 1.9 is unlikely to be a Go module in the first place.

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label May 30, 2024
@ianlancetaylor
Copy link
Contributor

Thanks, I don't think this is worth spending time on. If someone wants to send a fix, we can take a look.

@ianlancetaylor ianlancetaylor added this to the Unplanned milestone May 31, 2024
@mknyszek mknyszek added help wanted NeedsFix The path to resolution is known, but the work has not been done. labels Jun 3, 2024
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. help wanted NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants