-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: recurses into directories only containing assembly .s files #56509
Comments
Closing per golangci/golangci-lint#3339 (comment). |
@mvdan please reopen. After a bit more digging I'm far more confident this is a golang problem, not golangci-lint. I did a bit more digging into the submodule that causes the problem, there are a number of deep directories which contain assembly files (.s). If they are removed then both tools go back to working correctly. I have tried jonathan@fleetlaptop:~/git/testrepo$ CGO_ENABLED=1 go build ./...
pattern ./...: main module (gitlab.com/fleetspace/monoverse) does not contain package gitlab.com/fleetspace/monoverse/external/loramac-node/src/boards/NAMote72/cmsis/arm-std
jonathan@fleetlaptop:~/git/testrepo$ CGO_ENABLED=0 go build ./...
pattern ./...: main module (gitlab.com/fleetspace/monoverse) does not contain package gitlab.com/fleetspace/monoverse/external/loramac-node/src/boards/NAMote72/cmsis/arm-std
jonathan@fleetlaptop:~/git/testrepo$ find external/loramac-node/ -iname *.s -exec rm '{}' \;
jonathan@fleetlaptop:~/git/testrepo$ CGO_ENABLED=0 go build ./...
go: build output "myapp" already exists and is a directory
Please not the change in behaviour with and without those .s files. |
Go code can contain assembly. Looks like this is working as intended. |
These assembly files are NOT expected to be included in any go builds. They are apparently breaking the build because they are accessible by walking the entire filesystem tree under the go.mod file, but they are external files. It doesn't make sense that they should be able to break the build. Further, the actual error is nonsensical. Why is the go tools trying to bring in random .s files not associated with any .go files? |
Since there is no Moreover, if it were treated as a Go package, then the “does not contain package” error message would be misleading (because, as far as I can tell, that directory is in the main module). |
Looking into this: here's a minimal reproducer script test:
Running it produces the following:
The interesting thing is that the contents of the .s file matter: if it's empty there's no error |
Change https://go.dev/cl/447357 mentions this issue: |
Thanks for reopening and looking into the bug :) |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I originally filed this issue with golangci-lint however they are pushing back that this is a go tooling problem. golangci/golangci-lint#3339
The Issue is that after adding a git submodule of a completely unrelated project into any part of the tree under the go.mod, attempting to build gives the wonderful error as follows
I have reproduced this with a clean checkout of the golangci-lint repo, as well as creating a test repo with nothing but the git submodule. Both show the same behavior.
What did you expect to see?
no problems with
go build
orgolangci-lint
when running with random unrelated git tree in the workdir.What did you see instead?
This is a copy of my terminal showing how to reproduce
Something weird is happening in this git submodule which is triggering broken go build (and other tools) behavior.
Cheers
The text was updated successfully, but these errors were encountered: