Mac M1 Rust:未找到 ld 框架 CoreFoundation M1

Mac M1 Rust: ld framework not found CoreFoundation M1

切换到 M1 后,我在用 Rust 编译 crate 时遇到问题。板条箱是“sqlx-macros”。正如 sqlx repo 中所讨论的,很明显这不是板条箱本身的问题。在 ld framework not found CoreFoundation M1 周围挖掘,我无法解决我的问题。

我是 运行:

rustc 1.57.0 (f1edd0429 2021-11-29)
rustup default stable-aarch64-apple-darwin

这里是有问题的错误:

error: linking with `cc` failed: exit status: 1
  |
  = note: "cc" "-arch" "arm64" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/sqlx_macros-407f772bf8e457dd.sqlx_macros.3789a723-cgu.0.rcgu.o" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/sqlx_macros-407f772bf8e457dd.sqlx_macros.3789a723-cgu.1.rcgu.o" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/sqlx_macros-407f772bf8e457dd.sqlx_macros.3789a723-cgu.10.rcgu.o" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/sqlx_macros-407f772bf8e457dd.sqlx_macros.3789a723-cgu.11.rcgu.o" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/sqlx_macros-407f772bf8e457dd.sqlx_macros.3789a723-cgu.12.rcgu.o" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/sqlx_macros-407f772bf8e457dd.sqlx_macros.3789a723-cgu.13.rcgu.o" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/sqlx_macros-407f772bf8e457dd.sqlx_macros.3789a723-cgu.14.rcgu.o" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/sqlx_macros-407f772bf8e457dd.sqlx_macros.3789a723-cgu.15.rcgu.o" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/sqlx_macros-407f772bf8e457dd.sqlx_macros.3789a723-cgu.2.rcgu.o" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/sqlx_macros-407f772bf8e457dd.sqlx_macros.3789a723-cgu.3.rcgu.o" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/sqlx_macros-407f772bf8e457dd.sqlx_macros.3789a723-cgu.4.rcgu.o" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/sqlx_macros-407f772bf8e457dd.sqlx_macros.3789a723-cgu.5.rcgu.o" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/sqlx_macros-407f772bf8e457dd.sqlx_macros.3789a723-cgu.6.rcgu.o" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/sqlx_macros-407f772bf8e457dd.sqlx_macros.3789a723-cgu.7.rcgu.o" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/sqlx_macros-407f772bf8e457dd.sqlx_macros.3789a723-cgu.8.rcgu.o" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/sqlx_macros-407f772bf8e457dd.sqlx_macros.3789a723-cgu.9.rcgu.o" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/sqlx_macros-407f772bf8e457dd.312opvse87l793yj.rcgu.o" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/sqlx_macros-407f772bf8e457dd.281281m3wpaf90be.rcgu.o" "-L" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps" "-L" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/build/ring-00b2699d202c565f/out" "-L" "/Users/ulquiorra/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libdotenv-bcf0aca3b7bc8cd4.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libheck-626c5462f41d3929.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libunicode_segmentation-4b1977349c37e802.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libsyn-0c9f33ce0d41da04.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libsqlx_core-ae6ab38c5a09aaa7.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libcrc-da62e3c7cbfe97f5.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libcrc_catalog-d8370c27944dfe7a.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libhex-963718e6915ebdf6.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libwhoami-b6636d0fe6b91268.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libdirs-98e36b19a30fbb31.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libdirs_sys-d59a29575635414f.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libtokio_stream-530bb3979e3faf40.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libwebpki_roots-f4d1a9e1a1d281a7.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libsqlformat-db946c9c86afc529.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libunicode_categories-d7806e456d1ab4fc.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libnom-9324692423ffb34a.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libitertools-d0210e435c329f53.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libthiserror-40227fc935d966f7.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libbitflags-53a23abfe027286d.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/liburl-b6579ec0b8c695a0.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libidna-7c6b1ea0f937ef50.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libform_urlencoded-baa7e538d4ef6431.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libmatches-b58d0fe416543617.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libpercent_encoding-b55ac354f0255b20.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libmd5-74915dbb5c56bd05.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libbyteorder-5d34a33e544c853e.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libatoi-fead19dad46f0cbe.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libstringprep-b9be9e9ddfd94a5b.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libunicode_normalization-1980ff400d6709e5.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libtinyvec-58e0d3e4e182f228.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libtinyvec_macros-41736dd33b4ff66e.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libunicode_bidi-407b876b0fa4c956.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/librand-cbdb2958ad4fad90.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/librand_chacha-bed58bf603b9118b.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libppv_lite86-d55f98a5438a00f7.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/librand_core-5208c26a4e220237.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libhmac-71ed912ade899bb7.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libcrypto_mac-56d4f0e9b07e56da.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libsubtle-552b2ce96e9ace11.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libsha2-cec98bdca95d0c85.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libopaque_debug-0f46acc0bcbe7ebb.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libdigest-5dd2957b2c31b03d.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libblock_buffer-0a07dc8582ad511a.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libgeneric_array-edb04608a7cb3595.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libtypenum-c46c02c8c2d27571.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libhashlink-674e6e90a10a40f5.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libhashbrown-5981cabd74cd4e62.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libahash-c5a767a72ff39fe9.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libchrono-110b9ff6cc82c0dd.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libnum_integer-156ed8041665f5a4.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libnum_traits-2f966b2053809582.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libtime-26b95385d2213e8c.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libuuid-9b78316751859aa3.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libgetrandom-73e09dbdfae59109.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libserde_json-773ad93690775692.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libryu-35ba9cc3d5d02dd4.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libitoa-4cdeaf4add7f7fd0.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libserde-59c3b31fd28fffeb.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libsqlx_rt-0055a762dd1794dd.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libactix_rt-c118c1f8d144d5d0.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libtokio_rustls-8bd246f1cb8a9967.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/librustls-97f8c4084bc5ddbc.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libbase64-6e74f6cd80c81bfd.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libsct-ab05719c0e066ee5.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libwebpki-609d9d6de2956b78.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libring-a9c07951cca54be0.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libuntrusted-7dfb22f78fd3918f.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libtokio-bd033529cc1f9fc7.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libsignal_hook_registry-5efdce841beb6fab.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libnum_cpus-739e46d4ad873a11.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libmemchr-c827c82476ce2244.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libonce_cell-5952971dafb2b2ba.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libbytes-e547253afcf8f088.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libmio-0e779c175f479389.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/liblog-6e3fcaf289c0785c.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libcrossbeam_queue-77a82f114d2b20fc.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libcrossbeam_utils-ddfbc5e71e018f2c.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/liblazy_static-81d20f7d7f1f4bd2.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libfutures_intrusive-654c41f3445053f5.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libparking_lot-ecf810bcff890217.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libparking_lot_core-1cca6e92e476ead3.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/liblibc-249ca7d010eefcfe.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libsmallvec-cd4d7a3bc73153b0.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libinstant-3bd2b2afc483c597.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libcfg_if-070e0057f85f12e1.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/liblock_api-3a560b1cbe9bd1bd.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libscopeguard-46314ee240534403.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libeither-630743a902737812.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libfutures_util-e40c3140032e0ba7.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libpin_project_lite-5bad0c04bfff9074.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libfutures_task-3f7fbb78f0996ac8.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libpin_utils-af5505e3a763c822.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libfutures_channel-3151aecc7bea8587.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libfutures_sink-341ec96125dc400e.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libfutures_core-4077c13931d0998f.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libquote-b86e51bb4f102c43.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libproc_macro2-2f754891ab7c601c.rlib" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libunicode_xid-deac7a8ae4518802.rlib" "/Users/ulquiorra/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libproc_macro-33d9c5891f008791.rlib" "/Users/ulquiorra/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libstd-81655915c211065a.rlib" "/Users/ulquiorra/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libpanic_unwind-6401d7836ab37fcf.rlib" "/Users/ulquiorra/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libobject-bee3b45bdece0195.rlib" "/Users/ulquiorra/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libmemchr-01c74ed3833459fe.rlib" "/Users/ulquiorra/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libaddr2line-48661015cf0226dd.rlib" "/Users/ulquiorra/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libgimli-f6cb12e379c9f859.rlib" "/Users/ulquiorra/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libstd_detect-01c2377d8875d7d3.rlib" "/Users/ulquiorra/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/librustc_demangle-4ecebe9133c1e15e.rlib" "/Users/ulquiorra/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libhashbrown-68b6457fbd59457b.rlib" "/Users/ulquiorra/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/librustc_std_workspace_alloc-9d4889633473e617.rlib" "/Users/ulquiorra/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libunwind-7d202cbf8f30fd4c.rlib" "/Users/ulquiorra/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcfg_if-412e60c7c12b3b8f.rlib" "/Users/ulquiorra/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/liblibc-45ccb8237a0071b3.rlib" "/Users/ulquiorra/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/liballoc-24424da3181053ad.rlib" "/Users/ulquiorra/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/librustc_std_workspace_core-5789d203d1806d35.rlib" "/Users/ulquiorra/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcore-22574ec029e9d229.rlib" "/Users/ulquiorra/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcompiler_builtins-56bb43a121401f7f.rlib" "-framework" "CoreFoundation" "-framework" "SystemConfiguration" "-framework" "Security" "-liconv" "-lSystem" "-lresolv" "-lc" "-lm" "-liconv" "-L" "/Users/ulquiorra/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib" "-o" "/Users/ulquiorra/workspace/mine/toys/zero2prod/target/debug/deps/libsqlx_macros-407f772bf8e457dd.dylib" "-Wl,-dead_strip" "-dynamiclib" "-Wl,-dylib" "-nodefaultlibs" "-undefined" "dynamic_lookup"
  = note: ld: framework not found CoreFoundation
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

在这一点上我有点不知道该怎么做,所以任何想法将不胜感激。

升级到新的 ARM Mac 时,Xcode 的命令行工具的链接目录可能会中断。

最简单的修复方法是为 Xcode 重新安装命令行工具:

sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install

然后构建项目:

cargo build