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/go: does not vendor some directories #59182

Closed
mcandre opened this issue Mar 22, 2023 · 4 comments
Closed

cmd/go: does not vendor some directories #59182

mcandre opened this issue Mar 22, 2023 · 4 comments
Labels
modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@mcandre
Copy link

mcandre commented Mar 22, 2023

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

$ go version
go version go1.19 darwin/arm64

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="arm64"
GOBIN=""
GOCACHE="/Users/andrew/Library/Caches/go-build"
GOENV="/Users/andrew/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/andrew/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/andrew/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/andrew/.asdf/installs/golang/1.19/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/andrew/.asdf/installs/golang/1.19/go/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.19"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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 arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/xc/s20l07yj76x8m3h20lmy5jlc0000gn/T/go-build3387780020=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Attempting to go mod vendor the package gitlab.com/gomidi/midi results in a critical cpp/ cgo directory being deleted in its entirety.

What did you expect to see?

Complete vendoring and successful cgo compilation.

What did you see instead?

I tried several recommended tricks to force go mod vendor to persist the directory, to no avail. I tried:

  • Adding a dummy.go file to the cpp/ directory (the most commonly recommended tip from the Go community).
  • Moving cpp/* to a parent directory with existing *.go files, and updating #include directives to account for the new locations.
  • Removing #include directives from *.go files (another Go community recommended tip).
  • Enclosing the C/C++ files with #pragma once or #ifndef... directives.

The only states I am have been able to achieve are:

  • go mod vendor deletes the cpp/ directory entirely
  • go install ./... complains of missing C/C++ declarations
  • go install ./... complains of duplicate C/C++ declarations

Can someone please explain what the gomidi/midi author should do to correct their go mod vendor integration in their CGO code?

As a workaround, I am currently using modvendor, but if at all possible, I would prefer to use only built-in go tools.

https://github.com/goware/modvendor

Frankly, the whole go vendoring system behaves awkwardly with cgo (above), with go install <dev tools> (no dev dependency tracking in go.mod), and with reflection (e.g. enum comparison). I am at a loss to explain why the different built-in Go components often fail to cooperate with each other.

@heschi heschi changed the title affected/package: go mod vendor cmd/go: does not vendor some directories Mar 22, 2023
@heschi
Copy link
Contributor

heschi commented Mar 22, 2023

cc @bcmills @matloob

@heschi heschi added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Mar 22, 2023
@heschi heschi added this to the Backlog milestone Mar 22, 2023
@mvdan
Copy link
Member

mvdan commented Mar 22, 2023

Adding a dummy.go file to the cpp/ directory (the most commonly recommended tip from the Go community).

Can you show an example of that not working? If you add a Go file to that directory to make it a Go package, and you either directly or indirectly import it from your main module, it should be included by go mod vendor. My guess is that you added the Go file, but did not add any import, so it got discarded as an unused import by go mod vendor, since it only includes the packages in the package import graph.

@mvdan mvdan added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Mar 22, 2023
@bcmills bcmills added the modules label Apr 3, 2023
@ccll

This comment was marked as off-topic.

@gopherbot
Copy link

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

6 participants