gpt4 book ai didi

rust - 为什么定义 RUSTFLAGS 会导致 .cargo/config 中的 rustflags 被忽略?

转载 作者:行者123 更新时间:2023-12-05 05:51:34 25 4
gpt4 key购买 nike

我把它作为我的 ./cargo/config:

[target.aarch64-unknown-linux-gnu]
linker = "aarch64-none-linux-gnu-gcc"
rustflags = ["-C", "target-feature=+crt-static"]

我在 build.sh 中定义了 RUSTFLAGS,如下所示:

export RUSTFLAGS='--cfg chip_type="es"'

当我这样做时:

cargo build --target=aarch64-unknown-linux-gnu

我发现 "-C", "target-feature=+crt-static" 不包括在内。我该如何解决这个问题?

最佳答案

Cargo Configuration可以看出在 build.rustflags :

There are three mutually exclusive sources of extra flags. They are checked in order, with the first one being used:

  1. RUSTFLAGS environment variable.

  2. All matching target.<triple>.rustflags and target.<cfg>.rustflags config entries joined together.

  3. build.rustflags config value.

所以这个新的 build.sh代码解决了我的问题:

RUSTFLAGS='--cfg chip_type="es" '$RUSTFLAGS
RUSTFLAGS='-C target-feature=+crt-static '$RUSTFLAGS
export RUSTFLAGS

关于rust - 为什么定义 RUSTFLAGS 会导致 .cargo/config 中的 rustflags 被忽略?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70360722/

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