如何从构建中排除特定的板条箱类型?

How to exclude a particular crate-type from build?

我的 Rust 项目依赖于 crate reqwest,它依赖于 hyper.

当我为 Android 平台构建项目时

cargo.exe build --target aarch64-linux-android

cargo 找不到 cc.

   Compiling hyper v0.14.4
error: linker `cc` not found

= note: The system cannot find the file specified. (os error 2)

error: aborting due to previous error

error: could not compile `hyper`.

如果我从 hyperCargo.toml

中删除以下行
[lib]
crate-type = ["lib", "staticlib", "cdylib"]

然后我就可以毫无问题地构建我的项目了。

如何在不修改 hyperCargo.toml 的情况下构建我的项目?如何从构建中排除其 staticlibcdylib 板条箱类型?

解决方案/解决方法

我找到了一个 solution/workaround 来解决我的问题。我已经添加到 .cargo/config:

[target.aarch64-linux-android]
linker = 'aarch64-linux-android28-clang.cmd'

现在 hyper 被编译为 libstaticlibcdylib。顺便说一句,想要 cc.

的是 cdylib 板条箱类型

解决方案/解决方法

我找到了一个 solution/workaround 来解决我的问题。我已经添加到 .cargo/config:

[target.aarch64-linux-android]
linker = 'aarch64-linux-android28-clang.cmd'

现在 hyper 被编译为 libstaticlibcdylib。顺便说一下,想要 cc.

的是 cdylib 板条箱类型