I did, on linux, go build . on a project firstly created on Windows, containing a main.go file but also a resource.syso file generated with winres, that contains my icon file for the windows executable. The build was from linux this time, targeting linux, so i didn't pay attention to the .syso file.
What did you expect to see?
A working build
What did you see instead?
go build . dropped this error :
/usr/lib/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/tmp/go-link-918954239/000000.o: file not recognized: File format not recognized
collect2: error: ld returned exit status 1
It took me like 1 hour to think that go build was trying to include the .syso file even when i was on linux, and was crashing the build because of this, i didn't really pay attention to the command as it was issued by a script.
go build should ignore .syso file on systems other than windows, or (i don't know if .syso is a windows-only extension) display a more readable error
The text was updated successfully, but these errors were encountered:
All the Go toolchain does with a .syso file is turn it over to the external linker. It is the external linker that is producing that error message. I'm not clear on what the Go tools can do to get a better error, but I'm open for suggestions. I suppose the Go tool could say something like "by the way, when the linker failed just then, we were passing it a .syso file."
At the point where the linker is invoked, the .syso file has been stuffed into an archive, and the name has potentially been truncated. I don't think we should print a truncated name, and I don't feel like going to the effort of preserving the original name.