惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
DataBreaches.Net
罗磊的独立博客
M
MIT News - Artificial intelligence
G
Google Developers Blog
V
V2EX
D
Docker
博客园_首页
The Cloudflare Blog
人人都是产品经理
人人都是产品经理
Y
Y Combinator Blog
WordPress大学
WordPress大学
T
Tailwind CSS Blog
博客园 - 司徒正美
J
Java Code Geeks
L
LangChain Blog
博客园 - 三生石上(FineUI控件)
B
Blog RSS Feed
博客园 - 【当耐特】
小众软件
小众软件
Apple Machine Learning Research
Apple Machine Learning Research
大猫的无限游戏
大猫的无限游戏
P
Proofpoint News Feed
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - Franky

Rust Blog

Security Advisory for Cargo (CVE-2026-5223) | Rust Blog Security Advisory for Cargo (CVE-2026-5222) | Rust Blog Project goals update — April 2026 (end of 2025H2) | Rust Blog Rust is participating in Outreachy | Rust Blog Raising the baseline for the `nvptx64-nvidia-cuda` target | Rust Blog Announcing Google Summer of Code 2026 selected projects | Rust Blog Announcing Rust 1.95.0 | Rust Blog docs.rs: building fewer targets by default | Rust Blog Changes to WebAssembly targets and handling undefined symbols | Rust Blog Announcing Rust 1.94.1 | Rust Blog Security advisory for Cargo | Rust Blog What we heard about Rust's challenges | Rust Blog Call for Testing: Build Dir Layout v2 | Rust Blog Announcing rustup 1.29.0 | Rust Blog Announcing Rust 1.94.0 | Rust Blog 2025 State of Rust Survey Results | Rust Blog Rust debugging survey 2026 | Rust Blog Update on the October 15, 2018 incident on crates.io Announcing Rust 1.29.2 Announcing Rust 1.29 Announcing Rust 1.28 What is Rust 2018? Announcing Rust 1.27.2 Announcing Rust 1.27.1 Security Advisory for rustdoc Announcing Rust 1.27 Announcing Rust 1.26.2 Announcing Rust 1.26.1 Rust turns three Announcing Rust 1.26
Cargo changes how arrays in config are merged | Inside Ru...
Arlo Siemsen on behalf of the Cargo team · 2023-08-24 · via Rust Blog

Cargo will be changing the order of merged configuration arrays, and we are looking for people to help test this change and provide feedback.

When an array in Cargo's configuration is defined in multiple places, the elements are merged together. The order that the elements were merged was inconsistent with how other configuration types were merged together, and was not working as expected.

The new merging order will match the precedence order of non-array configuration, with higher-precedence configuration being placed later in the array.

In the case of build.rustflags, this resolves the confusing situation where higher precedence flags (in a project's config.toml) are overridden with lower precedence flags (in the global $CARGO_HOME, for example).

This may result in behavior changes if a project depends on the existing merging order. If you have an environment that involves merging configuration arrays, please consider testing your project with nightly to ensure it will continue to work once this change stabilizes. If you encounter a problem, please file an issue.

The change is included in Cargo starting with nightly-2023-08-24 toolchain.

Merging Order

The previous merging order was unspecified, but in practice it was the following, with earlier entries appearing first in the array:

  • config.toml in the current directory
  • config.toml in a parent directory
  • config.toml in $CARGO_HOME
  • command-line (--config)
  • environment variable (CARGO_*)

The new merging order is:

  • config.toml in $CARGO_HOME
  • config.toml in a parent directory
  • config.toml in the current directory
  • environment variable (CARGO_*)
  • command-line (--config)

The implementation is in cargo#12515.

Impacted configuration settings

The following configuration settings have arrays of strings that will be impacted by this change:

Example

The following example shows how this change may impact you and why we are making this change.

With the following in your Cargo home directory (usually ~/.cargo/config.toml):

[build]
rustflags = ["-C", "target-cpu=x86-64-v2"]

and then inside a project directory there is a .cargo/config.toml configuration file with:

[build]
rustflags = ["-C", "target-cpu=x86-64-v3"]

when you run cargo build within that project, cargo would previously merge these so that it passes -C target-cpu=x86-64-v3 -C target-cpu=x86-64-v2 to rustc. Because rustc ignores options earlier on the command-line and only honors the last one, the result would end up using x86-64-v2. This would effectively cause the merged config settings in the current directory to be ignored.

This was not the intended behavior, since config merging should always start with the lowest precedence (things in the Cargo home directory) and have more-specific config locations override those.