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: -o option to go build not accepted at end #40402

Open
kjk opened this issue Jul 25, 2020 · 6 comments
Open

cmd/go: -o option to go build not accepted at end #40402

kjk opened this issue Jul 25, 2020 · 6 comments

Comments

@kjk
Copy link

@kjk kjk commented Jul 25, 2020

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

$ go version
go version go1.14.4 windows/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
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\kjk\AppData\Local\go-build
set GOENV=C:\Users\kjk\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\kjk\go
set GOPRIVATE=
set GOPROXY=direct
set GOROOT=c:\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\kjk\AppData\Local\Temp\go-build301216802=/tmp/go-build -gno-record-gcc-switches

What did you do?

This used to work (in 1.13, I think) but fails in 1.14.4:

> go.exe build -tags api -trimpath  -o ..\presstige_api.exe .
can't load package: package -o is not in GOROOT (c:\go\src\-o)
can't load package: package ../presstige_api.exe: cannot find package "." in:
        C:\Users\kjk\src\presstige\presstige_api.exe

Note: If I do go build -o ... it works.

Maybe putting -o option at end was never supposed to work but it is a regression.

@seankhliao

This comment was marked as outdated.

@jtarchie
Copy link

@jtarchie jtarchie commented Jul 25, 2020

@seankhliao it looks like the report does have packages, the last . there.

@seankhliao
Copy link
Contributor

@seankhliao seankhliao commented Jul 25, 2020

ahh, in that case 🤷 The same command still works on linux

@cagedmantis cagedmantis changed the title -o option to go build not accepted at end cmd/go: -o option to go build not accepted at end Jul 27, 2020
@cagedmantis cagedmantis added this to the Backlog milestone Jul 27, 2020
@cagedmantis
Copy link
Contributor

@cagedmantis cagedmantis commented Jul 27, 2020

@bcmills
Copy link
Member

@bcmills bcmills commented Jul 30, 2020

I can only reproduce this on Linux if I add an explicit empty-string argument to the -trimpath flag.

example.com$ go build -tags api -trimpath  -o ..\whatever.exe .

example.com$ go build -tags api -trimpath '' -o ..\whatever.exe .
go: finding module for package ..whatever.exe
package -o is not in GOROOT (/usr/local/google/home/bcmills/sdk/gotip/src/-o)
malformed module path "..whatever.exe": leading dot in path element
@bcmills bcmills added the OS-Windows label Jul 30, 2020
@bcmills
Copy link
Member

@bcmills bcmills commented Jul 30, 2020

@kjk, does this still reproduce for you if you remove the doubled space after the -trimpath flag?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants
You can’t perform that action at this time.