Cgo: cannot parse gcc output

when building my program that relies on cgo with go-sqlite3, i run into this error:

$ go build .
# github.com/mattn/go-sqlite3
cgo: cannot parse gcc output $WORK\b066\\_cgo_.o as ELF, Mach-O, PE, XCOFF object

gcc and my linker are in my path:

$ which gcc
/c/Program Files/w64devkit/bin/gcc

$ gcc --version
gcc.exe (GCC) 15.2.0
Copyright (C) 2025 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ ld
C:\Program Files\w64devkit\bin\ld.exe: no input files

and my go env looks like this:

$ go env
set AR=ar
set CC=gcc
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_ENABLED=1
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set CXX=g++
set GCCGO=gccgo
set GO111MODULE=
set GOAMD64=v1
set GOARCH=amd64
set GOAUTH=netrc
set GOBIN=
set GOCACHE=C:\Users\spiritov\AppData\Local\go-build
set GOCACHEPROG=
set GODEBUG=
set GOENV=C:\Users\spiritov\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFIPS140=off
set GOFLAGS=
set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\spiritov\AppData\Local\Temp\go-build283819157=/tmp/go-build -gno-record-gcc-switches
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMOD=C:\code\github\spiritov\jump\api\go.mod
set GOMODCACHE=C:\Users\spiritov\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\spiritov\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Users\spiritov\sdk\go1.24.8
set GOSUMDB=sum.golang.org
set GOTELEMETRY=local
set GOTELEMETRYDIR=C:\Users\spiritov\AppData\Roaming\go\telemetry
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Users\spiritov\sdk\go1.24.8\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.24.8
set GOWORK=
set PKG_CONFIG=pkg-config

I don’t use cgo so I’m not familiar with it. But, I did find this issue:

Did you try cleaning your go cache with go clean -cache? Your gcc version is very recent, so, wondering if that got updated recently and is causing problems.

didn’t find this issue!, but i did go clean -cache and go clean -modcache to no avail..

however, i tracked it down to this issue since i was using my GCC version from w64devkit, which includes BigObj even though cgo doesn’t support it:

using GCC from mingw-w64 MSYS2 resolved this for me, though there is an open proposal for cgo to support BigObj:

1 Like

When I read the original post I was going to suggest this until saw that you already had found it. Years ago when I worked on some projects that needed cgo, I used mingw on windows.

1 Like