magefile / mage

a Make/rake-like dev tool using Go
https://magefile.org
Apache License 2.0
4.01k stars 250 forks source link

Cross compile with CGO_ENABLED for amd64 on arm64 ld: library not found for -lcrt0.o #500

Open gcstang opened 5 months ago

gcstang commented 5 months ago

Bug Description when compiling on macOS Ventura 13.6.3 with an m1 (arm) for a mac (x86) darwin/amd64 that requires CGO_ENABLED=1 env set I receive this error; I've looked and search everywhere and can't find anything on why this would happen; if I run the same build command from the terminal it works without error.

/Users/<myuser>/go/pkg/tool/darwin_arm64/link: running clang failed: exit status 1 ld: library not found for -lcrt0.o clang: error: linker command failed with exit code 1 (use -v to see invocation)

What did you do? GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 go build -tags '-ldflags -s -w -X "github.com/domainX/utils/version.GITCOMMIT=637b0a4-dirty" -X "github.com/domainX/utils/version.VERSION=" -X "github.com/domainX/utils/version.BUILDDATE=1706112416" -X "github.com/domainX/utils/version.GOVERSION=go1.21.6" -extldflags -static' -o /Volumes/990pro/STUFF/tclg/GitRepositories/personal/GoLang/src/github.com/domainX/examples/ex_mousemove/cross/mousemove-darwin-amd64/mousemove ./cmd/mousemove/.

What did you expect to happen? Build to not error as it does on the terminal (iTerm2)

What actually happened? ld library not found error /Users/<myuser>/go/pkg/tool/darwin_arm64/link: running clang failed: exit status 1 ld: library not found for -lcrt0.o clang: error: linker command failed with exit code 1 (use -v to see invocation)

Environment