Skip to content

runtime/cgo: cgo.exe: exit status 2 #1359

@zzdboy

Description

@zzdboy

Go version
go version go1.25.1 windows/amd64

PS E:\Go\src\adps> 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=E:\Go\bin
set GOCACHE=C:\Users\Administrator\AppData\Local\go-build
set GOCACHEPROG=
set GODEBUG=
set GOENV=C:\Users\Administrator\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\ADMINI~1\AppData\Local\Temp\go-build617750731=/tmp/go-build -gno-record-gcc-switches
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMOD=E:\Go\src\adps\go.mod
set GOMODCACHE=E:\Go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=E:\Go
set GOPRIVATE=
set GOPROXY=https://goproxy.cn,direct
set GOROOT=E:\PhpWebStudy-Data\env\golang
set GOSUMDB=sum.golang.org
set GOTELEMETRY=on
set GOTELEMETRYDIR=C:\Users\Administrator\AppData\Roaming\go\telemetry
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=E:\PhpWebStudy-Data\env\golang\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.25.1
set GOWORK=
set PKG_CONFIG=pkg-config

PS E:\Go\src\adps> go build -x
WORK=C:\Users\ADMINI~1\AppData\Local\Temp\go-build3942602973
cd E:\Go\src\adps
git status --porcelain
cd E:\Go\src\adps
git -c log.showsignature=false log -1 --format=%H:%ct
cd E:\Go\src\adps; git config extensions.objectformat
0.040s # cd E:\Go\src\adps; git config extensions.objectformat
cd E:\Go\src\adps; git -c log.showsignature=false log --no-decorate -n1 '--format=format:%H %ct %D' 1c5987271d64ef1e257573f2261d8f1a26d151c4 --
0.040s # cd E:\Go\src\adps; git -c log.showsignature=false log --no-decorate -n1 '--format=format:%H %ct %D' 1c5987271d64ef1e257573f2261d8f1a26d151c4 --
cd E:\Go\src\adps; git for-each-ref --format %(refname) refs/tags --merged 1c5987271d64ef1e257573f2261d8f1a26d151c4
0.041s # cd E:\Go\src\adps; git for-each-ref --format %(refname) refs/tags --merged 1c5987271d64ef1e257573f2261d8f1a26d151c4
cd E:\Go\src\adps; git -c log.showsignature=false log --no-decorate -n1 '--format=format:%H %ct %D' 1c5987271d64 --
0.043s # cd E:\Go\src\adps; git -c log.showsignature=false log --no-decorate -n1 '--format=format:%H %ct %D' 1c5987271d64 --
cd E:\Go\src\adps; git cat-file blob 1c5987271d64ef1e257573f2261d8f1a26d151c4:go.mod
0.040s # cd E:\Go\src\adps; git cat-file blob 1c5987271d64ef1e257573f2261d8f1a26d151c4:go.mod
mkdir -p $WORK\b156
cd E:\PhpWebStudy-Data\env\golang\src\runtime\cgo
TERM='dumb' CGO_LDFLAGS='' "E:\PhpWebStudy-Data\env\golang\pkg\tool\windows_amd64\cgo.exe" -objdir "$WORK\b156" -importpath runtime/cgo -import_runtime_cgo=false -import_syscall=false "-ldflags="-O2" "-g"" -- -I "$WORK\b156" -O2 -g -Wall -Werror -fno-stack-protector -Wdeclaration-after-statement "E:\PhpWebStudy-Data\env\golang\src\runtime\cgo\cgo.go"
runtime/cgo: E:\PhpWebStudy-Data\env\golang\pkg\tool\windows_amd64\cgo.exe: exit status 2

PS E:\Go\src\adps> gcc -v
Using built-in specs.
COLLECT_GCC=D:\msys64\mingw64\bin\gcc.exe
COLLECT_LTO_WRAPPER=D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-15.2.0/configure --prefix=/mingw64 --with-local-prefix=/mingw64/local --with-native-system-header-dir=/mingw64/include --libexecdir=/mingw64/lib --enable-bootstrap --enable-checking=release --with-arch=nocona --with-tune=generic --enable-mingw-wildcard --enable-languages=c,lto,c++,fortran,ada,objc,obj-c++,jit --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-backtrace=yes --enable-libstdcxx-filesystem-ts --enable-libstdcxx-time --disable-libstdcxx-pch --enable-lto --enable-libgomp --disable-libssp --disable-multilib --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-libiconv --with-system-zlib --with-gmp=/mingw64 --with-mpfr=/mingw64 --with-mpc=/mingw64 --with-isl=/mingw64 --with-pkgversion='Rev8, Built by MSYS2 project' --with-bugurl=https://github.com/msys2/MINGW-packages/issues --with-gnu-as --with-gnu-ld --with-libstdcxx-zoneinfo=yes --disable-libstdcxx-debug --enable-plugin --with-boot-ldflags=-static-libstdc++ --with-stage1-ldflags=-static-libstdc++
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 15.2.0 (Rev8, Built by MSYS2 project)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions