You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$> clang --version
Apple LLVM version 10.0.0 (clang-1000.10.44.4)
Target: x86_64-apple-darwin18.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
What did you do?
$ env GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go build -race
What did you expect to see?
A compiled program
What did you see instead?
/usr/local/Cellar/go/1.12.1/libexec/pkg/tool/darwin_amd64/link: running clang failed: exit status 1
ld: warning: ignoring file /var/folders/2g/3p3p4dn95yn1zzmwjrjjn57w0000gn/T/go-link-142075432/000002.o, file was built for unsupported file format ( 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 ) which is not the architecture being linked (x86_64): /var/folders/2g/3p3p4dn95yn1zzmwjrjjn57w0000gn/T/go-link-142075432/000002.o
ld: warning: ignoring file /var/folders/2g/3p3p4dn95yn1zzmwjrjjn57w0000gn/T/go-link-142075432/go.o, file was built for unsupported file format ( 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 ) which is not the architecture being linked (x86_64): /var/folders/2g/3p3p4dn95yn1zzmwjrjjn57w0000gn/T/go-link-142075432/go.o
Undefined symbols for architecture x86_64:
"__cgo_topofstack", referenced from:
__cgo_7e1b3c2abc8d_C2func_getnameinfo in 000017.o
__cgo_7e1b3c2abc8d_Cfunc_getnameinfo in 000017.o
__cgo_7e1b3c2abc8d_C2func_getaddrinfo in 000019.o
__cgo_7e1b3c2abc8d_Cfunc_gai_strerror in 000019.o
__cgo_7e1b3c2abc8d_Cfunc_getaddrinfo in 000019.o
__cgo_7b5af5e1ac14_Cfunc_ZSTD_getErrorName in 000021.o
__cgo_7b5af5e1ac14_Cfunc_ZSTD_isError in 000021.o
...
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [build_linux_dev] Error 2
The text was updated successfully, but these errors were encountered:
sitano
changed the title
build: cross-compiling for Linux x86_64 with CGO -race enabled failed on a Darwin
build: cross-compiling for Linux x86_64 with CGO -race enabled failed on macOS Mojave (Darwin)
Mar 15, 2019
bradfitz
changed the title
build: cross-compiling for Linux x86_64 with CGO -race enabled failed on macOS Mojave (Darwin)
cmd/go: cross-compiling for Linux x86_64 with CGO -race enabled failed on macOS Mojave (Darwin)
Mar 15, 2019
When trying to cross-compile a Go program that uses cgo, you need to have a C cross-compiler. In your case you are building with the C native compiler. That can't work.
@ianlancetaylor Yes, I know, I am only confused a little that having cgo only for race detector worked well in all previous Go versions with native compiler (like with 1.11.6)
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
YES
What operating system and processor architecture are you using (
go env
)?MacOS 10.14.3 (18D109) cross-compiling for Linux, AMD64
go env
OutputWhat xcode tools installed do you have?
What did you do?
$ env GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go build -race
What did you expect to see?
A compiled program
What did you see instead?
The text was updated successfully, but these errors were encountered: