在Intel机器上构建AppleSilicon二进制文件
如何在 macOS 11(英特尔)上编译 C 项目以在 ?Silicon 上工作?
我当前的构建脚本非常简单:
./configure
make
sudo make install
我已经使用了尝试--host和--target标志有aarch64-apple-darwin和arm-apple-darwin没有任何的运气。
二进制文件始终默认为x86_64:
> file foobar.so
foobar.so: Mach-O 64-bit bundle x86_64
更新:
似乎在--host指定时找不到 cc 和 gcc 。
checking for arm-apple-darwin-cc... no
checking for arm-apple-darwin-gcc... no
回答
我在这个页面上找到了一个使用这个的提示:
-target arm64-apple-macos11
当我从我的 mac 运行它时:
clang++ main.cpp -target arm64-apple-macos11
生成的 a.out 二进制文件被列为:
% file a.out
a.out: Mach-O 64-bit executable arm64
我安装了 XCode 12.2。
我面前没有 Arm Mac,所以我假设这可行。