dtolnay / rustversion

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

RUSTFLAGS="-Z sanitizer=address" stop macros from importing #40

Closed BadPseudonym closed 1 year ago

BadPseudonym commented 1 year ago

When building with RUSTFLAGS="-Z sanitizer=address" I get the following error when using rustversion in my crate

error[E0463]: can't find crate for `rustversion`
 --> src/lib.rs:4:3
  |
4 | #[rustversion::nightly]
  |   ^^^^^^^^^^^ can't find crate

error: cannot determine resolution for the attribute macro `rustversion::nightly`
 --> src/lib.rs:4:3
  |
4 | #[rustversion::nightly]
  |   ^^^^^^^^^^^^^^^^^^^^
  |
  = note: import resolution is stuck, try simplifying macro imports

when building without RUSTFLAGS="-Z sanitizer=address" it all works correctly.

BadPseudonym commented 1 year ago

After checking https://doc.rust-lang.org/beta/unstable-book/compiler-flags/sanitizer.html#build-scripts-and-procedural-macros it turns out that sanitizer=address disables procedural-macros I think.

To bypass the issue I used

[profile.sanitizer_address]
inherits = "test"

[profile.sanitizer_address.package.atomic_epoch]
rustflags = [ "-Z", "sanitizer=address" ]

to only target the crate I wanted that didn't use procedural-macros