Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

How to pass --cfg to mirai? #1235

Open
AiDaiP opened this issue Aug 26, 2023 · 1 comment
Open

How to pass --cfg to mirai? #1235

AiDaiP opened this issue Aug 26, 2023 · 1 comment

Comments

@AiDaiP
Copy link

AiDaiP commented Aug 26, 2023

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)
@hermanventer
Copy link
Contributor

This seems like a bug. You can probably work around it for now as follows:
MIRAI_FLAGS="-- --cfg=my_cfg" cargo mirai

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants