如何在 macOS 11 (Intel) 上编译 C 项目以在 Silicon 上运行?
我当前的构建脚本很简单:
./configure
make
sudo make install
我尝试过使用--host
and --target
标志与aarch64-apple-darwin
and arm-apple-darwin
没有任何运气。
二进制文件始终默认为x86_64
:
> file foobar.so
foobar.so: Mach-O 64-bit bundle x86_64
UPDATE:似乎 cc 和 gcc 没有找到--host
已指定。
checking for arm-apple-darwin-cc... no
checking for arm-apple-darwin-gcc... no
我发现了一个提示这一页 https://developer.apple.com/documentation/xcode/building_a_universal_macos_binary使用这个:
-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,所以我假设这可行。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)