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: 'go build -n' is sometimes non-runnable due to indented EOF #42931

Closed
sigxcpu76 opened this issue Dec 1, 2020 · 3 comments
Closed

cmd/go: 'go build -n' is sometimes non-runnable due to indented EOF #42931

sigxcpu76 opened this issue Dec 1, 2020 · 3 comments
Labels
FrozenDueToAge 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

@sigxcpu76
Copy link

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

go version go1.15.5 linux/amd64

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="amd64"
GOBIN=""
GOCACHE=""
GOENV=""
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH=""
GOPRIVATE=""
GOPROXY=""
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/sigxcpu/tmp/lock_analyzer/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build820090170=/tmp/go-build -gno-record-gcc-switches"

What did you do?

go build -n

What did you expect to see?

A runnable script of all the executed commands that will be done by go build

What did you see instead?

A non-runnable script because one of the EOFs is indented by a TAB.

This is the wrong output from a go build -n:

#go build -n        

...

mkdir -p $WORK/b001/
cat >$WORK/b001/_gomod_.go << 'EOF' # internal
package main
import _ "unsafe"
//go:linkname __debug_modinfo__ runtime.modinfo
var __debug_modinfo__ = "0w\xaf\f\x92t\b\x02A\xe1\xc1\a\xe6\xd6\x18\xe6path\ta.b/lock_analyzer\nmod\ta.b/lock_analyzer\t(devel)\t\n\xf92C1\x86\x18 r\x00\x82B\x10A\x16\xd8\xf2"
	EOF
cat >$WORK/b001/importcfg << 'EOF' # internal
...
@sigxcpu76 sigxcpu76 changed the title go build -n generates indented EOF that breaks script execution go build -n generates indented EOF that breaks script execution Dec 1, 2020
@bcmills bcmills added help wanted NeedsFix The path to resolution is known, but the work has not been done. labels Dec 2, 2020
@bcmills bcmills changed the title go build -n generates indented EOF that breaks script execution cmd/go: 'go build -n' is sometimes non-runnable due to indented EOF Dec 2, 2020
@bcmills bcmills added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Dec 2, 2020
@bcmills bcmills added this to the Backlog milestone Dec 2, 2020
@gopherbot gopherbot removed the NeedsFix The path to resolution is known, but the work has not been done. label Dec 2, 2020
@bcmills
Copy link
Contributor

bcmills commented Dec 2, 2020

With what source code did you observe this issue?

Can you modify the existing test in $GOROOT/src/cmd/go/testdata/script/build_dash_x.txt such that it reproduces the problem?

@bcmills bcmills added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. and removed help wanted labels Dec 2, 2020
@sigxcpu76
Copy link
Author

Well, it looks that it was fixed here
5abba0c#diff-02850bc8beaa613f53f7b7ac9667d6c1e02f924aa0aa2cd9e8c56816673fb695

Btw, the title change is misleading because the indented EOF meant that it was always unrunnable.

@bcmills
Copy link
Contributor

bcmills commented Dec 2, 2020

Btw, the title change is misleading because the indented EOF meant that it was always unrunnable.

It was at the very least runnable in GOPATH mode. (That is the condition that the build_dash_x test covered prior to CL 255052.)

@golang golang locked and limited conversation to collaborators Dec 2, 2021
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. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

3 participants