首页 文章

当从Xcode 8内部运行时,由于信号10,货物无法与`cc`链接

提问于
浏览
1

从Xcode 8中的macOS应用程序中运行 cargo 时出现了一个奇怪的错误:

Eonil$ cargo clean
[~/Temp/repotest1/ag] (master)
Eonil$ cargo build
   Compiling ag v0.1.0 (file:///Users/Eonil/Temp/repotest1/ag)
error: linking with `cc` failed: signal: 10
  |
  = note: "cc" "-m64" "-L" "/Users/Eonil/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/Eonil/Temp/repotest1/ag/target/debug/ag.0.o" "-o" "/Users/Eonil/Temp/repotest1/ag/target/debug/ag" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "/Users/Eonil/Temp/repotest1/ag/target/debug/deps" "-L" "/Users/Eonil/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/Eonil/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd-f5a209a9.rlib" "/Users/Eonil/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-f5a209a9.rlib" "/Users/Eonil/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libunwind-f5a209a9.rlib" "/Users/Eonil/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librand-f5a209a9.rlib" "/Users/Eonil/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcollections-f5a209a9.rlib" "/Users/Eonil/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_unicode-f5a209a9.rlib" "/Users/Eonil/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc-f5a209a9.rlib" "/Users/Eonil/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc_jemalloc-f5a209a9.rlib" "/Users/Eonil/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liblibc-f5a209a9.rlib" "/Users/Eonil/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcore-f5a209a9.rlib" "/Users/Eonil/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-f5a209a9.rlib" "-l" "System" "-l" "pthread" "-l" "c" "-l" "m"
  = note: 

error: aborting due to previous error

error: Could not compile `ag`.

To learn more, run the command again with --verbose.

为什么我会收到此错误以及如何解决此问题?

  • cargo 0.15.0-nightly (298a012 2016-12-20)

  • rustc 1.14.0 (e8a012324 2016-12-16)

1 回答

  • 2

    环境变量 MallocNanoZone 设置为 1 . 删除它或将其设置为 0 ,问题神奇地消失了 .

    我不知道为什么会这样 . 就我而言,使用 NSTask 在Xcode调试上下文中运行货物时发生错误 . Xcode自动设置 MallocNanoZone=1 ,它改变了一些对 cargo 执行不友好的内存管理行为 .

相关问题