-
-
Save Siedlerchr/48d47639ace1ebc32e1beb125b6da739 to your computer and use it in GitHub Desktop.
MacOS M1 cross compile and build a fat binary with aarch64/arm64 and x86_64/amd64
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
clang hello.c -target arm64-apple-darwin20.1.0 -o hello.arm64 | |
echo -n "hello.arm64 is architecture " && lipo -archs ./hello.arm64 | |
clang hello.c -target x86_64-apple-darwin-macho -o hello.x86_64 | |
echo -n "hello.x86_64 is architecture " && lipo -archs ./hello.x86_64 | |
lipo hello.arm64 hello.x86_64 -create -output hello | |
echo -n "final output binary has archs " && lipo -archs ./hello |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(void) { | |
puts("Hello, world!"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment