Now, let's compile for an Apple Silicon mac by using cross compilation: 1 $ GOOS=darwin GOARCH=arm64 go build -o hello-world-arm main.goģ /usr/local/Cellar/go/1.15.5/libexec/pkg/tool/darwin_amd64/link: running clang failed: exit status 1Ĥ ld: warning: ignoring file /var/folders/w3/x7jg17fj0099ppnd7qh25g1w0000gq/T/go-link-431194554/go.o, building for macOS-x86_64 but attempting to link with file built for unknown-arm64ĥ Undefined symbols for architecture x86_64:ħ 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) (go1.15.5 darwin/amd64)Ĩ Building Go toolchain1 using /usr/local/Cellar/go/1.15.5/libexec.ĩ Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.ġ0 Building Go toolchain2 using go_bootstrap and Go toolchain1.ġ1 Building Go toolchain3 using go_bootstrap and Go toolchain2.ġ2 Building packages and commands for darwin/amd64.ġ4 Installed Go for darwin/amd64 in /Users/pclaerhout/sdk/gotipġ5 Installed commands in /Users/admin/sdk/gotip/binĬompiling for an Intel mac is really easy, we can just run : 1 $ go build -o hello-world-x86 main.goģ hello-world-x86: Mach-O 64-bit executable x86_64 At this moment, the easiest way is to install the development version of Go using gotip: 1 $ go get /dl/gotipĦ HEAD is now at e5da18d os/exec: constrain thread usage in leaked descriptor test on illumosħ Building Go cmd/dist using /usr/local/Cellar/go/1.15.5/libexec. The first step is to install a version of Golang which supports compiling for the ARM processor. Let's use the most basic Go program we can imagine: There are ways to get it working as described by Sam Soffes in his blog post. Running the build on an Apple Silicon mac is more adventurous as tools like homebrew arent't fully supported yet. I'm testing this on an Intel mac running macOS Big Sur. Let's see how easy (or difficult) it is to compile a Go program into an executable which runs native on Intel macs and on the new Apple Silicon macs. Since Apple introduced the move to their own processor, called the M1 which is based on the ARM architecture, I wanted to figure out what this means to Go.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |