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: rewrites file paths to absolute in godefs generated comment #52063

Closed
tklauser opened this issue Mar 31, 2022 · 1 comment
Closed

cmd/cgo: rewrites file paths to absolute in godefs generated comment #52063

tklauser opened this issue Mar 31, 2022 · 1 comment
Assignees
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@tklauser
Copy link
Member

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

$ go version
go version go1.18 darwin/amd64

Does this issue reproduce with the latest release?

Yes, also reproduces on gotip.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/tklauser/Library/Caches/go-build"
GOENV="/Users/tklauser/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/tklauser/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/tklauser/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.18"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/tklauser/src/go/src/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 -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/rr/8gjqqn1173v24m0d1l71rpx00000gn/T/go-build4129713692=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

$ cat <<EOF > defs.go
package defs

/*
struct a { int b; };
*/
import "C"

type A C.struct_a
EOF
$ go tool cgo -godefs defs.go

What did you expect to see?

// Code generated by cmd/cgo -godefs; DO NOT EDIT.
// cgo -godefs defs.go

package defs

type A struct {
	B int32
}

What did you see instead?

// Code generated by cmd/cgo -godefs; DO NOT EDIT.
// cgo -godefs /Users/tklauser/tmp/defs.go

package defs

type A struct {
	B int32
}

Note that the file path in the comment got rewritten to an absolute path, while it it was specified as a relative path on the command line.

/cc @ianlancetaylor

@tklauser tklauser added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Mar 31, 2022
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/396936 mentions this issue: cmd/cgo: retain original file paths in godefs generated comment

@tklauser tklauser self-assigned this Mar 21, 2023
@golang golang locked and limited conversation to collaborators Mar 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

2 participants