Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/link: output has .exe suffix added by gcc during external linking #11725
A project with the one file "main.go":
Run a console command:
Got two files in "C:\Users\username\AppData\Local\Temp":
Expect only one file in "C:\Users\username\AppData\Local\Temp":
Like as a result of project without cgo.
changed the title
A result of build cgo project on windows: two files and one zero sized
Jul 15, 2015
Thanks. Here is what I think is happening:
You invoke go build with "-o PATH/run0go". The go command passed that -o option directly to the linker. The linker opened that exact file name as the output file, without appending ".exe". The linker saw this was a cgo build, and decided to invoke the external linker. The Go linker closed the output file (PATH/run0go) but did not remove it. The Go linker passed the same -o option to the external linker. The external linker, being a regular Windows linker, appended ".exe". That created run0go.exe. The empty run0go file was created by the Go linker and never removed.
I think the real problem here is that gcc does not honour value passed via "-o" flag:
I think we should "force" gcc by putting . at the end of the file name (see my example above).