首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在通过交叉运行Rust时发送RUST_BACKTRACE=1

如何在通过交叉运行Rust时发送RUST_BACKTRACE=1
EN

Stack Overflow用户
提问于 2022-10-21 15:10:52
回答 1查看 90关注 0票数 1

我正在尝试交叉编译使用交叉的Rust项目

我得到了一个错误,我希望通过设置环境变量RUST_BACKTRACE=1来跟踪进程。

但我不知道如何在使用交叉时做到这一点。

编辑

我使用的是命令cross build --target aarch64-unknown-linux-gnu

这是我的“cross.toml”内容

代码语言:javascript
复制
[target.aarch64-unknown-linux-gnu]
openssl-sys = "0.9.76"

[build.env]
passthrough = [
    "RUST_BACKTRACE",
    "RUST_LOG",
    "TRAVIS",
]

[target.aarch64-unknown-linux-gnu.env]
passthrough = [
    "RUST_DEBUG",
]

在试图编译时,我得到了以下错误

代码语言:javascript
复制
 thread 'main' panicked at '

  Could not find directory of OpenSSL installation, and this `-sys` crate cannot
  proceed without this knowledge. If OpenSSL is installed and this crate had
  trouble finding it,  you can set the `OPENSSL_DIR` environment variable for the
  compilation process.

  Make sure you also have the development packages of openssl installed.
  For example, `libssl-dev` on Ubuntu or `openssl-devel` on Fedora.

  If you're in a situation where you think the directory *should* be found
  automatically, please open a bug at https://github.com/sfackler/rust-openssl
  and include information about your system as well as this message.

  $HOST = x86_64-unknown-linux-gnu
  $TARGET = aarch64-unknown-linux-gnu
  openssl-sys = 0.9.76

  ', /cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.76/build/find_normal.rs:191:5
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-10-23 10:21:25

passthrough中使用Cross.toml只是传递本地环境变量。因此,在您的示例中,它按预期工作,但是它没有按您的要求工作,原因是没有设置RUST_BACKTRACE变量。

在Linux/Unix (mac)中,您可以通过编写echo $RUST_BACKTRACE和编写RUST_BACKTRACE=1临时设置环境的值。

因此,为了在交叉中设置变量,可以在运行命令时设置RUST_BACKTRACE,如下所示:

代码语言:javascript
复制
RUST_BACKTRACE=1 cross build --target aarch64-unknown-linux-gnu

也可以在Cross.toml配置中直接设置值,如下所示:

代码语言:javascript
复制
[target.aarch64-unknown-linux-gnu]
openssl-sys = "0.9.76"

[build.env]
passthrough = [
    "RUST_BACKTRACE=1",
    "RUST_LOG",
    "TRAVIS",
]

[target.aarch64-unknown-linux-gnu.env]
passthrough = [
    "RUST_DEBUG",
]
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74155695

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档