After updating the Go port for OpenBSD to start testing 1.23rc2, the build fails with:

===>  Building for go-1.23rc2
Building Go cmd/dist using /usr/ports/pobj/go-1.23rc2/go-openbsd-amd64-bootstrap. (go1.22.5 openbsd/amd64)
Building Go toolchain1 using /usr/ports/pobj/go-1.23rc2/go-openbsd-amd64-bootstrap.
go tool dist: /usr/ports/pobj/go-1.23rc2/go/src/cmd/internal/obj/x86/asm_test.go.orig.port:10: bootstrap-copied source file cannot import internal/testenv

This appears to be a result of code added in 805f6b3f5db, combined with the fact that the OpenBSD ports build applies patches (and hence patch produces a backup .orig.port file). This approach has worked without issue for Go 1.22 (and every earlier version) - the new code seems to be unnecessarily excessive since this is not a .go file, does not have any build tags and is additionally test code.

In order to avoid packaging complications, can we restrict this check to files that Go will actually compile?

Comment From: ianlancetaylor

Rather than try to have cmd/dist predict how the tools might change in the future, we have a list of ignored file prefixes and suffixes (ignorePrefixes and ignoreSuffixes in cmd/dist/buildtool.go. I suppose we could extend one of those lists.

Comment From: ianlancetaylor

As far as I know .orig.port is not a normal output of the patch program. How hard would it be for the OpenBSD process to use a different file name? It's not clear to me that the Go build process needs to work with unexpected files sprinkled into the tree.

Comment From: 4a6f656c

The .orig.port extension is used by OpenBSD's ports in order to avoid conflicts with .orig files that are bundled:

https://man.openbsd.org/bsd.port.mk.5#PATCHORIG

This could be changed back to the patch(1) default of .orig for the lang/go port if need be.

It seems a bit strange that the general Go source file rules are not applied here, but I can provide a diff that adds .orig to the ignoreSuffixes list if that is the preferred option.

Comment From: ianlancetaylor

I would be OK with changing bootstrapFixImports to only run on files whose names end with .go.