I understand the Exec format errors when running a go compiled executable usually have to do with cross-compilation errors but that’s not what’s happening here.
I’m compiling in a cygwin install on Windows, attempting a 32-bit build from the amd64 zip files, and then trying to run in the exact same environment. I have tried explicitly setting GOOS and GOARCH before running the go build; that does not help. The interesting thing is that my build routine builds 14 different executables; 2 of them will run, the rest will not, with the EXEC error. Everything compile, links, and vets cleanly, they just will not run.
This is new behaviour since go 1.25; the code being compiled has not changed, the environment has not changed, I’m just trying to update the libraries we’re using - everything works on go 1.24. I cannot figure out what the two that will run are doing differently - except that they are quite small programs, and do not do much at all. One thing most (but not all) of the programs that will not run do is link with C code. If it were all of them, I’d think there was an issue with the Go 1.25 and MingGW
We do not use go modules; moving over to use them is a piece of tech debt on our list to address, but has not happened yet. I do not know if that could be part of the issue.
Any pointers as to where I could look to figure out what might have changed would be appreciated.
Have you found the solution for this issue?
I’m facing the same issue myself and I’m basically stuck on 1.24 since upgrading to 1.25 breaks my windows binaries.
Sort of? It appears the MinGW version being used is causing the issues. I found this discussion here:
However, while building my Go code with the suggested flags gave a runnable executable, I’m now failing when I try to load the actual dll with the C code. One step forward, I guess?
If you find a MInGW that works, please let me know