Skip to content

Commit df65616

Browse files
Gelbpunkttgross35
authored andcommitted
build: Don't warn when enabling opting into musl 1.2 via multiple ways
In Alpine, we have to set both the old and new `cfg` *and* the environment variable since various versions of libc are being used by packaged software. This will then emit the warnings about the options being deprecated, even though we fully intentionally set them. I believe the primary purpose of the warnings is to tell people to migrate to the new `cfg`, so we can just not print a warning if musl 1.2 is being opted into via a different way (and the `cfg` or env var has no effect) already.
1 parent c610b5f commit df65616

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

build.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -220,17 +220,21 @@ fn main() {
220220

221221
let mut musl_v1_2_env = env_flag("CARGO_CFG_LIBC_UNSTABLE_MUSL_V1_2");
222222
if let Ok(old_musl_v1_2_3_env) = env::var("CARGO_CFG_LIBC_UNSTABLE_MUSL_V1_2_3") {
223-
println!(
224-
"cargo:warning=`--cfg=libc_unstable_musl_v1_2_3` will be removed; \
225-
set `--cfg=libc_unstable_musl_v1_2`instead"
226-
);
223+
if !musl_v1_2_env {
224+
println!(
225+
"cargo:warning=`--cfg=libc_unstable_musl_v1_2_3` will be removed; \
226+
set `--cfg=libc_unstable_musl_v1_2`instead"
227+
);
228+
}
227229
musl_v1_2_env |= old_musl_v1_2_3_env != "0";
228230
}
229231
if let Ok(old_musl_v1_2_3_env) = env::var("RUST_LIBC_UNSTABLE_MUSL_V1_2_3") {
230-
println!(
231-
"cargo:warning=RUST_LIBC_UNSTABLE_MUSL_V1_2_3 will be removed; \
232-
set `--cfg=libc_unstable_musl_v1_2` via RUSTFLAGS instead"
233-
);
232+
if !musl_v1_2_env {
233+
println!(
234+
"cargo:warning=RUST_LIBC_UNSTABLE_MUSL_V1_2_3 will be removed; \
235+
set `--cfg=libc_unstable_musl_v1_2` via RUSTFLAGS instead"
236+
);
237+
}
234238
musl_v1_2_env |= old_musl_v1_2_3_env != "0";
235239
}
236240

0 commit comments

Comments
 (0)