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: buildmode ignored when using -o #20017

Closed
multun opened this issue Apr 18, 2017 · 5 comments
Closed

cmd/go: buildmode ignored when using -o #20017

multun opened this issue Apr 18, 2017 · 5 comments
Labels
FrozenDueToAge help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@multun
Copy link

multun commented Apr 18, 2017

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

go version go1.8.1

What operating system and processor architecture are you using (go env)?

adm64 Archlinux

What did you do?

hello.go:

package notmain

import "fmt"

func main() {
	fmt.Println("42")
}
$ go build -buildmode=exe -o hello
$ file hello
hello: current ar archive

What did you expect to see?

An error, as the documentation states:

	-buildmode=exe
		Build the listed main packages and everything they import into
		executables. Packages not named main are ignored.

However, I feel like the buildmode pkgFilter was ignored because of -o being used:

if cfg.BuildO != "" {

What did you see instead?

An archive named hello was produced.

@bradfitz bradfitz changed the title go/build.go: buildmode ignored when using -o cmd/go: buildmode ignored when using -o Apr 18, 2017
@bradfitz bradfitz added this to the Go1.9Maybe milestone Apr 18, 2017
@bradfitz bradfitz added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 18, 2017
@multun
Copy link
Author

multun commented Apr 18, 2017

Does it make sense not to reuse the package list that was loaded here ?

@odeke-em
Copy link
Member

odeke-em commented Jun 4, 2017

/cc @rsc @ianlancetaylor

@multun
Copy link
Author

multun commented Jul 2, 2017

@odeke-em @rsc @ianlancetaylor so, what do you think ?

@ianlancetaylor
Copy link
Contributor

I think it's a bug but it doesn't seem like a very important one. @multun I don't know offhand if that is the right place to fix; if you can write a patch with a test case we can review it for 1.10. Thanks.

@gopherbot
Copy link

CL https://golang.org/cl/49371 mentions this issue.

@golang golang locked and limited conversation to collaborators Nov 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants