Closed
Description
Code
I ran cargo build -vv
with this code:
# Cargo.toml
[package]
name = "repro"
version = "0.1.0"
edition = "2021"
// build.rs
fn main() {
dbg!(std::env::var("CARGO_CFG_TARGET_HAS_ATOMIC").ok());
dbg!(std::env::var("CARGO_CFG_TARGET_HAS_ATOMIC_LOAD_STORE").ok());
dbg!(std::env::var("CARGO_CFG_TARGET_HAS_ATOMIC_EQUAL_ALIGNMENT").ok());
}
I expected to see this happen:
[repro 0.1.0] [build.rs:2] std::env::var("CARGO_CFG_TARGET_HAS_ATOMIC").ok() = Some(
[repro 0.1.0] "128,16,32,64,8,ptr",
[repro 0.1.0] )
[repro 0.1.0] [build.rs:3] std::env::var("CARGO_CFG_TARGET_HAS_ATOMIC_LOAD_STORE").ok() = Some(
[repro 0.1.0] "128,16,32,64,8,ptr",
[repro 0.1.0] )
[repro 0.1.0] [build.rs:4] std::env::var("CARGO_CFG_TARGET_HAS_ATOMIC_EQUAL_ALIGNMENT").ok() = Some(
[repro 0.1.0] "128,16,32,64,8,ptr",
[repro 0.1.0] )
Instead, this happened:
[repro 0.1.0] [build.rs:2] std::env::var("CARGO_CFG_TARGET_HAS_ATOMIC").ok() = Some(
[repro 0.1.0] "",
[repro 0.1.0] )
[repro 0.1.0] [build.rs:3] std::env::var("CARGO_CFG_TARGET_HAS_ATOMIC_LOAD_STORE").ok() = Some(
[repro 0.1.0] "",
[repro 0.1.0] )
[repro 0.1.0] [build.rs:4] std::env::var("CARGO_CFG_TARGET_HAS_ATOMIC_EQUAL_ALIGNMENT").ok() = Some(
[repro 0.1.0] "128,16,32,64,8,ptr",
[repro 0.1.0] )
It seems that cfg(target_has_atomic{,_load_store})
without value that is added in #106856 is overriding cfg(target_has_atomic{,_load_store})
with value.
This environment variable still seems to be rarely used in the ecosystem, but profiler_builtins uses it.
rust/library/profiler_builtins/build.rs
Line 67 in 231bcd1
Mentioning @vadorovsky who authored #106856
Version it worked on
It most recently worked on: nightly-2023-01-27
$ rustc +nightly-2023-01-27 --print cfg | grep target_has_atomic
target_has_atomic="128"
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_equal_alignment="128"
target_has_atomic_equal_alignment="16"
target_has_atomic_equal_alignment="32"
target_has_atomic_equal_alignment="64"
target_has_atomic_equal_alignment="8"
target_has_atomic_equal_alignment="ptr"
target_has_atomic_load_store="128"
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
Version with regression
nightly-2023-01-28
rustc --version --verbose
:
rustc 1.69.0-nightly (ef982929c 2023-01-27)
binary: rustc
commit-hash: ef982929c0b653436a6ea6892a2a839fba7c8b57
commit-date: 2023-01-27
host: aarch64-apple-darwin
release: 1.69.0-nightly
LLVM version: 15.0.7
$ rustc +nightly-2023-01-28 --print cfg | grep target_has_atomic
target_has_atomic
target_has_atomic="128"
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_equal_alignment="128"
target_has_atomic_equal_alignment="16"
target_has_atomic_equal_alignment="32"
target_has_atomic_equal_alignment="64"
target_has_atomic_equal_alignment="8"
target_has_atomic_equal_alignment="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="128"
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
@rustbot modify labels: +regression-from-stable-to-nightly -regression-untriaged