gpt4 book ai didi

rust - 如何将 panic=abort 与外部依赖项一起使用?

转载 作者:行者123 更新时间:2023-11-29 07:46:56 24 4
gpt4 key购买 nike

对于单个 crate 项目,将这些行添加到 Cargo.toml 会按预期工作。

[profile.release]
panic = "abort"

然后构建项目:

cargo build --release

但是,在间接使用依赖项的项目上,我遇到了错误。

    Compiling c_vec v1.0.12
error: the linked panic runtime `panic_unwind` is not compiled with this crate's panic strategy `abort`

error: aborting due to previous error

Build failed, waiting for other jobs to finish...
error: Could not compile `c_vec`.

c_vec crate 是一个间接使用的依赖。

如何在没有冲突的多 crate 项目上使用 panic=abort


重要的细节:

最佳答案

看起来是因为 c_vecdylib 指定为其库类型之一。

我在 Github 上发现这是一个问题:https://github.com/rust-lang/cargo/issues/2738

ah unfortunately that's a bad error message but it'sbecause of crate-type = ["dylib", "rlib"] in the c_vec crate. Thiscauses Cargo to pass -C prefer-dynamic which links to the dylib thatwe ship which is compiled against panic_unwind, meaning the abort modeis indeed invalid (this error is coming from the compiler).

The fix here would be to remove "dylib" from the c_vec crate.

当然,您必须创建自己的 lodepngc_vec 来处理这个问题。

关于rust - 如何将 panic=abort 与外部依赖项一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39844260/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com