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
I've tried to build a go program for different os/architectures
This is the program:
david@iMac example % cat main.go
package main
import "fmt"
func main() {
fmt.Println("Hello world")
}
david@iMac example %
This is a build for linux os and arm64 arch
david@iMac example % GOOS=linux GOARCH=arm64 go build -ldflags=-v main.go
# command-line-arguments
HEADER = -H5 -T0x11000 -R0x10000
deadcode
symsize = 0
pclntab=453982 bytes, funcdata total 109667 bytes
symsize = 2352
symsize = 62088
49010 symbols
67772 liveness data
david@iMac example % file main
main: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, Go BuildID=1EuGVMlN4cDnr8BlGzcV/X7K-Pkf9r2YwkiBrKP6J/8u7GPK0eoIKFAW43GX6K/pHAjSmKoxybfPCmtW00z, not stripped
david@iMac example %
Everything went fine.
Same build, but trying different OS (darwin) with same cpu set (arm64)
david@iMac example % GOOS=darwin GOARCH=arm64 go build -ldflags=-v main.go
# command-line-arguments
HEADER = -H1 -T0x2000 -R0x1000
deadcode
symsize = 0
pclntab=487711 bytes, funcdata total 119215 bytes
symsize = 0
symsize = 0
host link: "clang" "-o" "/var/folders/vr/c1zlgjd13fndm8vp_nqrtlf00000gn/T/go-build581065135/b001/exe/a.out" "-Qunused-arguments" "/var/folders/vr/c1zlgjd13fndm8vp_nqrtlf00000gn/T/go-link-251820392/go.o" "-no-pie"
/usr/local/Cellar/go/1.14.2_1/libexec/pkg/tool/darwin_amd64/link: running clang failed: exit status 1
ld: warning: ignoring file /var/folders/vr/c1zlgjd13fndm8vp_nqrtlf00000gn/T/go-link-251820392/go.o, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
Undefined symbols for architecture x86_64:
"_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)
david@iMac example %
What did you expect to see?
A successfully built
What did you see instead?
A linker error
host link: "clang" "-o" "/var/folders/vr/c1zlgjd13fndm8vp_nqrtlf00000gn/T/go-build581065135/b001/exe/a.out" "-Qunused-arguments" "/var/folders/vr/c1zlgjd13fndm8vp_nqrtlf00000gn/T/go-link-251820392/go.o" "-no-pie"
/usr/local/Cellar/go/1.14.2_1/libexec/pkg/tool/darwin_amd64/link: running clang failed: exit status 1
ld: warning: ignoring file /var/folders/vr/c1zlgjd13fndm8vp_nqrtlf00000gn/T/go-link-251820392/go.o, building for macOS-x86_64 but attempting to link with file built for unknown-arm64
Undefined symbols for architecture x86_64:
"_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)
The text was updated successfully, but these errors were encountered:
The problem is that darwin-arm64 does not support internal linking, which means that Go has to invoke the C linker, which means that you need to have a cross-linker from your host system to darwin-arm64. The Go linker is invoking the C linker, but it's not a cross-linker, so it fails.
At present we assume that darwin-arm64 is an iPhone, so in general it only works for building for a mobile device. See #38485.
I'm going to close this issue since there isn't much we can do at present, but if you want to repurpose this in some way that would be OK.
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
)?go env
OutputWhat did you do?
I've tried to build a go program for different os/architectures
This is the program:
This is a build for linux os and arm64 arch
Everything went fine.
Same build, but trying different OS (darwin) with same cpu set (arm64)
What did you expect to see?
A successfully built
What did you see instead?
A linker error
The text was updated successfully, but these errors were encountered: