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: build produces a non-64bit version on Windows #26899

Closed
iwdgo opened this issue Aug 9, 2018 · 3 comments
Closed

cmd/go: build produces a non-64bit version on Windows #26899

iwdgo opened this issue Aug 9, 2018 · 3 comments

Comments

@iwdgo
Copy link
Contributor

iwdgo commented Aug 9, 2018

While investigating more efficient ways to evaluate new test scripts, the following issue showed up. It looks related to similar cmd/go issues opened recently. I suppose that a module is produced and not an exe seen the size in dir cantcompile :

09-08-18  18:25    <DIR>          .
09-08-18  18:25    <DIR>          ..
09-08-18  18:25             2.902 cantcompile
09-08-18  18:23               106 cantcompile.go

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

go version go1.11beta3 windows/amd64

Does this issue reproduce with the latest release?

I did not try tip

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

set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\()\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\()\Documents\Google\
set GOPROXY=
set GORACE=
set GOROOT=C:\Go
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=0
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\Costa\)\Local\Temp\go-build007169846=/tmp/go-build -gno-record-gcc-switches

What did you do?

I tried several parameters configuration with always the same result where -x -v -work do not provide much information. Work directories are empty at best:
go build -x -v -work -i -o cantcompile.exe
go build -x -v -work -o cantcompile -i
and go build -i produces nothing.

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.

package cantcompile

import "fmt"

func main() {
	fmt.Println("can't compile if package is not main ?")
}

A link on play.golang.org is best.

What did you expect to see?

Some error message during build probably.

What did you see instead?

An executable is produced and if you try running it, you receive a message from very very old days.
gobuild16bit

@AlexRouSg
Copy link
Contributor

https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies

When compiling a single main package, build writes the resulting executable to an output file named after the first source file ('go build ed.go rx.go' writes 'ed' or 'ed.exe') or the source code directory ('go build unix/sam' writes 'sam' or 'sam.exe'). The '.exe' suffix is added when writing a Windows executable.

When compiling multiple packages or a single non-main package, build compiles the packages but discards the resulting object, serving only as a check that the packages can be built.

You are building a non-main package, therefore the output is not a executable but a object file.

@bcmills
Copy link
Contributor

bcmills commented Aug 9, 2018

As @AlexRouSg notes, this seems to be working as designed.

@bcmills bcmills closed this as completed Aug 9, 2018
@iwdgo
Copy link
Contributor Author

iwdgo commented Aug 12, 2018

I forgot to explain the inconsistency that the go run message is not displayed during go build:

C:\Users\()\Documents\Google\CloudSDK\sandbox\src\cantcompile>go run cantcompile.go
go run: cannot run non-main package

@golang golang locked and limited conversation to collaborators Aug 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants