How to pass `--cfg` to mirai?
AiDaiP opened this issue · comments
AiDaiP commented
Issue
In my project, I need to use --cfg
to build. I tried using RUSTFLAGS
or config.toml
to pass --cfg
, which works for cargo build
but does not work for cargo mirai
Steps to Reproduce
pub mod my_mod{
#[cfg(my_cfg)]
fn func1(){}
fn func2(){
func1()
}
}
./.cargo/config.toml
[build]
rustflags = ["--cfg", "my_cfg"]
[target.x86_64-unknown-linux-gnu]
rustflags = ["--cfg", "my_cfg"]
cargo mirai
or
RUSTFLAGS="--cfg=my_cfg" cargo mirai
Expected Behavior
It should be same ascargo build
without any errors.
Actual Results
error[E0425]: cannot find function `func1` in this scope
--> src/lib.rs:6:9
|
6 | func1()
| ^^^^^ not found in this scope
For more information about this error, try `rustc --explain E0425`.
error: could not compile `timing_channels` (lib) due to previous error
Environment
rustc --version
rustc 1.70.0 (90c541806 2023-05-31)
Herman Venter commented
This seems like a bug. You can probably work around it for now as follows:
MIRAI_FLAGS="-- --cfg=my_cfg" cargo mirai