Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime/cgo: objdump error "unsupported architecture" for amd64 #39682

Closed
neclepsio opened this issue Jun 18, 2020 · 5 comments
Closed

runtime/cgo: objdump error "unsupported architecture" for amd64 #39682

neclepsio opened this issue Jun 18, 2020 · 5 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Windows
Milestone

Comments

@neclepsio
Copy link

What version of Go are you using (go version)?

$ go version
go version go1.14.2 windows/amd64

Does this issue reproduce with the latest release?

Yes, it happens with 1.14.4 too.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\[...]\AppData\Local\go-build
set GOENV=C:\[...]\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=c:\[...]\Go-Modules
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=c:\[...]\go1.14.2
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=c:\[...]\go1.14.2\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\[...]\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\[...]\Temp\go-build345817374=/tmp/go-build -gno-record-gcc-switches
gcc -v Output
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=c:/[...]/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.1.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-10.1.0/configure --prefix=/mingw64 --with-local-prefix=/mingw64/local --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-native-system-header-dir=/mingw64/x86_64-w64-mingw32/include --libexecdir=/mingw64/lib --enable-bootstrap --with-arch=x86-64 --with-tune=generic --enable-languages=c,lto,c++,fortran,ada,objc,obj-c++ --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-filesystem-ts=yes --enable-libstdcxx-time=yes --disable-libstdcxx-pch --disable-libstdcxx-debug --disable-isl-version-check --enable-lto --enable-libgomp --disable-multilib --enable-checking=release --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --disable-plugin --with-libiconv --with-system-zlib --with-gmp=/mingw64 --with-mpfr=/mingw64 --with-mpc=/mingw64 --with-isl=/mingw64 --with-pkgversion='Rev3, Built by MSYS2 project' --with-bugurl=https://sourceforge.net/projects/msys2 --with-gnu-as --with-gnu-ld
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.1.0 (Rev3, Built by MSYS2 project)

What did you do?

Minimal test.go:

package main

// void f() {}
import "C"

func main() {}

Commands:

C:\[...]\test>go build

C:\[...]\test>file test.exe
test.exe: PE32+ executable (console) x86-64, for MS Windows

C:\[...]\test>go tool objdump test.exe
objdump: disassemble test.exe: unsupported architecture

What did you expect to see?

The result of disassembly.

What did you see instead?

Error message objdump: disassemble test.exe: unsupported architecture.

This only happens for binaries using cgo. I didn't find anywhere this is unsupported, so I'm opening this issue. I'm using mingw64; gcc -v output is included above, in operating system details section. Binaries run correctly.

@andybons andybons changed the title objdump error "unsupported architecture" for amd64 using cgo cgo: objdump error "unsupported architecture" for amd64 Jun 18, 2020
@andybons
Copy link
Member

@ianlancetaylor

@andybons andybons added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 18, 2020
@andybons andybons changed the title cgo: objdump error "unsupported architecture" for amd64 runtime/cgo: objdump error "unsupported architecture" for amd64 Jun 18, 2020
@andybons andybons added this to the Unplanned milestone Jun 18, 2020
@gopherbot
Copy link

Change https://golang.org/cl/240957 mentions this issue: cmd/internal/objfile: use pe.FileHeader.Machine to determine GOARCH

@alexbrainman
Copy link
Member

@neclepsio

Thank you for reporting this problem. It appears it was always broken this way.

Can you, please, try this fix

https://go-review.googlesource.com/c/go/+/240957

?

Thank you.

Alex

@neclepsio
Copy link
Author

It works, thank you!

@alexbrainman
Copy link
Member

It works, thank you!

Thanks for checking. I will submit my change after go 1.15 is released. So this change will be part of go 1.16.

Alex

@golang golang locked and limited conversation to collaborators Aug 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Windows
Projects
None yet
Development

No branches or pull requests

5 participants