dtolnay / rustversion

Conditional compilation according to rustc compiler version
Apache License 2.0
334 stars 15 forks source link

Both #[rustversion::nightly] and #[rustversion::not(nightly)] evaluate to true when passing -Zsanitizer=address #31

Closed kgrech closed 2 years ago

kgrech commented 2 years ago

Hello! I've recently faced the issue with compiling vergen crate. See more details here.

I compile it this way:

> rustup default nightly
info: using existing install for 'nightly-x86_64-unknown-linux-gnu'
info: default toolchain set to 'nightly-x86_64-unknown-linux-gnu'

  nightly-x86_64-unknown-linux-gnu unchanged - rustc 1.60.0-nightly (08df8b81d 2022-01-30)
> export RUSTFLAGS=-Zsanitizer=address RUSTDOCFLAGS=-Zsanitizer=address
> cargo build

It seems to be root cause of the issue to be the following block of code in vergen's build.rs:

#[rustversion::nightly]
fn nightly_lints() {
    println!("cargo:rustc-cfg=nightly_lints");
}

#[rustversion::not(nightly)]
fn nightly_lints() {}

It seems both version of the nightly_lints are being added

dtolnay commented 2 years ago

I don't think this is a rustversion issue. Rustversion is not running at all in your link. The relevant error from what you pasted is:

error: /home/kgrech/vergen/target/debug/deps/librustversion-e67a322b869b9b50.so: undefined symbol: __asan_option_detect_stack_use_after_return
  --> build.rs:18:3
   |
18 | #[rustversion::nightly]
   |   ^^^^^^^^^^^