我希望能将我的x86 Mac上的Rust程序交叉编译为可在Silicon Mac上运行的二进制文件,但我无法解决链接问题。
我有:
- 运行macOS 10.15.7 Catalina的x86 Mac - 一个名为“riff”的Rust项目 - 最近使用rustup获取的cargo 1.51.0 (43b129a20 2021-03-16) - Xcode版本为12.4(12D4e)
我想将其编译为可在Silicon(ARM)Mac上运行的二进制文件,可能是以下之一:
- 适用于Silicon特定的二进制文件 - 可在Silicon或x86上运行的通用二进制文件
我已经尝试过(通过./release.sh --dry):
我有:
- 运行macOS 10.15.7 Catalina的x86 Mac - 一个名为“riff”的Rust项目 - 最近使用rustup获取的cargo 1.51.0 (43b129a20 2021-03-16) - Xcode版本为12.4(12D4e)
我想将其编译为可在Silicon(ARM)Mac上运行的二进制文件,可能是以下之一:
- 适用于Silicon特定的二进制文件 - 可在Silicon或x86上运行的通用二进制文件
我已经尝试过(通过./release.sh --dry):
rustup target add aarch64-apple-darwin
cargo build --release --target=aarch64-apple-darwin
结果太长无法在此粘贴,这是摘录:
Compiling riff v0.1.0 (/Users/johan/src/riff)
error: linking with `cc` failed: exit code: 1
|
= note: "cc" "-arch arm64" "-L" "/Users/johan/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib" "/Users/johan/src/riff/target/aarch64-apple-darwin/release/deps/riff.1g47gi93dk96t2va.rcgu.o" ... "/Users/johan/src/riff/target/aarch64-apple-darwin/release/deps/riff.thread_local-9baf7723f72eef37.thread_local.7fl1y1d9-cgu.9.rcgu.o.rcgu.o" "/Users/johan/src/riff/target/aarch64-apple-darwin/release/deps/riff.unwind-082f7f4ff792426f.unwind.7rkx2ya0-cgu.0.rcgu.o.rcgu.o" "-o /Users/johan/src/riff/target/aarch64-apple-darwin/release/deps/riff" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "/Users/johan/src/riff/target/aarch64-apple-darwin/release/deps" "-L" "/Users/johan/src/riff/target/release/deps" "-L" "/Users/johan/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib" "/Users/johan/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcompiler_builtins-9eb7dc999785b765.rlib" "-lSystem" "-lresolv" "-lc" "-lm"
= note: ld: warning: ignoring file /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libresolv.tbd, missing required architecture arm64 in file /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libresolv.tbd
ld: warning: ignoring file /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libm.tbd, missing required architecture arm64 in file /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libm.tbd
ld: warning: ignoring file /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libc.tbd, missing required architecture arm64 in file /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libc.tbd
ld: warning: ignoring file /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd, missing required architecture arm64 in file /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd
Undefined symbols for architecture arm64:
"__tlv_atexit", referenced from:
std::sys::unix::thread_local_dtor::register_dtor::h4ece0fa32a190720 in riff.std-e40bd6a3af835df4.std.5bd9rdky-cgu.0.rcgu.o.rcgu.o
...
"_free", referenced from:
alloc::raw_vec::finish_grow::hd210c40bc8674cab (.llvm.18296587876935678160) in riff.addr2line-220464f1af330a49.addr2line.6xizm3st-cgu.1.rcgu.o.rcgu.o
addr2line::path_push::hf1048f2514c3ed28 in riff.addr2line-220464f1af330a49.addr2line.6xizm3st-cgu.5.rcgu.o.rcgu.o
alloc::raw_vec::finish_grow::ha5f485527a5c6598 in riff.addr2line-a950b2eed913eb15.addr2line.1hygsg7c-cgu.0.rcgu.o.rcgu.o
addr2line::path_push::h891160d400ff153e in riff.addr2line-a950b2eed913eb15.addr2line.1hygsg7c-cgu.0.rcgu.o.rcgu.o
core::ptr::drop_in_place$LT$aho_corasick..prefilter..Packed$GT$::h03bcd2abfab8068d in riff.aho_corasick-5d6c900557669556.aho_corasick.4z4l4vb2-cgu.0.rcgu.o.rcgu.o
core::ptr::drop_in_place$LT$aho_corasick..packed..pattern..Patterns$GT$::h0c7fda104debb352 in riff.aho_corasick-5d6c900557669556.aho_corasick.4z4l4vb2-cgu.0.rcgu.o.rcgu.o
core::ptr::drop_in_place$LT$alloc..vec..Vec$LT$alloc..vec..Vec$LT$u8$GT$$GT$$GT$::h75f2b558c0581f8d in riff.aho_corasick-5d6c900557669556.aho_corasick.4z4l4vb2-cgu.0.rcgu.o.rcgu.o
...
(maybe you meant: alloc::alloc::box_free::ha8718384ecb60252 (.llvm.10945926475227631812), alloc::alloc::box_free::h58e664059c03effd (.llvm.10945926475227631812) , alloc::alloc::box_free::h75cae1a8684a32ce (.llvm.8938487907768303252) , alloc::alloc::box_free::h0459f8e1bcc5ae0a (.llvm.8938487907768303252) , alloc::alloc::box_free::hc3b2f94f9be4da06 (.llvm.7882408235892284297) , alloc::alloc::box_free::h75cae1a8684a32ce (.llvm.7882408235892284297) , alloc::alloc::box_free::h0459f8e1bcc5ae0a (.llvm.11547294393004044273) , alloc::alloc::box_free::hcc8806ce168336a8 (.llvm.2537316772799228199) , alloc::alloc::box_free::h305ed20a6d3d49c7 (.llvm.11075277010792284734) , alloc::alloc::box_free::h384e6b725c5ad166 (.llvm.7882408235892284297) , alloc::alloc::box_free::h0459f8e1bcc5ae0a (.llvm.7882408235892284297) , alloc::alloc::box_free::hb8cf920d803cfa22 (.llvm.4992613404806278909) , alloc::alloc::box_free::h90dd1ed16b644fc1 (.llvm.9562203231941335137) , alloc::alloc::box_free::h9e3286b91a0737ba (.llvm.4992613404806278909) , alloc::alloc::box_free::h75cae1a8684a32ce (.llvm.11547294393004044273) )
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
SDKROOT = $(xcrun -sdk macosx --show-sdk-path)MACOSX_DEPLOYMENT_TARGET = $(xcrun -sdk macosx --show-sdk-platform-version)cargo build --target = aarch64-apple-darwin
- GutenYe