Skip to content

How to build a universal MachO library 'amd64+arm64' for MacOS? #31

Discussion options

You must be logged in to vote

You are correct. I've verified it over the weekend and using:(same versions run on intel mac and m1, build on m1)

env CGO_ENABLED=1 CGO_CFLAGS=-O3 GOARCH=amd64 go build -o darwin_amd64.dylib -buildmode=c-shared

and

env CGO_ENABLED=1 CGO_CFLAGS=-O3 GOARCH=arm64 go build -o darwin_amd64.dylib -buildmode=c-shared

and bundling it later on with :

lipo -create <pathToIntel.a> <pathToArm.a> -output <pathToUniversal.a>

Yields a working universal build.
If you're open to PRs, I will add that to the documentation with links as to why and such.

Replies: 1 comment 8 replies

Comment options

You must be logged in to vote
8 replies
@Splizard
Comment options

@jugglingjsons
Comment options

@Splizard
Comment options

@jugglingjsons
Comment options

Answer selected by Splizard
@Splizard
Comment options

@jugglingjsons
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants